9/30
Part 2 of 6 · Loss checksLearn and do
On random tokens, no honest model gets below ln V
The next check catches a model that sees the answer.
from collections.abc import Callable
def floor_test(model: nn.Module, get_batch: Callable, V: int, steps: int = 300) -> float:
"""Trains on random tokens. Returns the mean of the last 10 losses."""
# nothing here can be predicted
data = torch.randint(0, V, (100_000,))
opt = torch.optim.AdamW(model.parameters(), lr=3e-3)
losses = []
for _ in range(steps):
_, loss = model(*get_batch(data, model.block_size, 16))
opt.zero_grad(); loss.backward(); opt.step()
losses.append(loss.item())
# about ln V, never well below
return sum(losses[-10:]) / 10
This trains the model on uniformly random tokens, through their batch function, for a few hundred steps. Nothing in random tokens can be predicted. So the best any honest model can do is give every token , and its loss can't go below . That lowest possible loss is the data's floor.
Why train this test on random tokens, not real text?
Pick an answer above to see the rest
The causality test fails. Do you still run the target check?
Pick an answer above to see the rest
You close a leak, and the loss jumps from 0.02 to 3.5. What do you do?
Pick an answer above to see the rest