atlas

Research map / Architectures and efficiency / Attention and transformers

Test-Time Training on Nearest Neighbors for Large Language Models

ICLR 2024 · Architectures and efficiency › Attention and transformers · approach: Language model pretraining and induction · 1 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Fine-tunes a causal LM on each test input's nearest neighbors retrieved from a 210M-sequence Pile index (one gradient step per neighbor), reducing bits-per-byte across Pile tasks.

Problem

Retrieval-augmented language models need retrieved data in context at both training and test time, and long contexts make Transformer cost grow quadratically. The paper asks whether test-time fine-tuning on nearest neighbors can improve language modeling without such retrieval-aware training.

Approach

For each test instance, retrieve its nearest neighbors from a large distributed embedding index of the Pile, fine-tune the pretrained model on them sequentially (nearest last-to-first ordering, one gradient step per chunk), then reset parameters; no hyperparameter tuning beyond HuggingFace defaults.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
test-time training on nearest neighbors (TTT-NN, 50 neighbors, one gradient step each)GPT-2-Large · Pile all tasksbits per byte: 1.07 -> 0.85Helped
test-time training on nearest neighborsGPT-2-Large · pile_githubbits per byte: 1.95 -> 0.51Helped
test-time training on nearest neighborsGPT-2-Large · pile_gutenberg, pile_youtubesubtitlesbits per byte: pile_gutenberg 1.21 -> 1.18 (improves slightly); pile_youtubesubtitles 1.51 -> 1.42 but dyn. eval. betterHurt
interpolating neighbor-token distribution with LM (Interpolate, KNN-LM style)GPT-2-Large · Pile all tasksbits per byte: 1.07 -> 0.99Helped
dynamic evaluation (7 iterations on first half of sequence)GPT-2-Large · Pile all tasksbits per byte: 1.07 -> 1.03Helped
adding retrieved neighbors in-context at test time without special trainingGPT-2-Large · Pile all tasksbits per byte: 1.07 -> 1.06No clear effect
training on neighbors in increasing distance order (nearest last) vs. nearest firstTTT-NN · Pilebits per byteNo clear effect
training on all neighbors in a single batch repeatedly instead of sequential updatesTTT-NN · Pilebits per byteNo clear effect
splitting evaluation sequence into retrieval half and evaluation half (no overlap) (ablation)TTT-NN GPT-2-Small · Pile all tasksbits per byte: 82% -> 83%No clear effect
using only ~20 neighbors instead of 50 (ablation)GPT-2-Small · Pilebits per byteNo clear effect

Surprising findings

Limitations

Experimental setup

Datasets: The Pile

Benchmarks: The Pile (22 language modeling tasks)

Metrics: bits per byte byte perplexity word perplexity

Baselines: In-Context neighbors Interpolate (KNN-LM variant) Dynamic evaluation Base model only

Builds on: dynamic evaluation local learning KNN-LM RoBERTa

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy