Claude Token Counter, now with model comparisons
simonwillison.net
Claude Token Counter, now with model comparisons
1–10 of 93 posts
Re: Claude Token Counter, now with model comparisons
#2Re: Claude Token Counter, now with model comparisons
#3Interesting findings. Might need a way to downsample images on upload to keep costs down.
Re: Claude Token Counter, now with model comparisons
#4Re: Claude Token Counter, now with model comparisons
#5Why do you need an API key to tokenize the text? Isn't it supposed to be a cheap step that everything else in the model relies on?
Re: Claude Token Counter, now with model comparisons
#6Is there a quality increase from this change or is it a money grab ?
Re: Claude Token Counter, now with model comparisons
#7Interesting. Unfortunately Anthropic doesn't actually share their tokenizer, but my educated guess is that they might have made the tokenizer more semantically aware to make the model perform better. What do I mean by that? Let me give you an example. (This isn't necessarily what they did exactly; just illustrating the idea.)
Let's take the gpt-oss-120b tokenizer as an example. Here's how a few pieces of text tokenize (I use "|" here to separate tokens):
Kill -> [70074]
Killed -> [192794]
kill -> [25752]
k|illed -> [74, 7905]
kill -> [15874]
killed -> [17372]
You have 3 different tokens which encode the same word (Kill, kill, kill) depending on its capitalization and whether there's a space before it or not, you have separate tokens if it's the past tense, etc.This is not necessarily an ideal way of encoding text, because the model must learn by brute force that these tokens are, indeed, related. Now, imagine if you'd encode these like this:
|kill
|kill|ed
kill|
kill|ed
|kill
|kill|ed
Notice that this makes much more sense now - the model now only has to learn what "" is, what "kill" is, what "" is, and what "ed" (the past tense suffix) is, and it can compose those together. The downside is that it increases the token usage.So I wouldn't be surprised if this is what they did. Or, my guess number #2, they removed the tokenizer altogether and replaced them with a small trained model (something like the Byte Latent Transformer) and simply "emulate" the token counts.
Re: Claude Token Counter, now with model comparisons
#8Why do you need an API key to tokenize the text? Isn't it supposed to be a cheap step that everything else in the model relies on?
Note that they're the only provider which doesn't make their tokenizer available offline as a library (i.e. the only provider whose tokenizer is secret).
Re: Claude Token Counter, now with model comparisons
#9Re: Claude Token Counter, now with model comparisons
#10Is there any provided reason from anthropic why they changed the tokenizer ? Is there a quality increase from this change or is it a money grab ?
Comparisons are still ongoing but I have already seen some that suggest that Opus 4.7 might on average arrive at the answer with fewer tokens spent, even with the additional tokenizer overhead.
So, no, not a money grab.