AI Hero Club

Reasoning and Reinforcement Learning · Lesson 6

Marked Complete by You0 / 8

Saved in this browser only. Marking a lesson complete does not mean the project has passed verification.

Lesson Outline 10 subsections
Course Contents 8 lessons
Full course plan.
Reasoning and Reinforcement Learning / Learning Plan ↗

LESSON 06 / 8Suggested study 135 minutes

A Real RL Update: Sampling, Verification and Backpropagation

How do 40 sampled trajectories become one full-parameter update through verification, leave-one-out advantages and rescoring?

3 Questions for This Lesson
  • Completely track 40 steps to enter a parameter update
  • Separation of supervisory gains, RL benefits, reference penalties from optimist effects
  • Read evidence of thinning reward zero gradients, cropping and 17 volume updates
Course Project ZIP ↓

Set the Budget Before Freezing the Experiment

The training plan is fixed before the start of operation: random seed 29, CPU single-line, 40-step monitoring heat start-up, 100-stepon-policy intensive learning. The model configuration is consistent with chapter V, monitoring and RL use AdamW with zero weight decline; monitoring learning rate 0. 006, RL learning rate 0. 0015, and gradient paradigm one. RL selects five training topics, drawing eight tracks independently of each issue, so 40 and 100 steps 4,000 training tracks per step, regardless of additional samples for each stage of independent evaluation. Evaluation sampling cannot also be counted as evidence of training or as a covert addition to the training budget.

The monitoring phase uses the right two-step response to all twenty training topics, with the goal of responding to the negative logarithm probability on average. Forty steps later, copying it as a freeze reference and preserving the strategy as the pre-RL starting point; this is the same weighted snapshot that does not select the best synthesic baseline for some indicators from different candidates. There are no more types of training seeds in the current experiment, nor do you choose “Run a few more times until it's done.” on the basis of testing stop points.

The Supervised Objective Differs from the Later Reward Objective

Monitoring negative logarithms seem to be directly labeling the correct response, each with a gradient; strict incentives can only tell that the complete trajectory is passed and the correct number is not given when the right path is not taken. The two training signals cannot be confused. Reporting only random initializations to the final uplifts will count the ability to monitor learning as RL gains; this project clearly reports separately on the post-monitoring before and the post-RLafter, both of which are tested.

The monitoring phase gives the full response weight to each theme, each containing two random moves, so that the response request and re-averages are only fixed by a factor of two times the average of the answer word. If the same value is allowed for different lengths later, the dictionary equivalent will change the length response weight on average. The project has only a fixed two-step process, and the target unit is still identified in the document, so that the length does not allow the complete trajectory of the lesson to be replaced by a single custom.

LSFT=−1∣D∣∑x∈Dlog⁡pθ(y∗(x)∣x),L^RL=−1BG∑x,istopgrad⁡(Ai)log⁡pθ(yi∣x)L_{\mathrm{SFT}}=-\frac1{|D|}\sum_{x\in D}\log p_\theta(y^*(x)\mid x),\quad \widehat L_{\mathrm{RL}}=-\frac1{BG}\sum_{x,i}\operatorname{stopgrad}(A_i)\log p_\theta(y_i\mid x)
B=5 Question, G=8 sample; two-stage target is different from the data source.

Example 1: From a Group of Rewards to the Loss

Assuming that only the first of the eight sample questions is successful, the strict reward is [1,0,0,0,0,0,0,0]. If the current strategy is the same as a reference, all logarithm probability is zero, the positive reward is these. Leave a baseline to one zero and the remaining seven to 1/7 each, so the advantage is [1,−1/7,−1/7,−1/7,−1/7,−1/7,−1/7,−1/7]. The loss is an average after the probability of multiplying the eight advantages by the corresponding complete log, taking negative numbers.

If the log probability of an error path is − 3, with an advantage of − 1/7, which contributes to the value of the loss is ~ 3/56, the value is negative. Loss does not imply a procedural error, nor does it directly treat this proxy loss as a mission success rate. The true gradient is derived from the proxies of the advantage multiplied by the probabilities test; the optimist drops in loss, preferring to reduce the probability of a negative and increase the probability of a positive advantage path, but sharing parameters may lead to a connection of other paths, without ensuring that each act describes the change in an independent manner.

When the Current Policy Has Already Diverged from the Reference

