MCPcopy Create free account
hub / github.com/andrewkchan/deepseek.cpp / decode_one

Method decode_one

src/tokenizer.cpp:44–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44std::string Tokenizer::decode_one(int prev_token, int token) const {
45 const std::string& piece = vocab[token];
46 // if following BOS token, sentencepiece decoder strips any leading whitespace
47 if (prev_token == bos_id && piece[0] == ' ') {
48 return piece.substr(1);
49 }
50 // return byte piece for byte fallback tokens (<0x00>, <0x01>, ..., <0xFF>)
51 if (byte_fallback_start >= 0 && token >= byte_fallback_start && (token - byte_fallback_start) < 256) {
52 return byte_pieces[token - byte_fallback_start];
53 }
54 return piece;
55}
56
57std::vector<int> Tokenizer::encode(const std::string& text, bool encode_bos) const {
58 std::vector<int> out_tokens;

Callers 2

run_completionFunction · 0.80
run_passkeyFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected