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

Function convert_token_to_string

smallthinker/tools/run/run.cpp:969–979  ·  view source on GitHub ↗

convert the token to a string

Source from the content-addressed store, hash-verified

967
968// convert the token to a string
969static int convert_token_to_string(const llama_vocab * vocab, const llama_token token_id, std::string & piece) {
970 char buf[256];
971 int n = llama_token_to_piece(vocab, token_id, buf, sizeof(buf), 0, true);
972 if (n < 0) {
973 printe("failed to convert token to piece\n");
974 return 1;
975 }
976
977 piece = std::string(buf, n);
978 return 0;
979}
980
981static void print_word_and_concatenate_to_response(const std::string & piece, std::string & response) {
982 printf("%s", piece.c_str());

Callers 1

generateFunction · 0.85

Calls 3

printeFunction · 0.85
llama_token_to_pieceFunction · 0.50
stringClass · 0.50

Tested by

no test coverage detected