How LLMs Work

The mechanics under the API: tokens, context windows, sampling, and the knobs that actually change output.

Sign in to track your progress across sections.

17 articles

Stop estimating tokens

Listed inTokensHow LLMs Workon

Character and word counts disagree with real token counts, which is a problem because every limit you hit is counted in tokens. How byte pair encoding splits text, and how to budget a request so a response is not cut off mid-sentence.

Beginner6 min
#fundamentals
#cost

Prompt caching

Listed inPrompt CachingHow LLMs Workon

How cache breakpoints work, what invalidates a prefix, and the latency and cost numbers to expect.

External
Anthropic · platform.claude.com
#cost
#latency

Tokens

Listed inTokensHow LLMs Workon

The unit models actually read and bill for, and why character counts mislead you.

Beginner5 minDraft
#fundamentals
#cost

Fine-tuning

Listed inFine-tuningHow LLMs Workon

The documented benefits are about behavior and format rather than knowledge. Fine-tuning shapes how a model responds; retrieval is what gives it facts it did not train on.

Advanced4 min
#llm-internals

Pre-trained Models

Listed inPre-trained ModelsHow LLMs Workon

There are two cutoff dates, not one, and the gap between them is where a model is most confidently wrong. Plus which symptom each stage explains.

Beginner7 min
#fundamentals

Top-K

Listed inTop-KHow LLMs Workon

A fixed count applied to a distribution whose shape keeps changing. OpenAI never exposed it and Anthropic now returns a 400 for it.

Intermediate5 min
#sampling

Top-P

Listed inTop-PHow LLMs Workon

Nucleus sampling — trimming the tail by probability mass instead of by rank.

Intermediate4 minDraft
#sampling