MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / llama_tokenize

Function llama_tokenize

llama.cpp:10735–10755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10733}
10734
10735int llama_tokenize(
10736 const struct llama_model * model,
10737 const char * text,
10738 int text_len,
10739 llama_token * tokens,
10740 int n_max_tokens,
10741 bool add_bos,
10742 bool special) {
10743 auto res = llama_tokenize_internal(model->vocab, std::string(text, text_len), add_bos, special);
10744
10745 if (n_max_tokens < (int) res.size()) {
10746 // LLAMA_LOG_ERROR("%s: too many tokens\n", __func__);
10747 return -((int) res.size());
10748 }
10749
10750 for (size_t i = 0; i < res.size(); i++) {
10751 tokens[i] = res[i];
10752 }
10753
10754 return res.size();
10755}
10756
10757static std::string llama_decode_text(const std::string & text) {
10758 std::string decoded_text;

Callers 15

mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
eval_stringFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
perplexity_v2Function · 0.50

Calls 3

llama_tokenize_internalFunction · 0.85
stringFunction · 0.50
sizeMethod · 0.45

Tested by 5

mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40