In-context Pretraining: Language Modeling Beyond Document Boundaries
Not on the map. Why?
Abstract (arXiv)
Large language models (LMs) are currently trained to predict tokens given document prefixes, enabling them to directly perform long-form generation and prompting-style tasks which can be reduced to document completion. Existing pretraining pipelines train LMs by concatenating random sets of short documents to create input contexts but the prior documents provide no signal for predicting the next document. We instead present In-Context Pretraining, a new approach where language models are pretrained on a sequence of related documents, thereby explicitly encouraging them to read and reason across document boundaries. We can do In-Context Pretraining by simply changing the document ordering so that each context contains related documents, and directly applying existing pretraining pipelines. However, this document sorting problem is challenging. There are billions of documents and we would like the sort to maximize contextual similarity for every document without repeating any data. To do this, we introduce approximate algorithms for finding related documents with efficient nearest neighbor search and constructing coherent input contexts with a graph traversal algorithm. Our experiments show In-Context Pretraining offers a simple and scalable approach to significantly enhance LMs'performance: we see notable improvements in tasks that require more complex contextual reasoning, including in-context learning (+8%), reading comprehension (+15%), faithfulness to previous contexts (+16%), long-context reasoning (+5%), and retrieval augmentation (+9%).
Key facts. Cited by 76 papers in the map (data through 7 Oct 2026). Builds on 50 of its 63 references that are in the map. First posted on arXiv 16 Oct 2023.
Builds on
50 of 63 references.
References · 50
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2016SQuAD: 100,000+ Questions for Machine Comprehension of Textcited by 4,115
- 2018HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answeringcited by 3,686
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
- 2017TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehensioncited by 2,895
- 2017Billion-scale similarity search with GPUscited by 2,477
- 2015Character-level Convolutional Networks for Text Classificationcited by 2,293
- 2019BoolQ: Exploring the Surprising Difficulty of Natural Yes/No Questionscited by 2,140
38 more
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
- 2022BLOOM: A 176B-Parameter Open-Access Multilingual Language Modelcited by 1,968
- 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,371
- 2021Unsupervised Dense Information Retrieval with Contrastive Learningcited by 1,203
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
- 2019DROP: A Reading Comprehension Benchmark Requiring Discrete Reasoning Over Paragraphscited by 883
- 2022Super-NaturalInstructions: Generalization via Declarative Instructions on 1600+ NLP Taskscited by 858
- 2017RACE: Large-scale ReAding Comprehension Dataset From Examinationscited by 851
- 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 820
- 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 786
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 721
- 2019CCNet: Extracting High Quality Monolingual Datasets from Web Crawl Datacited by 544
- 2021MetaICL: Learning to Learn In Contextcited by 450
- 2020TweetEval: Unified Benchmark and Comparative Evaluation for Tweet Classificationcited by 414
- 2023How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resourcescited by 405
- 2021Entity-Based Knowledge Conflicts in Question Answeringcited by 349
- 2022One Embedder, Any Task: Instruction-Finetuned Text Embeddingscited by 329
- 2023Trusting Your Evidence: Hallucinate Less with Context-aware Decodingcited by 319
- 2023SemDeDup: Data-efficient learning at web-scale through semantic deduplicationcited by 295
- 2023RECOMP: Improving Retrieval-Augmented LMs with Compression and Selective Augmentationcited by 253
- 2022LinkBERT: Pretraining Language Models with Document Linkscited by 209
- 2023Inverse Scaling: When Bigger Isn't Bettercited by 205
- 2023RA-DIT: Retrieval-Augmented Dual Instruction Tuningcited by 194
- 2022SCROLLS: Standardized CompaRison Over Long Language Sequencescited by 170
- 2021Meta-learning via Language Model In-context Tuningcited by 163
- 2022Retrieval-Augmented Multimodal Language Modelingcited by 125
- 2022Training Language Models with Memory Augmentationcited by 112
- 2020Pre-training via Paraphrasingcited by 92
- 2020The Turking Test: Can Language Models Understand Instructions?cited by 82
- 2023Context-faithful Prompting for Large Language Modelscited by 76
- 2023Resolving Knowledge Conflicts in Large Language Modelscited by 49
- 2023Knowledge Card: Filling LLMs' Knowledge Gaps with Plug-in Specialized Language Modelscited by 46
- 2023Pre-Training to Learn in Contextcited by 41
- 2022Nonparametric Masked Language Modelingcited by 39
- 2021Dict-BERT: Enhancing Language Model Pre-training with Dictionarycited by 38
- 2021The Inductive Bias of In-Context Learning: Rethinking Pretraining Example Designcited by 33
- 2022Data-Efficient Finetuning Using Cross-Task Nearest Neighborscited by 26
- 2020Machine Reading Comprehension: The Role of Contextualized Language Models and Beyondcited by 21
Built on by
Citing papers per year: 2023: 4; 2024: 37; 2025: 26; 2026: 9.
76 papers.
Sort:
By area:
- 2024MiniCPM: Unveiling the Potential of Small Language Models with Scalable Training Strategiescited by 694
- 2024The Faiss librarycited by 370
- 2024RAFT: Adapting Language Model to Domain Specific RAGcited by 258
- 2024MUSE: Machine Unlearning Six-Way Evaluation for Language Modelscited by 251
- 2024VisRAG: Vision-based Retrieval-augmented Generation on Multi-modality Documentscited by 237
- 2024Make Your LLM Fully Utilize the Contextcited by 118
- 2024Found in the Middle: Calibrating Positional Attention Bias Improves Long Context Utilizationcited by 97
- 2024Catastrophic Failure of LLM Unlearning via Quantizationcited by 76
- 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
- 2024Large Scale Transfer Learning for Tabular Data via Language Modelingcited by 73
- 2024DevEval: A Manually-Annotated Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 71
- 2025CAD-Llama: Leveraging Large Language Models for Computer-Aided Design Parametric 3D Model Generationcited by 65
38 more
- 2024Instruction Pre-Training: Language Models are Supervised Multitask Learnerscited by 63
- 2025ChunkKV: Semantic-Preserving KV Cache Compression for Efficient Long-Context LLM Inferencecited by 57
- 2024UDA: A Benchmark Suite for Retrieval Augmented Generation in Real-world Document Analysiscited by 40
- 2024Lory: Fully Differentiable Mixture-of-Experts for Autoregressive Language Model Pre-trainingcited by 37
- 2024Fewer Truncations Improve Language Modelingcited by 33
- 2024In-Context Fine-Tuning for Time-Series Foundation Modelscited by 31
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 30
- 2024Parallel Structures in Pre-training Data Yield In-Context Learningcited by 26
- 2024Dataset Decomposition: Faster LLM Training with Variable Sequence Length Curriculumcited by 25
- 2024Analysing The Impact of Sequence Composition on Language Model Pre-Trainingcited by 22
- 2024Adaptive Contrastive Decoding in Retrieval-Augmented Generation for Handling Noisy Contextscited by 19
- 2023Structured Packing in LLM Training Improves Long Context Utilizationcited by 17
- 2024Quest: Query-centric Data Synthesis Approach for Long-context Scaling of Large Language Modelcited by 15
- 2024What are the Essential Factors in Crafting Effective Long Context Multi-Hop Instruction Datasets? Insights and Best Practicescited by 14
- 2023Large Language Models are Miscalibrated In-Context Learnerscited by 12
- 2024Yi-Lightning Technical Reportcited by 11
- 2025GRU: Mitigating the Trade-off between Unlearning and Retention for LLMscited by 11
- 2024Improving Domain Adaptation through Extended-Text Reading Comprehensioncited by 10
- 2024DAPE V2: Process Attention Score as Feature Map for Length Extrapolationcited by 10
- 2024MDCure: A Scalable Pipeline for Multi-Document Instruction-Followingcited by 10
- 2024DevEval: Evaluating Code Generation in Practical Software Projectscited by 9
- 2024Untie the Knots: An Efficient Data Augmentation Strategy for Long-Context Pre-Training in Language Modelscited by 9
- 2024A Survey on Responsible Generative AI: What to Generate and What Notcited by 8
- 2023EpiK-Eval: Evaluation for Language Models as Epistemic Modelscited by 6
- 2024BaichuanSEED: Sharing the Potential of ExtensivE Data Collection and Deduplication by Introducing a Competitive Large Language Model Baselinecited by 6
- 2025SkyLadder: Better and Faster Pretraining via Context Window Schedulingcited by 6
- 2025LongMagpie: A Self-synthesis Method for Generating Large-scale Long-context Instructionscited by 6
- 2025Harry Potter is Still Here! Probing Knowledge Leakage in Targeted Unlearned Large Language Models via Automated Adversarial Promptingcited by 6
- 2025Not All Tokens Are Meant to Be Forgottencited by 6
- 2025Improving Fisher Information Estimation and Efficiency for LoRA-based LLM Unlearningcited by 6
- 2023Beyond Output Matching: Bidirectional Alignment for Enhanced In-Context Learningcited by 5
- 2025DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfercited by 5
- 2025EntropyLong: Effective Long-Context Training via Predictive Uncertaintycited by 5
- 2024Investigating the Effectiveness of HyperTuning via Gistingcited by 4
- 2024Automatically Generating Numerous Context-Driven SFT Data for LLMs across Diverse Granularitycited by 4
- 2025A Survey of LLM × DATAcited by 4
- 2025Continuously Steering LLMs Sensitivity to Contextual Knowledge with Proxy Modelscited by 4
- 2025Synthetic bootstrapped pretrainingcited by 4
50 most cited of 76 All 76 (JSON)
- 2026When Context Misleads: In-context Learning with Jurisdiction in Large Language Models23 Sep 2026
- 2026What Proves You Wrong: Benchmarking Language Models on Falsifiable Research Ideation24 Aug 2026
- 2026Beyond Rephrasing: Book-Level Organization Improves Synthetic Textbook Data for Mid-Training30 Jul 2026
- 2026The Cost of Knowing: A Resource-Aware Protocol for Benchmarking Hallucination Beyond Static Leaderboards27 Jul 2026
- 2026Pretraining EHR Foundation Models with Patient-Aware Sampling24 Jul 2026
- 2026In-context Region-based Drag: Drag Any Region to Any Shape24 Jun 2026
- 2026Why Do Time Series Models Need Long Context Windows?1 Jun 2026
- 2026PolicyLong: Towards On-Policy Context Extension9 Apr 2026
- 2026Knowledge without Wisdom: Measuring Misalignment between LLMs and Intended Impact1 Mar 2026
- 2025Effect of Document Packing on the Latent Multi-Hop Reasoning Capabilities of Large Language Models16 Dec 2025
- 2025Forgetting to Forget: Attention Sink as A Gateway for Backdooring LLM Unlearning19 Oct 2025
- 2025The Impact of Role Design in In-Context Learning for Large Language Models27 Sep 2025
38 more
- 2025EntropyLong: Effective Long-Context Training via Predictive Uncertainty26 Sep 2025
- 2025On Theoretical Interpretations of Concept-Based In-Context Learning25 Sep 2025
- 2025LiteLong: Resource-Efficient Long-Context Data Synthesis for LLMs19 Sep 2025
- 2025Synthetic bootstrapped pretraining17 Sep 2025
- 2025Deploying AI for Signal Processing education: Selected challenges and intriguing opportunities10 Sep 2025
- 2025Improving Fisher Information Estimation and Efficiency for LoRA-based LLM Unlearning29 Aug 2025
- 2025Continuously Steering LLMs Sensitivity to Contextual Knowledge with Proxy Models27 Aug 2025
- 2025DiFaR: Enhancing Multimodal Misinformation Detection with Diverse, Factual, and Relevant Rationales14 Aug 2025
- 2025The SMeL Test: A simple benchmark for media literacy in language models4 Aug 2025
- 2025DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfer31 Jul 2025
- 2025Document-Level Tabular Numerical Cross-Checking: A Coarse-to-Fine Approach16 Jun 2025
- 2025Not All Tokens Are Meant to Be Forgotten3 Jun 2025
- 2025Improving Continual Pre-training Through Seamless Data Packing28 May 2025
- 2025A Survey of LLM × DATA24 May 2025
- 2025Harry Potter is Still Here! Probing Knowledge Leakage in Targeted Unlearned Large Language Models via Automated Adversarial Prompting22 May 2025
- 2025LongMagpie: A Self-synthesis Method for Generating Large-scale Long-context Instructions22 May 2025
- 2025CAD-Llama: Leveraging Large Language Models for Computer-Aided Design Parametric 3D Model Generation7 May 2025
- 2025SkyLadder: Better and Faster Pretraining via Context Window Scheduling19 Mar 2025
- 2025Computation Mechanism Behind LLM Position Generalization17 Mar 2025
- 2025GRU: Mitigating the Trade-off between Unlearning and Retention for LLMs12 Mar 2025
- 2025Post-training an LLM for RAG? Train on Self-Generated Demonstrations14 Feb 2025
- 2025ChunkKV: Semantic-Preserving KV Cache Compression for Efficient Long-Context LLM Inference1 Feb 2025
- 2025StaICC: Standardized Evaluation for Classification Task in In-context Learning27 Jan 2025
- 2024Yi-Lightning Technical Report2 Dec 2024
- 2024In-Context Fine-Tuning for Time-Series Foundation Models31 Oct 2024
- 2024UpANNS: Enhancing Billion-Scale ANNS Efficiency with Real-World PIM Architecture31 Oct 2024
- 2024MDCure: A Scalable Pipeline for Multi-Document Instruction-Following30 Oct 2024
- 2024Catastrophic Failure of LLM Unlearning via Quantization21 Oct 2024
- 2024VisRAG: Vision-based Retrieval-augmented Generation on Multi-modality Documents14 Oct 2024
- 2024DAPE V2: Process Attention Score as Feature Map for Length Extrapolation7 Oct 2024
- 2024HALO: Hallucination Analysis and Learning Optimization to Empower LLMs with Retrieval-Augmented Context for Guided Clinical Decision Making16 Sep 2024
- 2024Untie the Knots: An Efficient Data Augmentation Strategy for Long-Context Pre-Training in Language Models7 Sep 2024
- 2024What are the Essential Factors in Crafting Effective Long Context Multi-Hop Instruction Datasets? Insights and Best Practices3 Sep 2024
- 2024DataSculpt: Crafting Data Landscapes for Long-Context LLMs through Multi-Objective Partitioning2 Sep 2024
- 2024BaichuanSEED: Sharing the Potential of ExtensivE Data Collection and Deduplication by Introducing a Competitive Large Language Model Baseline27 Aug 2024
- 2024Adaptive Contrastive Decoding in Retrieval-Augmented Generation for Handling Noisy Contexts2 Aug 2024
- 2024MUSE: Machine Unlearning Six-Way Evaluation for Language Models8 Jul 2024
- 2024Found in the Middle: Calibrating Positional Attention Bias Improves Long Context Utilization23 Jun 2024
50 newest of 76 All 76 (JSON)
- 2024VisRAG: Vision-based Retrieval-augmented Generation on Multi-modality Documentscited by 237
- 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
- 2024UDA: A Benchmark Suite for Retrieval Augmented Generation in Real-world Document Analysiscited by 40
- 2024Adaptive Contrastive Decoding in Retrieval-Augmented Generation for Handling Noisy Contextscited by 19
- 2025A Survey of LLM × DATAcited by 4
- 2024HALO: Hallucination Analysis and Learning Optimization to Empower LLMs with Retrieval-Augmented Context for Guided Clinical Decision Makingcited by 3
- 2025Post-training an LLM for RAG? Train on Self-Generated Demonstrationscited by 1
- 2024UpANNS: Enhancing Billion-Scale ANNS Efficiency with Real-World PIM Architecturecited by 0
- 2025A Survey of LLM × DATA24 May 2025
- 2025Post-training an LLM for RAG? Train on Self-Generated Demonstrations14 Feb 2025
- 2024UpANNS: Enhancing Billion-Scale ANNS Efficiency with Real-World PIM Architecture31 Oct 2024
- 2024VisRAG: Vision-based Retrieval-augmented Generation on Multi-modality Documents14 Oct 2024
- 2024HALO: Hallucination Analysis and Learning Optimization to Empower LLMs with Retrieval-Augmented Context for Guided Clinical Decision Making16 Sep 2024
- 2024Adaptive Contrastive Decoding in Retrieval-Augmented Generation for Handling Noisy Contexts2 Aug 2024
- 2024UDA: A Benchmark Suite for Retrieval Augmented Generation in Real-world Document Analysis21 Jun 2024
- 2024Reliable, Adaptable, and Attributable Language Models with Retrieval5 Mar 2024
- 2024MUSE: Machine Unlearning Six-Way Evaluation for Language Modelscited by 251
- 2024Catastrophic Failure of LLM Unlearning via Quantizationcited by 76
- 2025GRU: Mitigating the Trade-off between Unlearning and Retention for LLMscited by 11
- 2025Harry Potter is Still Here! Probing Knowledge Leakage in Targeted Unlearned Large Language Models via Automated Adversarial Promptingcited by 6
- 2025Not All Tokens Are Meant to Be Forgottencited by 6
- 2025Improving Fisher Information Estimation and Efficiency for LoRA-based LLM Unlearningcited by 6
- 2025Forgetting to Forget: Attention Sink as A Gateway for Backdooring LLM Unlearningcited by 4
- 2025Forgetting to Forget: Attention Sink as A Gateway for Backdooring LLM Unlearning19 Oct 2025
- 2025Improving Fisher Information Estimation and Efficiency for LoRA-based LLM Unlearning29 Aug 2025
- 2025Not All Tokens Are Meant to Be Forgotten3 Jun 2025
- 2025Harry Potter is Still Here! Probing Knowledge Leakage in Targeted Unlearned Large Language Models via Automated Adversarial Prompting22 May 2025
- 2025GRU: Mitigating the Trade-off between Unlearning and Retention for LLMs12 Mar 2025
- 2024Catastrophic Failure of LLM Unlearning via Quantization21 Oct 2024
- 2024MUSE: Machine Unlearning Six-Way Evaluation for Language Models8 Jul 2024
- 2024Yi-Lightning Technical Reportcited by 11
- 2024Yi-Lightning Technical Report2 Dec 2024
- 2026In-context Region-based Drag: Drag Any Region to Any Shape24 Jun 2026
- 2024MiniCPM: Unveiling the Potential of Small Language Models with Scalable Training Strategiescited by 694
- 2024The Faiss librarycited by 370
- 2024RAFT: Adapting Language Model to Domain Specific RAGcited by 258
- 2024Make Your LLM Fully Utilize the Contextcited by 118
- 2024Found in the Middle: Calibrating Positional Attention Bias Improves Long Context Utilizationcited by 97
- 2024Large Scale Transfer Learning for Tabular Data via Language Modelingcited by 73
- 2024DevEval: A Manually-Annotated Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 71
- 2025CAD-Llama: Leveraging Large Language Models for Computer-Aided Design Parametric 3D Model Generationcited by 65
- 2024Instruction Pre-Training: Language Models are Supervised Multitask Learnerscited by 63
- 2024Fewer Truncations Improve Language Modelingcited by 33
- 2024In-Context Fine-Tuning for Time-Series Foundation Modelscited by 31
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 30
12 most cited of 50 All 50 (JSON)
- 2026When Context Misleads: In-context Learning with Jurisdiction in Large Language Models23 Sep 2026
- 2026What Proves You Wrong: Benchmarking Language Models on Falsifiable Research Ideation24 Aug 2026
- 2026Beyond Rephrasing: Book-Level Organization Improves Synthetic Textbook Data for Mid-Training30 Jul 2026
- 2026The Cost of Knowing: A Resource-Aware Protocol for Benchmarking Hallucination Beyond Static Leaderboards27 Jul 2026
- 2026Pretraining EHR Foundation Models with Patient-Aware Sampling24 Jul 2026
- 2026Why Do Time Series Models Need Long Context Windows?1 Jun 2026
- 2026PolicyLong: Towards On-Policy Context Extension9 Apr 2026
- 2026Knowledge without Wisdom: Measuring Misalignment between LLMs and Intended Impact1 Mar 2026
- 2025The Impact of Role Design in In-Context Learning for Large Language Models27 Sep 2025
- 2025EntropyLong: Effective Long-Context Training via Predictive Uncertainty26 Sep 2025
- 2025On Theoretical Interpretations of Concept-Based In-Context Learning25 Sep 2025
- 2025Deploying AI for Signal Processing education: Selected challenges and intriguing opportunities10 Sep 2025
12 newest of 50 All 50 (JSON)