liveBook · Manning

Argmax

Argmax is an operation that identifies an argument, position, or index at which a function or collection attains its maximum value.

How 2 Manning books explain it

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.

Read how LLMs in Production explains argmax →

Learn Generative AI with PyTorch

How it is used
Selects a predicted clothing class from the model’s ten-value output by returning the position of its highest probability.
How deep it goes
Explains that argmax returns the highest-probability position and demonstrates dim=1 on model outputs.
Examples
Demonstrates predictions for five clothing images, comparing class indices with actual labels.
What you can do after
Apply it with torch.argmax(preds, dim=1) to turn batches of model outputs into class indices and compare them with labels.

Read how Learn Generative AI with PyTorch explains argmax →

Related concepts

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.