Skip to main content
arXiv is now an independent nonprofit! Learn more
archive
Search Submit Donate Log in

Computer Science > Computation and Language

(cs)
[Submitted on 16 Oct 2023 (v1), last revised 24 Jun 2024 (this version, v6)]

Title:In-context Pretraining: Language Modeling Beyond Document Boundaries

Authors:Weijia Shi, Sewon Min, Maria Lomeli, Chunting Zhou, Margaret Li, Gergely Szilvasy, Rich James, Xi Victoria Lin, Noah A. Smith, Luke Zettlemoyer, Scott Yih, Mike Lewis
View a PDF of the paper titled In-context Pretraining: Language Modeling Beyond Document Boundaries, by Weijia Shi and Sewon Min and Maria Lomeli and Chunting Zhou and Margaret Li and Gergely Szilvasy and Rich James and Xi Victoria Lin and Noah A. Smith and Luke Zettlemoyer and Scott Yih and Mike Lewis
View PDF HTML (experimental)
Abstract: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%).
Subjects: Computation and Language (cs.CL); Artificial Intelligence (cs.AI); Machine Learning (cs.LG)
Cite as: arXiv:2310.10638 [cs.CL]
  (or arXiv:2310.10638v6 [cs.CL] for this version)
  https://doi.org/10.48550/arXiv.2310.10638
arXiv-issued DOI via DataCite

Submission history

From: Weijia Shi [view email]
[v1] Mon, 16 Oct 2023 17:57:12 UTC (1,084 KB)
[v2] Thu, 19 Oct 2023 01:40:02 UTC (1,084 KB)
[v3] Fri, 20 Oct 2023 23:44:56 UTC (1,085 KB)
[v4] Thu, 30 Nov 2023 23:26:35 UTC (1,087 KB)
[v5] Sat, 9 Mar 2024 22:22:48 UTC (1,088 KB)
[v6] Mon, 24 Jun 2024 06:28:42 UTC (1,088 KB)
Full-text links:

Access Paper:

    View a PDF of the paper titled In-context Pretraining: Language Modeling Beyond Document Boundaries, by Weijia Shi and Sewon Min and Maria Lomeli and Chunting Zhou and Margaret Li and Gergely Szilvasy and Rich James and Xi Victoria Lin and Noah A. Smith and Luke Zettlemoyer and Scott Yih and Mike Lewis
  • View PDF
  • HTML (experimental)
  • TeX Source
license icon view license

Current browse context:

cs.CL
< prev   |   next >
new | recent | 2023-10
Change to browse by:
cs
cs.AI
cs.LG

References & Citations

  • NASA ADS
  • Google Scholar
  • Semantic Scholar
Loading...

Bookmark

BibSonomy Reddit

arXivLabs: experimental projects with community collaborators

arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.

Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

Which authors of this paper are endorsers? | Disable MathJax (What is MathJax?)
We gratefully acknowledge support from our major funders, member institutions, , and all contributors.
About · Help · Contact · Subscribe · Copyright · Privacy · Accessibility · Operational Status (opens in new tab)
Major funding support from
Simons Foundation Simons Foundation International Schmidt Sciences