Compute stable softmax, derive cross-entropy gradients, and test confidence.
Preparation: Fractions and exponentials; derivatives for the college path.
Plan 20–35 minutes with the activities; this is a study estimate, not a timed requirement. Both paths have complete narration. Your notes and progress are kept separately for each level.
FULL LOCAL NARRATION
Follow the complete explanation.
Narration includes worked solutions. Pause at each practice prompt before continuing. Formula notation has a spoken explanation; all teaching text remains readable.
High-school path. Compute stable softmax, derive cross-entropy gradients, and test confidence.
Preparation: Fractions and exponentials; derivatives for the college path. Work through one section at a time. Predict the experiment result before changing its controls, then explain what the example leaves out.
Scores two, one and zero are not probabilities. They need not add to one or even be positive. Softmax turns each score into a positive weight using an exponential, then divides by the total. This creates shares of one whole. A larger score gets a larger share, but every finite score receives some share. Watch both the raw scores and the resulting probabilities: they answer different questions.
Worked step 1. Exponentiate [2,1,0] to approximately [7.389,2.718,1].
Worked step 2. Their sum is 11.107.
Worked step 3. Divide to obtain [0.6652,0.2447,0.0900].
pᵢ = exp(zᵢ) / Σⱼ exp(zⱼ)
Probability i is the exponential of score i divided by the sum of all exponential scores.
Try it yourself. Why not just divide the raw scores by their sum?
Pause the recording and write your reasoning before continuing. The worked solution follows.
Reveal worked solution
Worked solution. That is a different mapping and can produce invalid negative probabilities for other scores. Exponentials provide positive weights.
Section 02 / 07
Shift large scores safely
Computers cannot store arbitrarily large exponentials. Subtracting the largest score first avoids that problem. Scores 1002, 1001 and 1000 become zero, minus one and minus two. Their gaps are unchanged, so the probability shares stay the same. This is a safe change in the common starting point, not a change to the model's relative preferences. Workbench lets you test a large shared offset.
Worked step 1. Shift [2,1,0] to [0,-1,-2].
Worked step 2. The positive weights become [1,0.3679,0.1353].
Worked step 3. Normalize by 1.5032 to recover the same probabilities.
log pᵢ = zᵢ − m − log Σⱼ exp(zⱼ − m)
Log probability is the shifted score minus the log of the shifted exponential sum.
Try it yourself. What should adding one hundred to every score do?
Pause the recording and write your reasoning before continuing. The worked solution follows.
Reveal worked solution
Worked solution. Nothing to the exact probabilities. Small floating-point differences are possible, but a large change indicates a bug.
Section 03 / 07
Measure target surprise
Choose the correct target. If it is the first token, the model gave it probability about 0.665. Its loss is minus the natural logarithm of that probability, about 0.408. If the third token is correct, loss is about 2.408. Loss therefore measures more than whether the top guess was right. It penalizes assigning very little probability to the actual target.
Worked step 1. First target: −log(0.6652) ≈ 0.4076.
Worked step 2. Third target: −log(0.0900) ≈ 2.4076.
Worked step 3. A lower target probability causes a larger loss.
L = −log p_target
The loss is minus the natural logarithm of the target probability.
Try it yourself. What is the loss when the correct target has probability one half?
Pause the recording and write your reasoning before continuing. The worked solution follows.
Reveal worked solution
Worked solution. Approximately 0.6931 nats. A base-two logarithm would use bits instead; this lesson uses natural logarithms.
Section 04 / 07
Follow the chain rule
Nudge the correct score upward and its probability rises, so its loss falls. Nudge a competing score upward and it takes some share away. A gradient measures that local sensitivity. With the first target, the three score gradients are about minus 0.335, plus 0.245 and plus 0.090. Gradient descent moves against those signs. The values are not independent because all three probabilities share one total.
Worked step 1. Subtract [1,0,0] from the probability vector.
Worked step 2. Obtain about [−0.3348,0.2447,0.0900].
Worked step 3. The three components sum to zero up to rounding.
∂L/∂zᵢ = (pᵢ − yᵢ)/T
For logits divided by temperature, subtract the target indicator from the probability and divide by temperature.
Try it yourself. Why is −1/p_target not the complete logit gradient?
Pause the recording and write your reasoning before continuing. The worked solution follows.
Reveal worked solution
Worked solution. It differentiates the loss with respect to target probability. The normalization and its chain rule still connect that probability to every logit.
Section 05 / 07
Temperature is not truth
A high temperature divides scores more strongly and spreads the shares more evenly. A low positive temperature concentrates them around the largest score. It does not verify that score's answer. Compare temperatures one half, one and two. Predict which probability will rise before moving the slider. Then consider a case where the top-ranked token is wrong: sharper confidence can make that mistake more costly.
Worked step 1. At temperature one, the leading probability is about 0.6652.
Worked step 2. At temperature two it is about 0.5065.
Worked step 3. The top-ranked class stays the same.
Try it yourself. Does sharpening the distribution establish that its top answer is correct?
Pause the recording and write your reasoning before continuing. The worked solution follows.
Reveal worked solution
Worked solution. No. Confidence and correctness are different. Labels or evidence are required to assess correctness.
Section 06 / 07
Check the derivative two ways
First calculate probability minus target. Then change one score by a tiny amount and observe the loss. A small loss change divided by a small score change estimates sensitivity. Try both a positive and negative change so the estimate is centered. If the step becomes too tiny, rounding can hide the difference. This is a useful habit: compare a formula with a controlled numerical experiment.
Worked step 1. Hold target and other scores fixed.
Worked step 2. Evaluate the loss at first score plus and minus 0.001.
Worked step 3. Divide the difference by 0.002 and compare with the analytic gradient.
gᵢ ≈ [L(z+h eᵢ) − L(z−h eᵢ)] / (2h)
Subtract the two perturbed losses and divide by twice the perturbation.
Try it yourself. What could cause a failed gradient check when probabilities still sum to one?
Pause the recording and write your reasoning before continuing. The worked solution follows.
Reveal worked solution
Worked solution. Wrong target indexing, a missing temperature factor, batch averaging, or confusion between derivatives of logits and probabilities.
Section 07 / 07
Mastery and transfer
Bring the pieces together. First answer the checkpoint without the worked solutions. Then explain the mechanism in your own words, using one numerical example from this lesson.
Lower temperature guarantees… Option 1: More truthful answers. Option 2: More concentrated shares for unequal fixed scores. Option 3: Equal shares.
Pause here and choose an answer before continuing. The checkpoint explanation follows.
Reveal worked solution
The correct choice is option 2: More concentrated shares for unequal fixed scores. It changes concentration, not truth.
Transfer task. Change one assumption in the worked example. State your prediction, calculate or test it in Workbench, then explain whether the result supports your prediction.
Reveal worked solution
Self-check rubric. Name the changed assumption, keep the other inputs fixed, show at least one intermediate calculation, and distinguish what the toy example guarantees from what would require a trained model or a real measurement.
WORKBENCH / PREDICT → TEST → EXPLAIN
Inspect exact numerical data
These are computed teaching fixtures. No remote AI model or GPU is called by the experiment.
CHECK YOUR UNDERSTANDING
Commit to an explanation.
Keep your learning record.
MODERN MODEL CASE STUDY
DeepSeek V4.1 Flash: where this idea goes next
See how CSA2 separates cache reuse from index reuse. Follow the worked examples, then evaluate the reported gains and their limits.
Original worked examples and teaching text, grounded in these primary references. Numerical fixtures explain mechanisms; model quality and hardware performance require separate measurements. Both levels share key examples, with different explanations and checkpoints.
What a model learns: from numbers to a useful answer
Follow a sentence through learned weights, temporary activations, and the next-token decision.
Additional reading · original lesson audio remains unchanged.
Read the full explanation · 586 words
What changes when you ask a question?
23input x
×
0.6−0.2learned weights
+
0.1bias
=
0.7output y
The weights stay fixed during ordinary inference. Activations change with your input.
Text → tokens
Tokens → vectors
Learned transformations
Next-token scores
Text → tokens
A model is a computation with learned settings
A language model does not contain a little librarian choosing a finished answer from a shelf. It contains a structured computation whose numerical settings were learned during training. Those settings are called parameters. Many are weights arranged in matrices; other parameters can include offsets or normalization scales. The architecture determines which operations happen and how information travels. The weights determine the particular transformations performed by those operations. Two models can share an architecture and behave differently because they learned different parameter values.
Consider a tiny operation: y = 0.6x₁ − 0.2x₂ + 0.1. With inputs x₁ = 2 and x₂ = 3, the output is 0.7. Changing the first weight from 0.6 to 0.5 changes the output to 0.5. This is a teaching example, not a miniature intelligent system. Its purpose is to make one idea visible: numerical settings influence the result. In a language model, many such transformations act together across large vectors, nonlinear functions, and layers.
Follow the sentence
First, a tokenizer turns text into a sequence of token identifiers. A token may represent a word, part of a word, punctuation, or another unit. An embedding table supplies a learned vector for each identifier. These vectors are starting representations, not complete dictionary definitions. As they pass through the network, surrounding tokens influence how the current sequence is represented.
In attention, learned projections produce queries, keys, and values. The model compares queries with keys to calculate input-dependent attention scores, then combines value representations. This distinction matters: the projection weights normally remain fixed during a conversation, while the attention scores change with the input. Feed-forward transformations further process the representations, and residual connections carry information around sublayers. Finally, an output transformation supplies scores for possible next tokens. A selection procedure chooses a continuation, which becomes part of the next input step.
Training changes the settings; a conversation changes the state
During training, a loss measures how the predictions compare with the training objective. Gradients estimate how parameter changes would affect that loss. An optimizer uses those gradients to update trainable parameters. A single example does not usually teach an isolated fact to one identifiable weight. Useful patterns emerge through many updates, and knowledge and behavior are distributed across the computation.
During ordinary inference, the parameters stay fixed. Your prompt changes the activations: the temporary numbers produced while the model runs. A cache can retain intermediate information so the system need not repeat earlier work. That cache is not a new permanent education for the model. A product may separately save conversation history or conduct later training, but those are additional mechanisms. Saying that a chatbot remembers your previous sentence does not establish that its weights changed.
Why more parameters is not a complete explanation
A parameter count describes scale, not a guarantee of reliability. Data quality, architecture, training, numerical precision, and the way a model is evaluated all matter. A large model can produce a convincing error; a smaller specialized model can perform a narrow task well. To compare systems, ask what task was tested and under what conditions, rather than treating one number as a universal intelligence score.
Return to the animation and identify three different objects: a stored weight, an activation that changes with the sentence, and an output score. If the diagram uses moving dots, those dots represent information flow; they are not literal particles inside a model. Using the small equation above on paper, change an input while keeping a weight fixed, then change the weight while keeping the input fixed. Explain why these are different experiments. That distinction will help you understand fine-tuning, quantization, caches, and model releases throughout the course.
Sources and further investigation
Source review: October 28, 2026. Model-release claims are attributed to their publishers.