Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Yoav Goldberg, April 2023.
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
from transformers import AutoTokenizer, T5ForConditionalGeneration | |
# Model Init | |
n_gpu = 8 | |
tokenizer = AutoTokenizer.from_pretrained("google/flan-ul2") | |
model = T5ForConditionalGeneration.from_pretrained("google/flan-ul2") | |
heads_per_gpu = len(model.encoder.block) // n_gpu | |
device_map = { | |
gpu: list( | |
range( |
from typing import Any | |
from pytorch_lightning.utilities.fetching import AbstractDataFetcher | |
from pytorch_lightning.utilities.model_helpers import is_overridden | |
from pytorch_lightning.utilities.signature_utils import is_param_in_hook_signature | |
| |
| |
def on_run_start(self, data_fetcher: AbstractDataFetcher, **kwargs: Any) -> None: | |
self.trainer.logger_connector.on_epoch_start() | |
self.trainer.call_hook("on_epoch_start") | |
self.trainer.call_hook("on_train_epoch_start") |
name: Test | |
on: | |
push: | |
branches: | |
- main | |
- features/** | |
- dependabot/** | |
pull_request: | |
branches: |
""" | |
A minimal implementation of Monte Carlo tree search (MCTS) in Python 3 | |
Luke Harold Miles, July 2019, Public Domain Dedication | |
See also https://en.wikipedia.org/wiki/Monte_Carlo_tree_search | |
https://gist.github.com/qpwo/c538c6f73727e254fdc7fab81024f6e1 | |
""" | |
from abc import ABC, abstractmethod | |
from collections import defaultdict | |
import math |
class STLR(torch.optim.lr_scheduler._LRScheduler): | |
def __init__(self, optimizer, max_mul, ratio, steps_per_cycle, decay=1, last_epoch=-1): | |
self.max_mul = max_mul - 1 | |
self.turning_point = steps_per_cycle // (ratio + 1) | |
self.steps_per_cycle = steps_per_cycle | |
self.decay = decay | |
super().__init__(optimizer, last_epoch) | |
def get_lr(self): | |
residual = self.last_epoch % self.steps_per_cycle |
all: | |
python setup.py build_ext --inplace | |
clean: | |
rm -f pympi.cpp | |
rm -f pympi.so | |
rm -rf build |