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

Function llama_token_to_piece

common/common.cpp:1046–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044}
1045
1046std::string llama_token_to_piece(const struct llama_context * ctx, llama_token token) {
1047 std::vector<char> result(8, 0);
1048 const int n_tokens = llama_token_to_piece(llama_get_model(ctx), token, result.data(), result.size());
1049 if (n_tokens < 0) {
1050 result.resize(-n_tokens);
1051 int check = llama_token_to_piece(llama_get_model(ctx), token, result.data(), result.size());
1052 GGML_ASSERT(check == -n_tokens);
1053 } else {
1054 result.resize(n_tokens);
1055 }
1056
1057 return std::string(result.data(), result.size());
1058}
1059
1060std::string llama_detokenize_spm(llama_context * ctx, const std::vector<llama_token> & tokens) {
1061 const llama_token bos_id = llama_token_bos(llama_get_model(ctx));

Callers 6

llama_detokenize_spmFunction · 0.70
llama_detokenize_bpeFunction · 0.70
LOG_TOKENS_TOSTR_PRETTYFunction · 0.70
LOG_BATCH_TOSTR_PRETTYFunction · 0.70
llama_sampling_prev_strFunction · 0.70
llama_sampling_sampleFunction · 0.70

Calls 5

llama_get_modelFunction · 0.50
stringFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected