MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / decode_gpt2_bpe

Function decode_gpt2_bpe

server/src/server/tokenizer.cpp:722–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

720}
721
722static std::string decode_gpt2_bpe(const std::string & tok) {
723 std::string out;
724 out.reserve(tok.size());
725 const char * p = tok.c_str();
726 const char * end = p + tok.size();
727 while (p < end) {
728 int cplen;
729 uint32_t cp = utf8_decode(p, (size_t)(end - p), &cplen);
730 out.push_back((char)gpt2_unicode_to_byte(cp));
731 p += cplen;
732 }
733 return out;
734}
735
736std::string Tokenizer::token_text(int32_t id) const {
737 if (id < 0 || id >= (int32_t)id_to_token_.size()) return "";

Callers 1

token_textMethod · 0.85

Calls 3

utf8_decodeFunction · 0.85
gpt2_unicode_to_byteFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected