liveBook · Manning

Hyperparameter tuning

As explained in LLMs in Production

Hyperparameter tuning is the process of selecting values for training or model-configuration choices that are not learned as model parameters.

Hyperparameter tuning selects training or generation settings that are not learned as model parameters. For large language models, changing data quality often delivers more value than searching these settings. section 5.4.4 section 7.2.2

Use tuning selectively and match the setting to the job:

  • Use Optuna when a small metric improvement matters and the dataset cannot change soon. section 5.4.4
  • Improve the dataset, represent the target metric more completely, or try oversampling before investing heavily in tuning. section 5.4.4
  • For generation, adjust temperature and beam count only when the queried API endpoint accepts those parameters. section 7.2.2
  • Prefer low or zero temperature for repeatable outputs; higher temperature increases response creativity but can reduce predictability. section 7.2.2

Temperature changes token selection

Given “I am a,” the model produces logits, converts them to probabilities with softmax, and applies temperature during that conversion. Zero temperature uses the highest-logit token for consistent output; higher values flatten the distribution. section 7.2.2

Figure 7.3 A simple path of how the next word is chosen. Given an input, a model will generate a vector of logits for each token in the model’s vocabulary. Using the softmax algorithm, these logits will be transformed into probabilities. These probabilities will correspond to how often that token is likely to be chosen. Temperature is applied during the softmax algorithm.
figure

Follow the next-token path from logits through softmax probabilities to temperature-controlled selection. section 7.2.2

How LLMs in Production covers it

How deep it goes
Defines temperature through logits and softmax, but treats broad LLM tuning briefly and defers deeper optimization to data and model changes.
Examples
Uses Optuna, the prompt “I am a,” temperature settings, logits, softmax probabilities, and beam search as teaching examples.
What it assumes
Assumes basic model training and token generation concepts while explaining logits, softmax, and temperature directly.
What you can do after
Apply it via Optuna for training searches or configure temperature and beam settings through a compatible LLM API endpoint.
How it connects
Connects hyperparameter tuning with data quality, oversampling, quantization, logits, softmax, and beam search.

Also explained in

Compare how 18 books explain hyperparameter tuning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.