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

Method resegment

llama.cpp:7166–7189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7164
7165private:
7166 void resegment(llm_symbol & symbol, std::vector<llama_vocab::id> & output) {
7167 auto text = std::string(symbol.text, symbol.n);
7168 auto token = vocab.token_to_id.find(text);
7169
7170 // Do we need to support is_unused?
7171 if (token != vocab.token_to_id.end()) {
7172 output.push_back((*token).second);
7173 return;
7174 }
7175
7176 const auto p = rev_merge.find(text);
7177
7178 if (p == rev_merge.end()) {
7179 // output any symbols that did not form tokens as bytes.
7180 for (int j = 0; j < (int)symbol.n; ++j) {
7181 llama_vocab::id token_id = llama_byte_to_token(vocab, symbol.text[j]);
7182 output.push_back(token_id);
7183 }
7184 return;
7185 }
7186
7187 resegment(symbols[p->second.first], output);
7188 resegment(symbols[p->second.second], output);
7189 }
7190
7191 void try_add_bigram(int left, int right) {
7192 if (left == -1 || right == -1) {

Callers

nothing calls this directly

Calls 5

llama_byte_to_tokenFunction · 0.85
findMethod · 0.80
stringFunction · 0.50
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected