MCPcopy Create free account
hub / github.com/M4THYOU/TokenDagger / encode_ordinary

Method encode_ordinary

src/tiktoken/tiktoken.cpp:156–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154 }
155
156 std::vector<int> CoreBPE::encode_ordinary(const std::string& text) const {
157 std::vector<int> result;
158 // Split text using regex
159 auto pieces = split_text(text, 0, text.length());
160 for (const auto& piece : pieces) {
161 std::vector<unsigned char> bytes(piece.begin(), piece.end());
162 // TODO: check if the bytes exist in the encoder, direct lookup before falling back to BPE.
163 byte_pair_encode(bytes, encoder, result);
164 }
165
166 return result;
167 }
168
169 std::pair<std::vector<int>, int> CoreBPE::encode(const std::string& text, const emhash8::HashSet<std::string>& allowed_special) {
170 std::vector<int> result;

Callers 2

encodeMethod · 0.45
PYBIND11_MODULEFunction · 0.45

Calls 3

byte_pair_encodeFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected