Text Generation Strategies
Text generation is the step where the model produces output one piece at a time, and the weights are part of the calculation that decides what comes next.
The Question Behind Every Word
When a large language model writes a sentence, it is not looking up a stored answer. It computes a next word from the input it receives and from a large collection of numbers built into the model. Those numbers are the subject of this article.
What do you think happens?
If the model's behavior depends on these built-in numbers, who or what decides what the numbers should be?
Reveal answer
The numbers are learned during training.
The source frames them as values the model learns, rather than values a person enters. The rest of this article follows that idea from its definition, to its role in text generation, to the steps that come after it in building an LLM.
What a Weight Parameter Is
A weight parameter is a model parameter that is learned during training, not typed in by hand.
The key word is learned. A value a programmer types into code is chosen by the person writing the program, and it stays that way unless someone edits the code. A weight parameter starts with some value and then changes as the model is trained. Its final value is the product of training rather than a decision made in advance by the author.
| Feature | Value typed in by hand | Weight parameter |
|---|---|---|
| Where it comes from | A person writes it into the code | Produced by the training process |
| Who sets its value | The programmer | Training, rather than a hand-typed choice |
| Does it change over time | Only if someone edits the code | Its value changes as training runs |
| Role in the model | Fixed input chosen by the author | Part of the calculation that the model uses to produce text |
A hand-typed value compared with a learned weight parameter
Tracing One Weight Through Training
To make the idea concrete, follow a single weight from before training to after training. The source does not give specific values for any real model, so the numbers below are invented for illustration. What matters is the direction of change: the value moves, and it eventually settles.
Following one weight from start to finish
A weight starts at 0.20 before training. After training, it is 0.58. What changed, and what stayed the same?
- 1Identify the starting state
Before training, the weight holds an initial value of 0.20 (illustrative).
- 2Identify the ending state
After training, the weight holds a learned value of 0.58 (illustrative).
- 3Compare the two
The value moved upward during training. The weight is still the same weight with the same role in the model. Only its value changed.
- 4Generalize
A model contains a very large number of weights, and each one begins with some value and ends training with a learned value.
The weight's identity and role stayed fixed while its value was learned. The learned values are what carry the model's ability forward.
Why Weights Drive Text Generation
The source states that weight parameters are used in LLMs for text generation. This is why they matter to the chapter. Text generation is the step where the model produces output one piece at a time, and the weights are part of the calculation that decides what comes next.
This connects training to output. Training determines the learned values, and generation uses those values to compute each next word. A model whose weights were learned differently would compute different next words from the same input.
A model does not store a finished answer to retrieve. Each word is computed from the input and from the learned numbers inside the model.
Where Weights Sit in the Chapter Workflow
The chapter follows a sequence of stages. It begins by recapping text generation from the previous chapter, then sets up the LLM for text generation and discusses basic ways to evaluate the quality of the text it produces. Evaluation is where the learned weights are tested: if the weights are good, the generated text should be judged well. Evaluation and training both depend on a model whose weights are already defined.
Read this overview as a map rather than a checklist. The first three stages prepare you to judge a model. The middle stages train and improve it. The last stages handle the weights as stored, reusable values. Weight parameters are the common thread through all of them.
Saving and Loading Learned Weights
Because weights are learned, they are valuable. Training takes effort, and the learned values are the result of that effort. The source describes implementing functions to save and load LLM weights. Saving captures the current state of the weights. Loading brings a saved state back into a model, so the model can be used again or have its training continued.
The source also describes loading pretrained weights from OpenAI into the LLM model. This is a different route to learned weights. Instead of learning them within this chapter's own training run, the model receives weights that were already learned elsewhere.
Mistakes Beginners Make with Weights
Common mistake Treating a weight like a setting you type in
What it looks likeAssuming you can choose a weight's final value in the code and the model will use it.
Why it failsA weight parameter is learned during training, not typed in by hand.
Do this insteadThink of the weight as a value that training produces, and check the training process to see where its value comes from.
Common mistake Thinking the model looks up a stored answer
What it looks likeBelieving a sentence is retrieved whole from storage.
Why it failsThe model computes a next word from the input and from the numbers built into it.
Do this insteadConnect each generated word to the input and the learned weights used in that calculation.
Common mistake Assuming saving a model means saving its design only
What it looks likeThinking the model can be reused just because its structure was written down.
Why it failsThe learned values are the result of training effort, and saving captures the current state of the weights.
Do this insteadRemember that saving stores the weights, and loading restores them into a model.
Common mistake Confusing pretrained weights from OpenAI with weights learned in this chapter's own training run
Practice: Tracing a Learned Value
A model has a weight whose value is 0.20 before training and 0.58 after training. Explain, in your own words, why this weight is called a learned weight parameter and not a value a programmer typed in. Then describe what stayed the same about the weight during training.
Hints
- Ask who or what set the final value.
- Look at what the source says about whether the weight is still the same weight after training.
- Think about the difference between changing a value and changing what the weight does in the model.
Key Takeaways
- 1A weight parameter is a model parameter that is learned during training, not typed in by hand.
- 2Training changes a weight's value while the weight remains the same weight with the same role in the model.
- 3Weights are used in LLMs for text generation, linking what training learned to the output the model produces.
- 4Weights appear across the chapter's stages, and saving and loading them lets a model be reused or trained further.
- 5Pretrained weights from OpenAI are another source of learned weights, received instead of learned in the chapter's own training run.
At a glance
- A weight parameter is a model parameter that is learned during training, not typed in by hand.
- Training changes a weight's value while the weight remains the same weight with the same role in the model.
- Weights are used in LLMs for text generation, linking what training learned to the output the model produces.
- Saving and loading weights lets a model be used later or have its training continued.
- Pretrained weights from OpenAI are another source of learned weights, received instead of learned in the chapter's own training run.