Skip to content

Instantly share code, notes, and snippets.

View lochbrunner's full-sized avatar

Matthias Lochbrunner lochbrunner

  • Deepmind
  • London
View GitHub Profile

Reinforcement Learning for Language Models

Yoav Goldberg, April 2023.

Why RL?

With the release of the ChatGPT model and followup large language models (LLMs), there was a lot of discussion of the importance of "RLHF training", that is, "reinforcement learning from human feedback". I was puzzled for a while as to why RL (Reinforcement Learning) is better than learning from demonstrations (a.k.a supervised learning) for training language models. Shouldn't learning from demonstrations (or, in language model terminology "instruction fine tuning", learning to immitate human written answers) be sufficient? I came up with a theoretical argument that was somewhat convincing. But I came to realize there is an additional argumment which not only supports the case of RL training, but also requires it, in particular for models like ChatGPT. This additional argument is spelled out in (the first half of) a talk by John Schulman from OpenAI. This post pretty much

@nullcline
nullcline / baka_trace.py
Created March 9, 2023 08:20
tsundere error traces
import traceback
import openai
import sys
# list models
models = openai.Model.list()
def baka(error, character="tsundere",):
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback_list = traceback.extract_tb(exc_traceback)
@lochbrunner
lochbrunner / bieber_lstm.py
Last active September 4, 2022 09:11
Using pytorch, LSTM, mini-batches and DataSets to train a toy model. This GIST is inspired by https://gist.github.com/williamFalcon/f27c7b90e34b4ba88ced042d9ef33edd but trying to be complete, working and a bit more simpler than the orig. Additionaly it uses torch datasets.
#!/usr/bin/env python
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn
import torch
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from torch.nn import functional as F