Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Test-Time Training on Nearest Neighbors for Large Language Models

About

Many recent efforts augment language models with retrieval, by adding retrieved data to the input context. For this approach to succeed, the retrieved data must be added at both training and test time. Moreover, as input length grows linearly with the size of retrieved data, cost in computation and memory grows quadratically for modern Transformers. To avoid these complications, we simply fine-tune the model on retrieved data at test time, using its standard training setup. We build a large-scale distributed index based on text embeddings of the Pile dataset. For each test input, our system retrieves its neighbors and fine-tunes the model on their text. Surprisingly, retrieving and training on as few as 20 neighbors, each for only one gradient iteration, drastically improves performance across more than 20 language modeling tasks in the Pile. For example, test-time training with nearest neighbors significantly narrows the performance gap between a small GPT-2 and a GPT-Neo model more than 10 times larger. Sufficient index quality and size, however, are necessary. Our work establishes a first baseline of test-time training for language modeling.

Moritz Hardt, Yu Sun• 2023

Related benchmarks

TaskDatasetResultRank
Language ModelingThe Pile (test)--
53
Language ModelingThe Pile DM Math (test)
BPB (%)82.14
6
Language ModelingThe Pile FreeLaw (test)
BPB (%)72.73
6
Language ModelingThe Pile ArXiv (test)
BPB Score90.82
6
Language ModelingThe Pile HackerNews (test)
BPB (Bits Per Byte)0.8698
6
Language ModelingThe Pile PubMed Cent. (test)
BPB%85.03
6
Language ModelingThe Pile StackEx. (test)
BPB (%)80.91
6
Language ModelingThe Pile Wikipedia (test)
BPB68.83
6
Language ModelingThe Pile Github (test)
Bits Per Byte (BPB)46.97
6
Language ModelingThe Pile Enron (test)
BPB65.67
6
Showing 10 of 13 rows

Other info

Code

Follow for update