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

Function gpt2_bytes_to_unicode

convert.py:175–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173# this has poisoned all HF tokenizer configs that use ByteLevel decoder/preprocessor
174# as a result we get crazy UTF-8-as-bytes-as-UTF8 in the tokenizer data that we need to convert back
175def gpt2_bytes_to_unicode():
176 bs = list(range(ord("!"), ord("~")+1))+list(range(ord("¡"), ord("¬")+1))+list(range(ord("®"), ord("ÿ")+1))
177 cs = bs[:]
178 n = 0
179 for b in range(2**8):
180 if b not in bs:
181 bs.append(b)
182 cs.append(2**8+n)
183 n += 1
184 cs = [chr(n) for n in cs]
185 return dict(zip(bs, cs))
186
187def load_tokens(tokenizer_path, vocab_size):
188 tokens = [""] * vocab_size

Callers 1

load_tokensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected