<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Michael Ross</title>
    <description>The latest articles on DEV Community by Michael Ross (@xplaination).</description>
    <link>https://dev.to/xplaination</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3975007%2Fe078722d-8157-496f-866a-b53b7a5b5507.png</url>
      <title>DEV Community: Michael Ross</title>
      <link>https://dev.to/xplaination</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xplaination"/>
    <language>en</language>
    <item>
      <title>Your LLM can't read. Here's the weird trick it uses instead</title>
      <dc:creator>Michael Ross</dc:creator>
      <pubDate>Sat, 13 Jun 2026 01:38:02 +0000</pubDate>
      <link>https://dev.to/xplaination/your-llm-cant-read-heres-the-weird-trick-it-uses-instead-47bi</link>
      <guid>https://dev.to/xplaination/your-llm-cant-read-heres-the-weird-trick-it-uses-instead-47bi</guid>
      <description>&lt;p&gt;Here's a fact that breaks people's mental model of large language models the first time they really sit with it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A language model never sees your words. Not one. It sees numbers — and only numbers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you type &lt;code&gt;Hello, world&lt;/code&gt; into ChatGPT, the model on the other end isn't reading English. By the time your text reaches the neural network, it's been chopped into chunks called &lt;strong&gt;tokens&lt;/strong&gt; and each chunk has been swapped for an integer ID. The model is, underneath all the magic, a very expensive function that maps integers to integers. The "intelligence" is what happens in between.&lt;/p&gt;

&lt;p&gt;Let's actually look at it.&lt;/p&gt;

&lt;h2&gt;
  
  
  See it for yourself (5 lines of Python)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# pip install tiktoken
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tiktoken&lt;/span&gt;

&lt;span class="n"&gt;enc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tiktoken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_encoding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cl100k_base&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# the GPT-4 era tokenizer
&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, world&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                       &lt;span class="c1"&gt;# -&amp;gt; [9906, 11, 1917]
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;  &lt;span class="c1"&gt;# -&amp;gt; ['Hello', ',', ' world']
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three tokens. &lt;code&gt;Hello&lt;/code&gt; is one. The comma is its own token. And &lt;code&gt;world&lt;/code&gt;? It comes through as &lt;code&gt;' world'&lt;/code&gt; — &lt;strong&gt;with the leading space baked in.&lt;/strong&gt; That space is part of the token. This is not a rounding error; it's central to how the whole thing works.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what &lt;em&gt;is&lt;/em&gt; a token?
&lt;/h2&gt;

&lt;p&gt;A token is a frequent chunk of text. Not always a word, not always a letter — whatever the tokenizer found useful while it was trained on a mountain of text. Common words become single tokens. Rare words get shattered into pieces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;playing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tokenization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;antidisestablishmentarianism&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;

&lt;span class="c1"&gt;# playing                      -&amp;gt; ['playing']
# tokenization                 -&amp;gt; ['token', 'ization']
# antidisestablishmentarianism -&amp;gt; ['ant', 'idis', 'establish', 'ment', 'arian', 'ism']
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;playing&lt;/code&gt; is so common it earns a single ID. &lt;code&gt;tokenization&lt;/code&gt; splits into two. The long one gets diced into six. This is &lt;strong&gt;Byte Pair Encoding&lt;/strong&gt; — an intimidating name for a refreshingly simple idea: start with characters, then repeatedly glue together the most common neighboring pair until you've built a vocabulary of ~50k–100k chunks. Frequent stuff ends up whole; rare stuff stays in pieces. Every model ships with its own frozen vocabulary, which is why a token count from one model doesn't transfer to another.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gotcha that costs you money
&lt;/h2&gt;

&lt;p&gt;Here's the part that bites people in production: &lt;strong&gt;you are billed in tokens, and your context window is measured in tokens — not characters, not words.&lt;/strong&gt; And tokens are sneakier than they look.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;123456789&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;   &lt;span class="c1"&gt;# -&amp;gt; 3   (numbers split oddly)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;   &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;          &lt;span class="c1"&gt;# -&amp;gt; 1   (whitespace is real)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;        &lt;span class="c1"&gt;# -&amp;gt; 1
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;       &lt;span class="c1"&gt;# -&amp;gt; 1, but a DIFFERENT id than "hello"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few consequences that trip people up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numbers don't tokenize the way you'd guess.&lt;/strong&gt; A long ID or a big number can eat more tokens than the English sentence around it. If you're stuffing logs, UUIDs, or JSON into a prompt, your token count balloons.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;"hello"&lt;/code&gt; and &lt;code&gt;" hello"&lt;/code&gt; are different tokens.&lt;/strong&gt; Leading spaces matter. This is why few-shot prompt formatting is weirdly fiddly — the model genuinely sees &lt;code&gt;Q:&lt;/code&gt; and &lt;code&gt;Q:&lt;/code&gt; as different starts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your prompt is longer than your intuition says.&lt;/strong&gt; A "short" 280-character message is usually ~70–90 tokens, but throw in code, punctuation, or non-English text and that ratio gets worse fast.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The practical move: &lt;strong&gt;count tokens before you send, not after you get the bill.&lt;/strong&gt; &lt;code&gt;len(enc.encode(prompt))&lt;/code&gt; is the cheapest cost estimate you'll ever write, and it's also how you stop blowing past a context window at the worst possible moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters beyond trivia
&lt;/h2&gt;

&lt;p&gt;Almost every confusing LLM behavior has a tokenization fingerprint on it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Models are weirdly bad at counting letters in a word ("how many r's in strawberry?") — because they never saw the letters, they saw a couple of tokens.&lt;/li&gt;
&lt;li&gt;Non-English languages can cost 2–3× more tokens for the same meaning, because the vocabulary was trained heavy on English.&lt;/li&gt;
&lt;li&gt;Prompt-injection and jailbreak tricks often lean on unusual token boundaries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you can &lt;em&gt;see&lt;/em&gt; the tokens, a lot of "why is the model doing that?" turns into "oh, of course it's doing that."&lt;/p&gt;




&lt;p&gt;This is the first idea in a 10-part plain-English series I've been writing on how LLMs actually work under the hood — embeddings, attention, KV cache, quantization, RAG, the whole stack, no math degree required. If this scratched an itch, the full write-up with diagrams lives here: &lt;strong&gt;&lt;a href="https://xplaination.com/articles/ai-learner-01-tokens-vocabularies-language-numbers" rel="noopener noreferrer"&gt;How Language Becomes Numbers&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now I'm genuinely curious: &lt;strong&gt;what's the weirdest tokenization edge case you've hit in production?&lt;/strong&gt; Emoji that exploded into six tokens, a regex that broke on token boundaries, a non-English prompt that quietly 3×'d your bill? Drop it in the comments — I collect these.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
