Argmax
An operation that returns the argument, often an index, at which a function or collection attains its maximum value.
LLMs in Production
Argmax is the operation that returns the position of the maximum value in a set or vector.
- How it is used
- Uses argmax as a next-token selection option during language-model generation.
- How deep it goes
- Explains highest-logit selection and its role in temperature handling, without detailing the algorithm's implementation.
- Examples
- Uses the prompt “I am a” to illustrate token logits and probabilities, and contrasts argmax with multinomial sampling.
- What you can do after
- Apply argmax to select the highest-logit token as the next token instead of sampling among alternatives.
Learn Generative AI with PyTorch
- How it is used
- Turns multicategory model outputs into predicted class labels for clothing images.
- How deep it goes
- Shows the returned maximum position in prediction code, without developing argmax beyond this classification use.
- Examples
- Uses ten clothing classes and five test images whose predicted numerical labels match the actual labels.
- What you can do after
- Apply via PyTorch to convert batch class scores into predicted labels and compare them with targets.
Also covered in
- DuckDB in Action
- Build a Reasoning Model (From Scratch)
- Build a DeepSeek Model (From Scratch)In early access (MEAP)
- Deep Learning with R, Third Edition
What to know first
- language modelA language model is a computational model of linguistic sequences that estimates their probabilities or predicts tokens from context, enabling it to generate or evaluate language.
- softmaxSoftmax is a function that exponentiates each value in a score vector and normalizes the results to produce positive values summing to one, forming a probability distribution.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- vocabularyA vocabulary is the finite set of distinct tokens a language-processing system can represent, often associated with identifiers.
Related concepts
- greedy algorithmequivalent to · A greedy algorithm constructs a solution incrementally by choosing the locally best available option at each step, generally without reconsidering earlier choices or optimizing the entire sequence globally.
- top-k samplingequivalent to · Top-k sampling is a decoding technique that restricts each next-token selection to the k candidates with the highest probabilities, then samples from those candidates.
- generationused by · Generation is the production of an output by a computational model from supplied input or context, often using patterns learned from data.
- best-of-Nused by · Best-of-N is a technique that generates or evaluates multiple candidates and selects one according to a scoring or quality criterion.
Questions about argmax
What is argmax?
An operation that returns the argument, often an index, at which a function or collection attains its maximum value.
Which Manning books explain argmax?
LLMs in Production and Learn Generative AI with PyTorch.
What should I know before learning argmax?
Manning books that teach argmax usually introduce language model, softmax, array and vocabulary first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

