MCPcopy Create free account
hub / github.com/Niko1221/Strata / cmd_export_tokenizer

Function cmd_export_tokenizer

engine/src/ling32/ling32_main.cpp:116–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116int cmd_export_tokenizer(const std::string& file, const std::string& dir) {
117 Ling32File f;
118 std::string err;
119 if (!f.open(file, err, true)) { std::fprintf(stderr, "strata-ling32: %s\n", err.c_str()); return 1; }
120 std::error_code ec;
121 std::filesystem::create_directories(dir, ec);
122 const std::filesystem::path d(dir);
123 if (f.man().tokenizer_json.empty() || f.man().chat_template.empty()) {
124 std::fprintf(stderr, "strata-ling32: this file's Section 0 has no tokenizer_json / chat_template\n");
125 return 1;
126 }
127 char tok[256];
128 std::snprintf(tok, sizeof tok, "{\"eos\":[%d,156892],\"pad\":%d,\"sampling\":{\"temperature\":0.6,\"top_p\":0.95,\"top_k\":20,\"repetition_penalty\":1.0}}\n", f.cfg().eos_id, f.cfg().pad_id);
129 if (!write_text(d / "tokenizer.hf.json", f.man().tokenizer_json) || !write_text(d / "chat_template.jinja", f.man().chat_template) || !write_text(d / "ling32_tokens.json", tok)) {
130 std::fprintf(stderr, "strata-ling32: cannot write into %s\n", dir.c_str());
131 return 1;
132 }
133 std::printf("tokenizer: %zu bytes, chat template: %zu bytes\n", f.man().tokenizer_json.size(), f.man().chat_template.size());
134 return 0;
135}
136
137// ------------------------------------------------------------------------------------------------ the run
138struct RunOpts {

Callers 1

mainFunction · 0.70

Calls 5

write_textFunction · 0.70
openMethod · 0.45
emptyMethod · 0.45
cfgMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected