Deep Reinforcement Learning


Deep Reinforcement Learning

Anna
I've been reading about deep reinforcement learning, and it's fascinating how it combines deep learning with decision-making. Have you looked into it?

Hope
Yeah, it's like teaching an agent to make a sequence of good decisions, right? And they use neural networks to handle huge state spaces. The lecture mentioned Atari games and AlphaGo.

Anna
Exactly. The key difference from supervised learning is that RL learns from experience, not labels. In supervised learning, you show examples, but in RL, the agent explores and gets rewards.

Hope
Right. And the lecture gave a great example: solving the game of Go with supervised learning would require expert moves, but you'd never cover all possible board states. That's where RL shines.

Anna
And even expert moves aren't always optimal. So RL addresses that by using delayed rewards. The agent learns to maximize cumulative reward over time.

Hope
The vocabulary is important: agent, environment, state, action, reward. And the goal is to maximize the return, which is the sum of discounted rewards.

Anna
Discount factor gamma makes sense because future rewards are less certain. Like getting a dollar now is better than later. In RL, it also helps the algorithm converge.

Hope
They used a simple recycling example with five states and actions left/right. The Q-table stored values for each state-action pair. And the Bellman equation gives the optimal Q values.

Anna
The Bellman equation is key: Q*(s,a) = r + gamma * max_{a'} Q*(s',a'). It means the optimal value of an action is the immediate reward plus the best future value from the next state.

Hope
But a Q-table won't work for complex games like Atari because the state space is huge. That's why we use deep Q-learning: a neural network approximates the Q function.

Anna
The network takes the state as input and outputs Q-values for each action. But how do we train it without labels? They use the Bellman equation to create targets.

Hope
Right. You compute the target as r + gamma * max_{a'} Q(s',a') from the current network. Then you minimize the difference between the predicted Q and that target.

Anna
But that target uses the same network, so it's moving. They fix the target by not backpropagating through it. And they use experience replay to break correlations between consecutive states.

Hope
Experience replay stores transitions (s, a, r, s') in a memory buffer and samples random mini-batches for training. That makes learning more stable and efficient.

Anna
Another trick is epsilon-greedy exploration. With probability epsilon, you take a random action; otherwise, you choose greedily. This prevents the agent from getting stuck in local optima.

Hope
The lecture also showed that for Atari games, they preprocess the input by converting to grayscale, cropping, and stacking four frames to capture motion. That's crucial for games like Breakout.

Anna
And the network is a CNN because it's processing images. They trained one algorithm on many games and achieved superhuman performance on most. That was a big breakthrough from DeepMind.

Hope
Then they moved to reinforcement learning from human feedback, or RLHF, which is used to align language models like ChatGPT. It starts with supervised fine-tuning on human-written responses.

Anna
But supervised fine-tuning only imitates good behavior; it doesn't optimize for preferences. So they train a reward model on human comparisons between different responses.

Hope
The reward model takes a prompt and response and outputs a scalar score representing human preference. It's trained to give higher scores to preferred responses.

Anna
Then they use RL, specifically PPO, to fine-tune the language model. The model generates responses, the reward model scores them, and the model updates to maximize that score.

Hope
So the agent is the language model, the environment is the space of prompts and generated tokens, and the reward comes from the reward model. It's sparse because you only get the reward at the end of the response.

Anna
That's similar to games like chess where you only know if you won at the end. The model has to learn to make a sequence of good token choices to get a high reward.

Hope
RLHF has been crucial for making language models helpful and harmless. The lecture mentioned that it was the leap from GPT-2 to ChatGPT.

Anna
And it's more efficient than supervised fine-tuning because asking humans to compare two responses is easier than writing one from scratch.

Hope
Overall, deep RL is powerful for tasks requiring sequential decision-making. From games to robotics to aligning AI, it's a key technique.

Ask anything
We've read this whole study set, so questions about it get the best answers.