If a path is now more common than a reference, the logarithmic ratio is positive, and the beta0.03 times the value is deducted from its reward; less see the path logarithm is negative, minus the negative number equals an increase in return. This is the correct composition of KL’s expectations, not a artificial incentive for wrong answers. As a result of a centralization, intra-group comparisons reflect both correctness and deviations. Beta is only meaningful in a clear goal, and should not be temporarily zeroed because it sees negative returns, which would be replaced by another goal.

The logarithmic of the correct path. 5 An error path logarithm - 0 2 for example, return of 0.985 and 0. 006. The error path values are positive, do not represent acceptance of the error by the verifyor, but encourage restoration of the relatively low reference quality. The report compares the rigorous reward to the sample log to a separate record that allows readers to distinguish. “Training is closer to reference” and “It's a more successful solution.”. When Beta is too big, it may be overstretched by the job reward; this experiment is fixed. 03, no search for a so-called universal optimal coefficient.

Organizing Batched Tasks and Random Streams

Each step takes five consecutive questions from the 20 training topics in a fixed cycle, extending them eight times to each issue, resulting in 40 consecutive lines by task. Sampler produces one number for two consecutive forwards; then re-scoring it on the same network, referring to no_grad. Incentives and reference differential tectonic returns, loo_advantages use eight reshapes; this batch is only rebutted once, and then immediately discarded. No high incentive samples were used to screen or repeat the wheels, so this chapter fulfils the conditions for sampling of the zero-policy estimation.

The fixed task cycle covers 20 questions every four steps, 100 steps every 25; 200 samples per question. However, the results of the sampling are based on a gradual change strategy, and 200 questions cannot be calculated as an IID sample from a fixed success rate to calculate a simple two confidence range. After the evaluation phase freezes, independent sampling is done in order to meet the repeated trial explanation under the fixed parameters. This is the difference between “Sampling success rate” in the log and the final evaluation of the success rate.

Example 2: When an All-Zero Group Should Skip the Update

The training has just begun, and the current model is a reference. If a set of incentives are zero, the logarithm is zero, and all returns and advantages are zero, the group contributes zero to the gradient, which is expected to act. The space thinning reward for each 10-step, 100-track approach would have encountered many of these groups. If the whole batch had been so and no extra positive, the update could have been zero. The two-step smoke training for tess.py checks the complete process and limited values, without requiring short training to change all parameters; the freezing 100-step real run only verifies 17 more actual updates.

When the strategy changes and the reference remains unchanged, even if there is a strict incentive for zero, different path logs can produce positive signals. If the reference is synchronized to the current strategy before each update is achieved, this will be removed, and the test reference digest will capture the error. On the contrary, if all incentives are identical but the process is still largely updated by uncertainty about the old gradient, it will not be reasonable to “Continuous learning”; the boundaries of the gradient will have to be identified as zero, payback detach and the current batch.

The Steps Between a Mathematical Estimate and a Working Optimization

REINFORCE’s unbiased conclusions are directed at expectations of uncut gradients under fixed parameters. Items record the original gradient paradigms, then crop them at the maximum of the parameters, and AdamW then update them according to the first and second steps of history. The clippings are part of the actual algorithms, and no longer claim that each parameter step is equal to an altruistic gradient multiplied by a fixed learning rate.

After each battle, check the gradient on a page-by-line basis and be limited in size to record the parameters; there is an immediate failure with the existence of the NaN or the missing gradient, which does not treat the nan_to_num as normal repair. Optimizing the record of the maximum absolute difference between the RL and the RL; the actual 17 counts are positive and each last has a non-zero gradient. The full byte summary of the reference model is identical and no gradient is available. This evidence supports “Full Network Parameters ParticipationRL”, and does not support that "every internal neuron has learned the algorithm."

Logs and Checkpoints Must Belong to the Same Run

Train output contains config, data summary, random seeds, steps, Beta, sample, staged history, before/after Complete evaluation, volume changes, and reference summaries. Checkpoint.pt saves both the final strategy and the freeze reference, evaluates the precise probability of success and KL to be reloaded, and tests confirm that it is consistent with results. No endshot can be used only as a result, nor can a better weight be replaced by another round next to the old report; the list contains summaries that bind source codes, check points and indicators.

