Inside the Machine

What the Tokenizer and Post-Training Really Do To Your Output

Almost every reproducible model quirk comes from one of three layers. Knowing which one tells you whether to fix the prompt, the pipeline, or the model choice.

A useful model of an LLM at this tier is not next-token prediction. It is three stacked layers: a tokenizer that does not see the text you see, an attention mechanism whose cost and accuracy depend on position, and a post-training process that bent a text-imitator into an assistant with a personality and a set of reflexes. Nearly every reproducible quirk comes from one of those three. Identifying which one is the difference between fixing a bug and rewording a prompt for a week.

The tokenizer layer

Byte-pair encoding merges frequent character sequences into single tokens. English prose lands near four characters per token, roughly three-quarters of a word. Scripts the tokenizer saw less of fare far worse: Japanese, Thai, Hindi and Arabic commonly cost two to four times as many tokens for the same meaning, so a non-English product pays a hidden multiple on every single call. Long numbers are chopped into digit groups whose boundaries shift depending on where the number starts, which is the actual mechanism behind arithmetic errors that survive otherwise careful prompting.

  • Character-level tasks (count the letters, reverse this string, strict rhyme, exact truncation) fight the tokenizer. Move them to code, not to a better prompt.
  • Arithmetic on long figures is a tokenization artefact, not an intelligence limit. Hand the model a calculator tool and stop negotiating with it.
  • Trailing whitespace, smart quotes and unusual Unicode change tokenization and can measurably shift output. Normalize input before it reaches the model.
  • Your cost and context unit is tokens, not characters or words. Count with the vendor's own tokenizer; word-count estimates are wrong by enough to blow a budget.

~4 chars

one English token — the same meaning in Thai or Japanese can cost two to four times more tokens, and you pay for every one

The attention layer: context is not free

Standard attention compares every token with every other token, so compute grows with the square of sequence length. Vendors hide that behind flat per-token pricing, but you feel it as latency: time-to-first-token rises faster than linearly as the prompt grows. The second effect is positional. Retrieval accuracy sags for material buried in the middle of a long prompt — a finding that has replicated across models and years. Put the instruction and the load-bearing evidence near the start and the end. Never assume that because something is inside the window it is being used.

Post-training is where the personality came from

  1. Pretrainingimitate a vast corpus — raw capability, no manners
  2. Supervised fine-tuningcurated demonstrations teach the assistant format
  3. Preference optimisationrated against a reward model — this is where the reflexes come from

That third stage explains the behaviours people mistake for stupidity. Human raters preferred answers that were agreeable, confident, well-formatted and longer, so the reward model learned to prefer them too. Out comes sycophancy, hedging, headers and bullets where none were asked for, a bias toward length, and refusal edges that fire on harmless requests near a trained boundary. These are optimisation artefacts, not capability limits, and they respond to different fixes than a knowledge gap does.

Order your output fields by what you want the model to commit to last. Ask for the verdict first and the reasoning after, and the reasoning is a justification of a token already emitted — the model cannot retract it. Ask for the analysis first and the verdict last, and the verdict is conditioned on the analysis. Same prompt content, materially different accuracy, and it costs nothing to switch.

Sampling: what you actually control

Temperature flattens or sharpens the distribution; top-p truncates its tail. Where the vendor exposes log probabilities you get a usable confidence proxy for routing and abstention. What you do not get is determinism: at temperature zero, batching, floating-point reduction order and mixture-of-experts routing all make identical requests diverge occasionally. That is a property of the serving stack, not a setting you can turn off.

Any test that asserts exact string equality on model output will flake, and the flake will be blamed on the test. Assert on schema validity and on properties — this field parses as a date, this number falls in range, this claim appears in the cited source. Teams that learn this late end up distrusting their own test suite.

What is solid and what is not

Well-established: tokenization effects, quadratic attention cost, positional degradation in long contexts, and the general direction of preference-training artefacts. Genuinely contested: how much explicit reasoning tokens help. They measurably improve multi-step maths and planning, and they often do nothing on retrieval-shaped tasks while billing as output tokens. Treat extended thinking as a per-task empirical question with a price tag, not as a quality setting you leave on.

Key takeaways

1Letter-level and long-number tasks are tokenizer problems — give the model a tool instead of a better prompt
2Being inside the context window is not the same as being used; position changes retrieval accuracy
3Sycophancy, hedging and over-formatting are preference-training artefacts, and output field order is a free lever against them
4Temperature zero gives low variance, not determinism — assert on schemas and properties, never exact strings

This is one lesson of 541.

The whole Foundation is free — 16 subjects, beginner to advanced. Sign in to track what you have read, take the end-of-module quizzes, and use the terminal.