What tokenizers did Andrej Karpathy recommend using?
Andrej Karpathy recommends reusing GPT-4 tokens and vocabulary if your application can do that, because the system is efficient and well-tested. If you need to train a vocabulary from scratch, he suggests BPE with SentencePiece, while noting that he is not enthusiastic about its byte fallback or many configuration settings. He also says byte-level BPE from TikTok and OpenAI is something he likes.
“That's something you should consider and just use the Tech token because it is a very efficient and nice library for inference for BPE. I also really like the byte-level BPE that TikTok and OpenAI use. If, for some reason, you want to train your own vocabulary from scratch, then I would use the BPE with SentencePiece. Oops, as I mentioned, I'm not a huge fan of SentencePiece. I don't like its byte fallback, and I don't like that it's doing BPE on Unicode code points. I think it also has like a million settings, and I think there's a lot of footguns here, and I think it's really easy to miscalibrate them and you end up cropping your sentences or something like that because of some type of parameter that you don't fully understand.”

Key takeaways
- Reuse a proven tokenizer and vocabulary when possible.
- Be cautious with SentencePiece settings and byte fallback.
- Prefer simple, well-understood tokenizer implementations if you can.
Context
In the closing recommendations of his 2019 tokenization talk, Karpathy compares practical tokenizer choices for application builders. The quote above is taken word for word from the recording's transcript.
In the transcript
…So, it's worth understanding this stage. That said, I will say that eternal glory goes to anyone who can get rid of it. I showed you one possible paper that tried to do that, and I think, I hope a lot more can follow over time. And my final recommendations for the application right now are if you can reuse the GPT-4 tokens and the vocabulary in your application, then
That's something you should consider and just use the Tech token because it is a very efficient and nice library for inference for BPE. I also really like the byte-level BPE that TikTok and OpenAI use. If, for some reason, you want to train your own vocabulary from scratch, then I would use the BPE with SentencePiece. Oops, as I mentioned, I'm not a huge fan of SentencePiece. I don't like its byte fallback, and I don't like that it's doing BPE on Unicode code points. I think it also has like a million settings, and I think there's a lot of footguns here, and I think it's really easy to miscalibrate them and you end up cropping your sentences or something like that because of some type of parameter that you don't fully understand.
The settings, try to copy-paste exactly maybe where, what Meta did, or basically spend a lot of time looking at all the hyperparameters and go through the code of SentencePiece and make sure that you have this correct. Um, but even if you have all the settings correct, I still think that the algorithm is kind of inferior to what's happening here. And maybe the best, if you really need…
Topics
More questions about Andrej Karpathy
- What did Andrej Karpathy say about JSON versus YAML token efficiency?
- What did Andrej Karpathy say about why tokenization causes strange LLM behavior?
- What did Andrej Karpathy say about the risks of tokenization?
- What did Andrej Karpathy say about scaling laws in large language models?
- How does Andrej Karpathy decide when to use reasoning models, search, or tools with LLMs?
- What does Andrej Karpathy mean by the 'cognitive core' in LLMs?
All Andrej Karpathy answers · All Andrej Karpathy recordings
How this answer was made: the quote is checked word for word against the transcript of the recording and confirmed as the speaker's own words; the summary above it was drafted with AI from that transcript and quality-checked. Methodology and corrections.