atlas

Research map / Large language models / Language, safety and interpretability

In-Context Pretraining: Language Modeling Beyond Document Boundaries

ICLR 2024 · Large language models › Language, safety and interpretability · approach: In-context learning analysis · 3 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.

Proposes In-Context Pretraining, which reorders pretraining documents so each context window holds related documents (via contriever nearest-neighbor search and a max-TSP-style graph traversal), and pretrains 0.3B–7B LLaMA-style models from scratch on 306B tokens.

Problem

Standard LM pretraining concatenates random short documents into context windows, so prior documents give no signal for predicting the next document; the goal is to make pretraining contexts contain related documents at web scale without repeating data.

Approach

Keep the standard pretraining pipeline but reorder documents: link each document to its nearest neighbors via dense retrieval and FAISS, then build contexts by a greedy maximum-weight path traversal that visits each document exactly once, instead of kNN grouping that duplicates documents.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Pretrain on sequences of related documents instead of randomly ordered documentsICLM · Text classification (seven datasets)average accuracy: 66.0 -> 71.3Helped
Pretrain on sequences of related documents instead of randomly ordered documentsICLM · Reading comprehension (six datasets)average score: 37.6 -> 43.2Helped
Pretrain on sequences of related documents instead of randomly ordered documentsICLM · NQ and TriviaQA open-bookexact match: +9%Helped
Pretrain on sequences of related documents instead of randomly ordered documentsICLM · NQ and TriviaQA closed-bookexact matchMixed
Pretrain on sequences of related documents instead of randomly ordered documentsICLM · NQ-Swap and MemoTrapexact matchHelped
Pretrain on sequences of related documents instead of randomly ordered documentsICLM · SCROLL long-context tasksaverage score: 32.5 -> 34.1Helped
Use kNN document grouping instead of random document orderingStandard pretraining · Wikipedia, Arxiv, and Books language modelingperplexityNo clear effect
Increase document relevance from random to clustering to nearest-neighbor linking (ablation)ICLM · WikipediaperplexityHelped
Add semantic deduplication of near-duplicate documents (ablation)ICLM · WikipediaperplexityHelped
Increase the number of in-context demonstration examples (ablation)7B ICLM · Text classificationaccuracyHelped

Surprising findings

Limitations

Experimental setup

Datasets: English CommonCrawl (235M-document sample, ~306B tokens) SCROLL (finetuning for long-context evaluation)

Benchmarks: Wikipedia perplexity Arxiv perplexity Books perplexity SST2 Amazon Yelp AGNews DBpedia Hate Speech Offensive RACE BoolQ

Metrics: perplexity accuracy exact match F1 ROUGE-1

Baselines: Standard pretraining kNN pretraining clustering-based grouping

Builds on: LLaMA Contriever FAISS retrieval-augmented language model pretraining

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