Papers › Scaling Retrieval-Based Language Models with a Trillion-Token Datastore

Scaling Retrieval-Based Language Models with a Trillion-Token Datastore

9 Jul 2024arXiv:2407.12854archive 2025-07-28

Rulin Shao, Jacqueline He, Akari Asai, Weijia Shi, Tim Dettmers, Sewon Min, Luke Zettlemoyer, Pang Wei Koh

Scaling laws with respect to the amount of training data and the number of parameters allow us to predict the cost-benefit trade-offs of pretraining language models (LMs) in different configurations. In this paper, we consider another dimension of scaling: the amount of data available at inference time. Specifically, we find that increasing the size of the datastore used by a retrieval-based LM monotonically improves language modeling and several downstream tasks without obvious saturation, such that a smaller model augmented with a large datastore outperforms a larger LM-only model on knowledge-intensive tasks. By plotting compute-optimal scaling curves with varied datastore, model, and pretraining data sizes, we show that using larger datastores can significantly improve model performance for the same training compute budget. We carry out our study by constructing a 1.4 trillion-token datastore named MassiveDS, which is the largest and the most diverse open-sourced datastore for retrieval-based LMs to date, and designing an efficient pipeline for studying datastore scaling in a computationally accessible manner. Finally, we analyze the effect of improving the retriever, datastore quality filtering, and other design choices on our observed scaling trends. Overall, our results show that datastore size should be considered as an integral part of LM efficiency and performance trade-offs. To facilitate future research, we open-source our datastore and code at https://github.com/RulinShao/retrieval-scaling.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2407.12854")

Code

Syntology Ran 13 of 14 code samples harvested from 1 repository linked to this paper; 1 has no recorded run. Of those that ran: 1 ran · fixture could not drive it; 12 ran with no contract checked.

By repository: official repository: 14 samples from 1 repository, 13 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

rulinshao/retrieval-scaling officialmentioned in papermentioned on GitHubMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

14 samples harvested; 13 ran; 0 honoured the contract we drafted; 1 has no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · fixture could not drive it
12ran
1unverified

Licence: 0 of the 14 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from rulinshao/retrieval-scaling. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

add_embeddings rulinshao/retrieval-scaling/contriever/passage_retrieval.py official repository ran · fixture could not drive it MIT (permissive) · bc7a7a194c238080 · report
check_below_lexical_overlap_threshold rulinshao/retrieval-scaling/src/decontamination.py official repository ran MIT (permissive) · ce1279ff0f9d0ad4 · report
check_endpoint rulinshao/retrieval-scaling/api/serve_main_node.py official repository ran MIT (permissive) · afaf6b8bca6e2795 · report
extract_answer rulinshao/retrieval-scaling/src/evaluate_perplexity.py official repository ran fingerprinted MIT (permissive) · 290c5134d15244b3 · report
extract_running_endpoints rulinshao/retrieval-scaling/api/serve_main_node.py official repository ran MIT (permissive) · 24e1876e4b2645ed · report
generate_13word_grams rulinshao/retrieval-scaling/src/decontamination.py official repository ran MIT (permissive) · e199a8fd8e8c353f · report
get_bm25_index_dir rulinshao/retrieval-scaling/src/index.py official repository ran MIT (permissive) · 71b717cfe94bf7d2 · report
get_search_output_path rulinshao/retrieval-scaling/src/search.py official repository ran MIT (permissive) · ab7ba9276e2369aa · report
get_sharded_passages rulinshao/retrieval-scaling/src/embed.py official repository ran MIT (permissive) · 00dd34a32eb05634 · report
hydra_runner rulinshao/retrieval-scaling/src/hydra_runner.py official repository ran MIT (permissive) · 5cbcb4692500af92 · report
max_contiguous_overlap rulinshao/retrieval-scaling/src/decontamination.py official repository ran fingerprinted MIT (permissive) · 87bbb67c9c88bea4 · report
rerank_elements rulinshao/retrieval-scaling/api/serve_main_node.py official repository ran MIT (permissive) · d2a9c470a304b933 · report
split_data_into_chunks rulinshao/retrieval-scaling/src/data.py official repository ran MIT (permissive) · 7b2c46dc9de9bec4 · report
load_passages rulinshao/retrieval-scaling/src/data.py official repository unverified MIT (permissive) · 97e49e2086fde576 · report

Tasks

Language ModelingLanguage ModellingRetrieval

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections