Reinforcement Learning and Language Model Alignment (VTR UGE 21), day 3 of 5
Prof. Dr. Utku Kose, Süleyman Demirel University
Parts A and B repeat two calculations of the lecture step by step, one REINFORCE update and the advantages of generalised advantage estimation (GAE), with sliders for their numbers. Part C evaluates the clipped objective of proximal policy optimisation (PPO) by hand. Part D trains a policy with and without the clip of PPO and shows its mean reward and its entropy over the iterations. Part E matches the ingredients of policy gradient methods with their effects. Part F lets you coach a free throw that is learned with REINFORCE and computes one update of its mean speed by hand.
The worked example of the lecture, one REINFORCE update in a state with three actions, with every intermediate value. The sliders set the three preferences, the action taken, the return and the learning rate, and every step is recomputed at once. A step with an input field asks for its value before it shows the calculation. The figure compares the probabilities before and after the update.
Back to the lecture: REINFORCE, where the text continues after the box of this part.
The worked example of the lecture: The agent writes the cat sat <eos>, the only reward comes with the last token, and a critic gives the four visited states a value. The sliders set the final reward, the four values of the critic and \(\lambda\); the discount factor is 1. The advantages are computed backwards from the last step. Values are rounded to four decimals.
Back to the lecture: Actor-critic. The lecture continues there with Section 4 of the Colab notebook: Open it from the next orange box.
PPO maximises the smaller of two terms: the ratio times the advantage, and the clipped ratio times the advantage, with the ratio clipped to the range from 0.8 to 1.2. This is the clipped objective of the lecture for a single step, with a clip range of 0.2. Compute it for three steps.
Back to the lecture: Trust regions and PPO, where the text continues after the box of this part.
A softmax policy learns to choose among four arms with close win rates, 0.70, 0.74, 0.77 and 0.80. Each iteration collects a small batch of 8 pulls and reuses it for the chosen number of gradient passes. Compare plain policy gradient with the clipped objective of PPO, raise the learning rate and the reuse, and add an entropy bonus. Every run is the mean of eight seeds.
The bench applies the formulas of the lecture to a bandit, in which every pull is an episode of one step. The advantage of a pull is its reward minus the mean reward of the batch, divided by the standard deviation of the rewards of the batch. In every pass, plain policy gradient adds the advantage times the gradient of the log-probability of the arm. The clipped objective multiplies this term by the probability ratio and leaves a pull out when its ratio has left the range from 0.8 to 1.2 in the direction that its advantage favours. The entropy bonus adds beta times the slope of the entropy to the mean gradient of the batch. A pass changes the preferences by this sum times the learning rate of the slider times 0.1, and a run has 150 iterations. The curves show the mean reward of the policy, at most 0.80, and its entropy in nats, at most ln 4 = 1.386.
| Run | Objective | Learning rate | Passes | Entropy bonus | Final reward | Worst seed | Final entropy |
|---|
Back to the lecture: Trust regions and PPO. The lecture continues there with Section 5 of the Colab notebook: Open it from the next orange box.
Match each ingredient of a policy gradient method with its effect.
Back to the lecture: Entropy, where the text continues after the box of this part.
A player practises free throws. The ball leaves the hand 2.1 m above the floor at 52 degrees, and the centre of the hoop is 4.2 m away and 3.05 m above the floor. Only the speed changes from throw to throw, so the speed alone sets how far the ball carries. A training app gives 10 marks for a ball through the centre of the hoop and one mark less for every 10 cm short or long, never fewer than 5. The ball goes in when it comes down less than 11 cm from the centre. The player draws the speed \(v\) of each throw from a normal distribution with the mean \(\mu\) and the spread \(\sigma\), starts at \(\mu = 6.9\) m/s and learns with REINFORCE: \(\mu \leftarrow \mu + \alpha\, (r - b)\, (v - \mu) / \sigma^2\), where \(r\) is the mark and the baseline \(b\) is the running average of the marks. Coach the player: Choose the spread, the step size and whether the marks are compared with the baseline. Every coaching plan uses the same random numbers for 200 throws, so two plans can be compared fairly. Find a plan with which the player scores at least 100 baskets. The controls start with the settings of the lecture. Then answer the questions below by hand.
By hand: The mean speed is \(\mu = 7.00\) m/s, the spread \(\sigma = 0.10\) m/s, the baseline \(b = 7.5\) and the step size \(\alpha = 0.001\). A throw at \(v = 7.10\) m/s comes down 12 cm short.
Back to the lecture: Entropy, where the text continues after the box of this part.
Answer each question, rate your confidence and check the answer. Results stay in this browser.
Write a short answer to each question. The text is saved in this browser and is included when you export the learning log.