MCPcopy
hub / github.com/karpathy/nanochat / encode

Method encode

tests/test_engine.py:73–77  ·  view source on GitHub ↗
(self, s, prepend=None)

Source from the content-addressed store, hash-verified

71 return self._bos
72
73 def encode(self, s, prepend=None):
74 tokens = list(s.encode("utf-8")) # bytes 0-255
75 if prepend is not None:
76 tokens = [prepend] + tokens
77 return tokens
78
79 def decode(self, tokens):
80 # Filter out special tokens before decoding

Callers 6

tok_train.pyFile · 0.45
run_categorical_evalFunction · 0.45
get_hf_token_bytesFunction · 0.45
chat_completionsFunction · 0.45
tok_eval.pyFile · 0.45
chat_cli.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected