How LLMs Work

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

17 articles

Stop estimating tokens

Listed inTokensHow LLMs Workon

Why character and word counts are wrong by enough to matter, how BPE actually splits your text, and how to budget a request so the model never gets 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 · docs.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

Top-K

Listed inTop-KHow LLMs Workon

Restricting the candidate pool to the k most likely tokens, and how it interacts with top-p.

Intermediate4 minDraft
#sampling

Temperature

Listed inTemperatureHow LLMs Workon

The randomness dial: what it does to the distribution, and sane defaults per task.

Beginner4 minDraft
#sampling

Top-P

Listed inTop-PHow LLMs Workon

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

Intermediate4 minDraft
#sampling