Skip to content

Instantly share code, notes, and snippets.

View mrdrozdov's full-sized avatar

Andrew Drozdov mrdrozdov

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

@efonte
efonte / script.py
Created October 18, 2019 17:57
Disco Elysium texts
import re
strings = set()
with open('texts.txt', mode='r', encoding='utf-8') as file_input:
content = file_input.read()
regExStr = r'^\s*\d string title = "(?:tooltip\d+|Name|Dialogue Text)"\n\s*\d string value = "((?!(START|input|\w+\(\)|\!\(\w+\(\)\))).+)"$'
compiled = re.compile(regExStr, re.MULTILINE)
matched = compiled.finditer(content)
@stephenroller
stephenroller / mixout.py
Last active February 10, 2023 23:49
Example of mixout on generic modules.
#!/usr/bin/env python3
"""
Example of a generic Mixout implementation. (Lee et al., 2019).
https://arxiv.org/abs/1909.11299
Implementation by Stephen Roller (https://stephenroller.com).
Updated 2020-02-10 to include 1/(1 - p) correction term. Thanks to
Cheolhyoung Lee for making this correction.
@yzh119
yzh119 / st-gumbel.py
Created January 12, 2018 12:25
ST-Gumbel-Softmax-Pytorch
from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def sample_gumbel(shape, eps=1e-20):
U = torch.rand(shape).cuda()
return -Variable(torch.log(-torch.log(U + eps) + eps))
@BaseCase
BaseCase / dc_2017_biblio.md
Last active January 23, 2020 05:13
List of resources recommended or mentioned by the speakers at Deconstruct 2017

Deconstruct 2017 Bibliography

Here are all of the resources mentioned by Deconstruct 2017 speakers, along with who recommended what. Please post a comment if I missed something or have an error!

DC 2017 Speakers' Choice Gold Medalist

  • Seeing Like a State by James Scott

Books

  • Public Opinion by Walter Lippmann (Evan Czaplicki)
  • A Pattern Language by Christopher Alexander (Brian Marick)
  • Domain Driven Design by Eric Evans (Brian Marick)
@kastnerkyle
kastnerkyle / treernn.py
Created March 16, 2017 23:52 — forked from volkancirik/treernn.py
Pytorch TreeRNN
"""
TreeLSTM[1] implementation in Pytorch
Based on dynet benchmarks :
https://github.com/neulab/dynet-benchmark/blob/master/dynet-py/treenn.py
https://github.com/neulab/dynet-benchmark/blob/master/chainer/treenn.py
Other References:
https://github.com/pytorch/examples/tree/master/word_language_model
https://github.com/pfnet/chainer/blob/29c67fe1f2140fa8637201505b4c5e8556fad809/chainer/functions/activation/slstm.py
https://github.com/stanfordnlp/treelstm
@maryrosecook
maryrosecook / ...
Last active September 13, 2018 18:17
Reminders to myself to help me get better at programming. I don't always manage to do these things, but I try. Please feel free to add your own reminders to yourself in the comments below!
We couldn’t find that file to show.
@coolaj86
coolaj86 / github-pages-https-lets-encrypt.md
Last active November 16, 2021 22:36
Github Pages: Let's Encrypt!
@bcomnes
bcomnes / .screenrc
Last active August 21, 2022 10:33
ssh agent forwarding in tmux and gnu screen
# Fix agent forwarding
# https://gist.github.com/martijnvermaat/8070533
# http://techblog.appnexus.com/2011/managing-ssh-sockets-in-gnu-screen/
# See .ssh/rc for socket linking
unsetenv SSH_AUTH_SOCK
setenv SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock.$HOSTNAME