When readers modify the learning rate or number of steps, it is suggested that a new directory be created through --output -- so that new experiments can coexist with packaged videodence. The output of different directories is not an additional one, because it is impossible to prove once the original evidence has been rewritten which of the quotes are running. Independent runbacks can lead to environmental re-entry differences; the probability, gradient and task results should be compared, and whether to place them in place. The next chapter will read the actual training upgrades and tests that have been frozen and explain why a system that achieves all the tests may still not solve the problem.

Run in the Project DirectoryDirectly Run Check
import torch
from run import loo_advantages
r=torch.tensor([1.,0.,0.,0.,0.,0.,0.,0.])
a=loo_advantages(r,8)
assert torch.allclose(a,torch.tensor([1.]+[-1/7]*7))
assert abs(float(a.sum()))<1e-6
print(a.tolist())
Terminal CommandRerun complete in new directory; fixed 40-step monitoring with 100-step RL
python run.py train --output my-run
python run.py evaluate --output my-run --split test

Independent Experiment: Gradients Through the Full Trajectory Tree and Seventeen Tensors

Only 100 tracks are allowed in this course, so you can list expectations completely on the same model and on the same subject, comparing the two paths of chapter IV. New gradient_audit.py creates random float64 models and freezes reference from secure 919 and then only adds a coordinates to the current head. 1 This human disturbance was used to test the formula, not the optimist update, and did not use historical training weights.

J=∑ypθ(y)Fθ(y),Fθ(y)=R(y)−βlog⁡pθ(y)q(y),S=∑ystopgrad⁡(pθ(y)Fθ(y))log⁡pθ(y).J=\sum_y p_\theta(y)F_\theta(y),\quad F_\theta(y)=R(y)-\beta\log\frac{p_\theta(y)}{q(y)},\qquad S=\sum_y\operatorname{stopgrad}(p_\theta(y)F_\theta(y))\log p_\theta(y).
beta=0.2, fixed (2, 2). Directly to J, as with S, which keeps only the score path, should be equal to this parameter point; the values for J and S should not be equal.

The script compares J to S for each of the 17 scales, instead of checking onlyhead. The maximum difference for all coordinates is 5.204170×10-107, which is less than the set 10-12 threshold; the probability of 100 paths and the equivalent of one within that threshold. The total L2 range is shown as a direct gradient in the second table below, and the maximum absolute difference by coordinates in the third. The parameters are not used to determine which layer is more important, but are used to avoid passing the gradient at zero and falsely.

Parameter ThrustDirect Gradient ArgumentsThe biggest error of both routes.
token_embedding.weight5.204599e-022.776e-17
position_embedding.weight5.293632e-023.383e-17
blocks.0.ln_attention.weight2.022516e-042.711e-19
blocks.0.ln_attention.bias3.909932e-048.945e-19
blocks.0.attention.query.weight4.406804e-051.186e-20
blocks.0.attention.key.weight4.168311e-052.795e-20
blocks.0.attention.value.weight8.320259e-035.204e-18
blocks.0.attention.output.weight8.771058e-033.578e-18
blocks.0.ln_feedforward.weight3.317937e-041.355e-19
blocks.0.ln_feedforward.bias2.445171e-041.423e-19
blocks.0.feedforward.0.weight1.228797e-024.770e-18
blocks.0.feedforward.0.bias3.367637e-031.030e-18
blocks.0.feedforward.2.weight1.336448e-024.987e-18
blocks.0.feedforward.2.bias5.428007e-022.342e-17
final_norm.weight1.220381e-035.313e-18
final_norm.bias1.404165e-037.589e-19
head.weight5.522263e-025.204e-17
Full volume verification on a real random model; no re-training and no replacement of the 40-step SFT+100 step RL result.

Negative contrasts with the intentional removal of stopgrad on probabilities weights and returns, and leads to “pFMultiplylogp”. The maximum difference between it and real J is 0.1358048393, which the examiner categorically rejects; this means that no agent can pass by without writing a single proxy. Direct and score routes share path_logps, so the path index cannot be proved separately; the two previous independent scores, grammar support, and probability and inspection continue to be maintained.

Run in the Project DirectoryRe-list 100 paths and verify all 17 volumes, while rejecting the error agent.
from gradient_audit import audit
r = audit()
assert len(r['tensors']) == 17
assert r['negative_control']['status'] == 'REJECTED'
assert r['model_unchanged'] and not r['training_performed']
print(r['max_absolute_error'], r['negative_control']['max_absolute_gradient_error'])
Terminal CommandKeeps a new receipt in the project root directory; it is exported to Runs and does not cover the original evidence.
.venv/bin/python gradient_audit.py --output runs/gradient-audit.json

