MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / main

Function main

subprojects/llama.cpp/tests/test-tokenizer-1-bpe.cpp:17–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <atomic>
16
17int main(int argc, char **argv) {
18 if (argc < 2 || argc > 3) {
19 fprintf(stderr, "Usage: %s <vocab-file> [--ignore-merges]\n", argv[0]);
20 return 1;
21 }
22
23 const std::string fname = argv[1];
24 bool ignore_merges = false;
25 if (argc == 3) {
26 if (std::strcmp(argv[2], "--ignore-merges") != 0) {
27 fprintf(stderr, "Usage: %s <vocab-file> [--ignore-merges]\n", argv[0]);
28 return 1;
29 }
30 ignore_merges = true;
31 }
32
33 fprintf(stderr, "%s : reading vocab from: '%s'\n", __func__, fname.c_str());
34
35 if (ignore_merges) {
36 fprintf(stderr, "%s : ignoring merges for tokens inside vocab\n", __func__);
37 }
38
39 llama_model * model;
40 llama_context * ctx;
41
42 llama_backend_init();
43
44 // load the vocab
45 {
46 auto mparams = llama_model_default_params();
47
48 mparams.vocab_only = true;
49
50 model = llama_model_load_from_file(fname.c_str(), mparams);
51
52 if (model == NULL) {
53 fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, fname.c_str());
54 return 1;
55 }
56
57 auto cparams = llama_context_default_params();
58
59 ctx = llama_init_from_model(model, cparams);
60
61 if (ctx == NULL) {
62 fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, fname.c_str());
63 llama_model_free(model);
64 return 1;
65 }
66 }
67
68 const llama_vocab * vocab = llama_model_get_vocab(model);
69
70 //GGML_ASSERT(llama_vocab_type(vocab) == LLAMA_VOCAB_TYPE_BPE);
71 if (llama_vocab_type(vocab) != LLAMA_VOCAB_TYPE_BPE) {
72 return 99;
73 }
74

Callers

nothing calls this directly

Calls 15

llama_backend_initFunction · 0.85
llama_init_from_modelFunction · 0.85
llama_model_freeFunction · 0.85
llama_model_get_vocabFunction · 0.85
cleanupFunction · 0.85
llama_vocab_n_tokensFunction · 0.85
common_detokenizeFunction · 0.85
unicode_cpts_from_utf8Function · 0.85
common_tokenizeFunction · 0.85

Tested by

no test coverage detected