MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / gpt_vocab_init

Function gpt_vocab_init

external/ggml/examples/common.cpp:382–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382bool gpt_vocab_init(const std::string & fname, gpt_vocab & vocab) {
383 printf("%s: loading vocab from '%s'\n", __func__, fname.c_str());
384
385 vocab.token_to_id = ::json_parse(fname);
386
387 for (const auto & kv : vocab.token_to_id) {
388 vocab.id_to_token[kv.second] = kv.first;
389 }
390
391 printf("%s: vocab size = %d\n", __func__, (int) vocab.token_to_id.size());
392
393 // print the vocabulary
394 //for (auto kv : vocab.token_to_id) {
395 // printf("'%s' -> %d\n", kv.first.data(), kv.second);
396 //}
397
398 return true;
399}
400
401gpt_vocab::id gpt_sample_top_k_top_p(
402 const gpt_vocab & vocab,

Callers

nothing calls this directly

Calls 2

json_parseFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected