liveBook · Manning

Temperature

As explained in Build a Large Language Model (From Scratch)

A decoding method that rescales next-token probabilities with a temperature to make sampling more or less random.

Temperature sampling changes next-token randomness by dividing logits by a temperature, converting them to probabilities, and sampling the next token. section 5.3.3

A higher-temperature generation

Using temperature=1.4 and top_k=25 produces a varied continuation: “Every effort moves you stand to work on surprise, a one of us had gone with random-”.

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Implements logit scaling, softmax conversion, and multinomial sampling, while deferring systematic setting combinations to exercises.
Examples
Demonstrates a 15-token continuation using temperature 1.4 and top-k 25, contrasting it with a memorized passage.
What it assumes
Assumes a model producing next-token logits and a tokenized prompt passed into the generation function.
What you can do after
Apply it via a modified generate function and compare outputs across temperature and top-k settings.
How it connects
Connects logits, softmax, multinomial sampling, top-k sampling, and autoregressive text generation.

Also explained in

Compare how 17 books explain temperature →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.