-
Notifications
You must be signed in to change notification settings - Fork 50
/
test-forward-semantic.cpp
59 lines (44 loc) · 1.68 KB
/
test-forward-semantic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cstdio>
#include <string>
#include <random>
#include <vector>
#include "bark.h"
#include "common.h"
static const std::vector<std::string> test_data = {
"./data/semantic/test_pass_semantic_1.bin", // prompt: Ceci est un texte en français pour tester le bon fonctionnement de bark.
"./data/semantic/test_pass_semantic_2.bin", // prompt: Sometimes the heart sees what is invisible to the eye
"./data/semantic/test_pass_semantic_3.bin", // prompt: El Arte de Vencer se Aprende en las Derrotas
};
static const int n_threads = 4;
static const float min_eos_p = 0.2;
static const float temp = 0.0f; // deterministic sampling
int main() {
const std::string fname = "../ggml_weights/ggml_weights_text.bin";
std::mt19937 rng(0);
bark_model model;
if (gpt_model_load(fname, model.text_model) > 0) {
fprintf(stderr, "%s: invalid model file '%s'\n", __func__, fname.c_str());
return 1;
}
bark_context * ctx = bark_new_context_with_model(&model);
ctx->rng = rng;
bark_sequence input;
bark_sequence gt_tokens;
for (int i = 0; i < (int) test_data.size(); i++) {
input.clear();
gt_tokens.clear();
std::string path = test_data[i];
load_test_data(path, input, gt_tokens);
ctx->tokens = input;
bark_forward_text_encoder(ctx, temp, min_eos_p, n_threads);
printf("\n");
printf("%s: %s\n", __func__, path.c_str());
if (!run_test(gt_tokens, ctx->semantic_tokens)) {
printf("%s: test %d failed.\n", __func__, i+1);
} else {
printf("%s: test %d passed.\n", __func__, i+1);
}
}
bark_free(ctx);
return 0;
}