liveBook · Manning

Logit

As explained in Learn Generative AI with PyTorch

An unnormalized model output score produced before conversion to probabilities for sampling or selection.

A logit is an unnormalized score produced by a model before softmax converts scores into probabilities. In language generation, one logit corresponds to each possible next token. section 8.5.2 section 11.2.4

Logits connect model outputs to token selection in several steps:

  • A recurrent or Transformer model produces one score for every vocabulary token. section 8.5.2 section 11.2.4
  • Softmax converts the scores into a probability distribution used for sampling. section 8.5.2 section 11.2.4
  • Temperature modifies the logits before softmax: lower values favor predictable choices, while higher values increase variation. section 8.5.2
  • Top-K sampling filters the resulting distribution to a selected number of high-probability tokens. section 8.5.2

Sampling the next word

Given the prompt “I'm not going to see,” the model produces logits for candidate continuations. With temperature 1 and no top-K limit, repeated samples vary among several words. With temperature 0.5 and top_k=3, outputs concentrate on choices such as “you,” “the,” and “her.” Raising temperature to 2 produces more unusual continuations and can reduce coherence.

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines logits, places them before softmax, and demonstrates temperature and top-K processing without deriving their mathematics.
Examples
Demonstrates logits through sampled continuations from fixed prompts under unrestricted, top-K, low-temperature, and high-temperature settings.
What it assumes
Assumes familiarity with language-model outputs and token vocabularies while defining the pre-softmax role directly.
What you can do after
Apply logits via PyTorch sampling code by scaling them, converting them with softmax, and selecting or filtering candidate tokens.
How it connects
Connects logits to softmax, temperature sampling, top-K sampling, LSTM outputs, Transformer decoder blocks, and linear output heads.

Also explained in

Compare how 17 books explain logit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.