1 of 70

Large Language Models

Lecture 14

Alignment of Language Models:

Reward Maximization

Krishnendu Ghosh

2 of 70

Why Instruction Tuning not enough?

3 of 70

Taxonomy of Alignment methods

4 of 70

Reinforcement Learning

5 of 70

Reinforcement Learning

6 of 70

Reinforcement Learning

7 of 70

Reinforcement Learning

8 of 70

LLM as a Policy

9 of 70

LLM as a Policy

10 of 70

LLM as a Policy

11 of 70

LLM as a Policy

12 of 70

Who/What is the Reward Model?

13 of 70

LLM as a Reward Model

14 of 70

Architecture of the Reward Model

15 of 70

Bradley-Terry Preference Model I

16 of 70

Bradley-Terry Preference Model II

17 of 70

MLE for BT models

18 of 70

An intuitive view

19 of 70

Where does the Data come from?

20 of 70

Publicly Available Preference Data

21 of 70

Constitutional AI for Preferences

22 of 70

Reward Maximization Objective

23 of 70

Why care about closeness to πref?

24 of 70

Formulating Objective:

Reward Maximization

25 of 70

Formulating Objective:

Closeness to πref

26 of 70

Combining Objective

27 of 70

Takeaways & what next?

28 of 70

Regularized Reward Maximization

Objective

29 of 70

Regularized Reward

30 of 70

How to maximize REINFORCE?

REINFORCE (REward Increment = Nonnegative Factor × Offset Reinforcement? No.) stands for a policy-gradient algorithm commonly used in reinforcement learning.

​

It directly estimates how to update a policy to maximize expected reward.

​

How it works

​

1. Sample: The policy generates an action.

2. Reward: The environment provides a reward.

3. Calculate: Estimate how the action's reward compares with the expected return.

4. Update: Increase the probability of actions that yield higher returns.

31 of 70

How to maximize REINFORCE?

32 of 70

Computing the derivative

33 of 70

The log-derivative trick

34 of 70

Monte Carlo approximation

35 of 70

Expanding the gradient

36 of 70

Implementing REINFORCE

37 of 70

Problems with REINFORCE

38 of 70

REINFORCE with Q functions

39 of 70

Q-function & Value function

40 of 70

Q-function to Advantage function

41 of 70

REINFORCE with advantage functions

42 of 70

Implementing the Value function

43 of 70

Learning the Value function

44 of 70

Vanilla Policy Gradient

45 of 70

Problems

46 of 70

REINFORCE with importance weights

47 of 70

Proximal Policy Optimization

48 of 70

PPO-CLIP

49 of 70

PPO-CLIP with +ve advantage

50 of 70

PPO-CLIP with -ve advantage

51 of 70

The PPO-CLIP algorithm

52 of 70

Things to remember

53 of 70

Policy Gradient/PPO for

LLM Alignment

54 of 70

Direct Preference Optimization on preferences

55 of 70

The non-parametric case

56 of 70

Optimal Policy & Reward (π∗, r∗)

57 of 70

Parametric Policy & Reward (πθ, rθ)

58 of 70

Training the reward function

59 of 70

The DPO objective

60 of 70

Interpreting the objective

61 of 70

Interpreting β

62 of 70

PPO vs DPO

63 of 70

Why is DPO biased?

64 of 70

Why is DPO biased?

65 of 70

Why is DPO biased?

66 of 70

Why is DPO biased?

67 of 70

Deal with OOD Bias in DPO?

68 of 70

Performance Comparison:

Offline vs Online DPO

69 of 70

Main Takeaways

70 of 70

Source: https://lcs2-iitd.github.io/ELL881-AIL821-2401/lectures/