This proves the consistency achieved by this limited-generation tree, both of which are the parameter points; the general rationale for the expectation of a constant equation is still the corollary of a zero average score. It does not mean that the random small gradients are identical to the exact gradients, nor does it mean that the Adam increases after the clippings are neutral. Scripts do not execute optimizers, do not read the freeze checkpoint, and at the end the checking of the model parameters tested remain unchanged.

TRY IT YOURSELF

Practice I: budget by item

How many training tracks are there?

Hint 1
Multiply the number of questions per step, sample each issue, update steps.
Hint 2
The number of turns per question is repeated cross-referenced and each two random numbers are shown separately from the extra evaluation sample, without counting EOS as a random training action.
Compare with the Solution
Total 5×8 x 100=4000. 25 times per subject x 8=200 with 20 questions totalling 4000. Each random action, 8,000 sampling figures; EOS is not random. The before/after evaluation sample is not included in training 4,000, but it consumes extra reasoning budgets, and the report should be disaggregated.

TRY IT YOURSELF

Practice II: Regular returns

Beta0. 03. The correct path log is 0. 5, the wrong path log is − 0.2.

Hint 1
Strictly correct rewards are listed in two separate columns, along with the return on training after joining KL.
Hint 2
Adds a r−beta log ratio to two paths; negative log ratio can bring positive or positive contributions, but does not change the certificationer label.
Compare with the Solution
Correct 1−0.03 x 0.5=0.985, Error 0−0.03 x (-0.2) = 0.006. There is still a strict reward for errors; positive returns from KL do not amount to certification. No positive or negative return should be used to replace the success label.

TRY IT YOURSELF

Practice III: Short smoke training not updated

The random initial strategy is a reference, and the whole set of zero incentives should not be imposed on each volume in the test?

Hint 1
The strategy is equal to the log ratio of each log and the advantage of a zero reward.
Hint 2
Check whether zero should be in place along the chain of advantage to the Loss gradient; no signal smoke cases apply different acceptance requirements than real signal operations.
Compare with the Solution
At this point, each log is zero, with zero returns, zero advantages and zero score loss gradients, and there is no theoretical update. The smoke test should check the process, shape, and limited values.

Which Objective Has an Unbiased Gradient Under Cyclic Sampling?

Leaves a fixed input without bias equal to the even goal of each step for all subjects. J_x(θ) The goal of the whole training topic is the right one under the current strategy. J(θ) =Σ_x J_x(θ) / 20. The kstep of this project takes the current question B_k, which only guarantees that the trajectories are expected to be equal to the condition of the uncut estimater J_Bk(θ_k), of which J_Bk= _(x∈Bk) J_x/5. It doesn't normally equal the thugs. J(θ_k) The shortest counter-arguments are: two issues: J1 (), J2 (),, the goal gradient for the homogeneity of the population is zero; the first question for a fixed draw is one; the gradient is estimated to be equal. After the second round, the parameters have been changed, and the four-step step-by-twenties are not averaged at the same parameter point. Only four sets of rights after the freezing of the same twilight have been accumulated will the overall gradient be accurately returned to the overall gradient; if the single step is evenly drawn, the goal will be gradually neutral. This does not transform the current cycle training into off-policy: each track is still extracted from the current pre-update strategy to meet the meaning of this chapter on-policy. Actual optimization also includes gradients and AdamW, and parameter increment should not be considered a direct and unbiased gradient. Keep cycle realization and the results of the old experiment here, and only clarify the scope of the conclusions at each level.

CHECK YOUR UNDERSTANDING

Check Your Understanding

Answer first, then open the explanation to check your reasoning. These questions help reveal gaps in understanding; independent implementation and transfer require separate evaluation.

From which point does the 1. RL upgrade compare?

Show ExplanationIn this way, SFT proceeds are distinguished from subsequent RL gains.
2. How many trajectories?

Show ExplanationThe project identified a series of no-policy updates with no old data to be reused.
3. Does the non-cuttled gradient mean that Adam's parameters are inexorable?

Show ExplanationThe estimater ' s conclusions cannot be transmitted directly to non-linear parameter updates.
4. Negative agent loss indicates what?

Show ExplanationThe loss is a proxy for the gradient and cannot be considered an accuracy or a full positive target.

Manual completion records your progress; it does not certify your project.