Skip to content

Infini-gram mini: internet-scale exact n-gram search with FM-indexInfini-gram mini: Exact n-gram Search at the Internet Scale with FM-Index

arXiv· arXiv:2506.12229· Hao Xu, Jiacheng Liu, Yejin Choi, Noah A. Smith, Hannaneh HajishirziPaul G. Allen School of Computer Science & Engineering, University of Washington; Allen Institute for AI; Stanford UniversityIndexed by this site · 2026-10-15· Originally publishedSelected ToolsSelectedAttention39

Quick read

Evaluation and benchmarks

Based on the paper PDF (generated by Gemini); refer to the original

The authors used the FM-index system to index an 83TB corpus and measured GSM8K's dirty data rate at 74.20% in CC-2025-21.

Questions
Modern language models are mainly trained on massive internet corpora; existing exact-match search engines build indexes whose size is typically 2× to 29× the corpus, with storage overhead too high to scale to PB-level corpora for training data screening and benchmark contamination analysis.
Methods
Based on the FM-index data structure, a scalable retrieval system is developed. A sampled suffix array and a wavelet-tree-compressed BWT are built over UTF-8 bytes, enabling indexing and text compression without tokenization. Sharded parallel construction and disk memory mapping support low-memory on-demand retrieval.
Experiments and results
Compressed an 83TB corpus index to 44% of the original size (36.88TB). Contamination detection across 24 benchmarks showed MMLU has a dirty data rate of 27.70% in DCLM-baseline and GSM8K reaches 74.20% in CC-2025-21; among dirty samples, 58% to 82.6% were question-answer pairs appearing verbatim.
Limitations and future work
Document retrieval latency is higher than suffix arrays; reconstructing 3000 characters takes 1.8 to 4.5 seconds. Multi-modal co-occurrence queries are difficult to support. Only case-sensitive exact matching is supported. Retrieved output may contain biases or sensitive content present in the original corpus. When the test set exceeds 1000 items, it is downsampled to 1000 items.
Experimental setupMMLU、MMLU-Pro et al. · dirty rate、suspicious rate et al.
Benchmarks
MMLUMMLU-ProBigBenchHardAGIEvalGPQAHLEAIME-2024GSM8KMATH-500MGSMHumanEvalHumanEval+LiveCodeBenchSWE-benchMBPPARC-ChallengeARC-EasyCSQAHellaSwagOpenbookQASocial IQaWinoGrandeCoQASQuADthe PileDCLM-baselineCommon Crawl
Metrics
dirty ratesuspicious rateη (50-character substring overlap proportion)indexing timepeak RAMquery latencystorage multiplier
AI summaryand selection rationaleResearchers from the University of Washington, Allen Institute for AI, and Stanford University release infini-gram mini, an exact-match search system based on FM-index, with an index size of only 44% of the corpus, indexing speed 18 times faster than the existing SDSL implementation, 3.2 times lower index memory usage, and negligible query memory. The team indexed 83TB of text on a single 128-vCPU CPU node in 99 days, covering Pile, DCLM-baseline, and 7 Common Crawl crawls from January to July 2025. The authors used the system to analyze contamination in 24 commonly used evaluation benchmarks and found 12 with clear contamination: on DCLM-baseline, MMLU has 27.70% dirty entries, and GSM8K has a dirty-entry ratio of 74.2% on the CC-2025-21 crawl; the authors say that in most dirty entries the question and answer appear together verbatim, which may overestimate model capability.

Researchers from the University of Washington, Allen Institute for AI, and Stanford University release infini-gram mini, an exact-match search system based on FM-index, with an index size of only 44% of the corpus, indexing speed 18 times faster than the existing SDSL implementation, 3.2 times lower index memory usage, and negligible query memory. The team indexed 83TB of text on a single 128-vCPU CPU node in 99 days, covering Pile, DCLM-baseline, and 7 Common Crawl crawls from January to July 2025. The authors used the system to analyze contamination in 24 commonly used evaluation benchmarks and found 12 with clear contamination: on DCLM-baseline, MMLU has 27.70% dirty entries, and GSM8K has a dirty-entry ratio of 74.2% on the CC-2025-21 crawl; the authors say that in most dirty entries the question and answer appear together verbatim, which may overestimate model capability.

Why it was selectedThe paper uses an FM-index whose size is only 44% of the corpus to make 83TB of text searchable, and on that basis reports contamination rates for several core benchmarks in web crawls, which can serve as a reference for cleaning evaluation data.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors state that exact matching search over massive internet corpora faces enormous storage overhead, making it difficult to systematically investigate benchmark contamination in large-scale pretraining data.

    This study attempts to solve the problem that exact-match search over massive internet text corpora has excessive storage overhead, making it difficult to conduct systematic benchmark contamination detection and data analysis on large-scale pretraining data.

    • Corpus scale and search needs: Modern language models are mainly trained on PB-scale internet corpora such as Common Crawl; retrieving exact matches of long sequences is important for understanding pretraining data and its impact on model behavior.
    • Storage overhead bottleneck of existing retrieval systems: Previous exact-match search engines built indexes whose size was typically several times the corpus itself, e.g., suffix automata reached 29×, suffix arrays 6×, and ElasticSearch about 2×; the high storage cost limited their scaling to PB-scale corpora.
    • Application potential of FM-index: FM-index, commonly used in bioinformatics, can compress text while indexing; in theory the storage overhead on natural text can drop to 0.26× of the corpus, but previous implementations on natural language text covered only up to 13.4GB of data.
    • System implementation and contamination monitoring application: The paper develops the open-source system INFINI-GRAM MINI, reducing the index storage multiplier to 0.44×, building indexes on 83TB of internet text and conducting benchmark contamination analysis, and setting up a bulletin board system that continuously monitors benchmark contamination status.
  2. What related research exists?

    The authors review research on large-scale exact text search, FM-index, and benchmark contamination detection, noting that previous search systems had storage multipliers as high as 2× to 29×.

    Major related research in large-scale corpus retrieval and benchmark contamination detection includes the following directions:

    Large-scale exact text matching search

    • Suffix structures and commercial engines: Merrill et al. (2024) applied suffix automata to 1.3TB of text with a storage multiplier of 29×; Liu et al. (2024) applied suffix arrays to 12TB of text with a storage multiplier of 6×; Elazar et al. (2024) used ElasticSearch to index and analyze 35TB of text with a storage multiplier of about 2×. The authors note that these systems have excessive storage multipliers, making it difficult to scale to petabyte-scale corpora.
    • FM-index for natural language: Bevilacqua et al. (2022) previously used FM-index on a 13.4GB natural language dataset; Gog et al. (2014) open-sourced the SDSL library, but the authors note that its construction steps are single-threaded and queries require resident memory.

    FM-index theory and genomic applications

    • Classic data structures: Ferragina and Manzini (2000) proposed FM-index; Burrows et al. (1994) proposed BWT; Mäkinen and Navarro (2005) proposed Huffman-shaped wavelet trees to compress the BWT representation.
    • Parallel and bioinformatics extensions: Labeit et al. (2017) proposed parallel lightweight construction methods for wavelet trees and suffix arrays; Li (2014) and Wang et al. (2018) applied these to long-read retrieval in bioinformatics.

    Language model benchmark contamination detection

    • Substring and skip-gram matching: Soldaini et al. (2024) and Llama Team (2024) used n-gram or token overlap metrics; Singh et al. (2024) used longest common substring matching; Touvron et al. (2023) used skipgram matching and defined three thresholds: clean, suspicious, and dirty.
    • Collaborative contamination reporting: Sainz et al. (2024) aggregated contamination information on pretraining data shared by multiple parties.

    Baseline methods and evaluation data

    • The paper compares its index construction baseline against the SDSL library (Gog et al., 2014), and its retrieval latency baseline against infini-gram (Liu et al., 2024); system tests used DCLM-baseline (8.7GB files and 17TB full set) and the Pile (1.3TB). Benchmark contamination detection covered 24 mainstream benchmarks including MMLU, GSM8K, ARC, and SQuAD.

    The authors state that, compared with previous systems, this paper extends FM-index to an 83TB internet corpus, reduces the storage multiplier to 0.44×, and completes benchmark contamination analysis on larger-scale open-source text.

  3. How does the paper address this problem?

    The authors developed INFINI-GRAM MINI, a parallel indexing and disk-based query system based on FM-index, and established a contamination detection protocol combining substring matching and LLM review.

    The paper proposes the text retrieval system INFINI-GRAM MINI by improving the FM-index construction pipeline and combining it with on-demand external-memory querying, for internet-scale exact-match retrieval and benchmark contamination analysis.

    Index representation and data preprocessing

    The system builds the index directly on raw UTF-8 bytes without tokenization, fixing the alphabet size at σ = 256. For corpora containing many documents, the system uses the unused hexadecimal byte \xff in UTF-8 as a document boundary separator, concatenating all documents into a single byte string, while additionally saving a text offset file to record each document's starting position and metadata.

    Parallelized index construction and sharding

    The system parallelizes each construction stage of the FM-index:

    • Core component construction: adapts the parallel algorithm of Liu et al. (2024) to build the suffix array (SA) and BWT; uses the parallel algorithm of Labeit et al. (2017) to build the Huffman-shaped wavelet tree; rewrites the sampled suffix array (SA) and sampled inverse suffix array (ISA) construction from SDSL with multithreaded parallelization.
    • Sampling parameter selection: SA sampling interval set to a = 32, ISA sampling interval set to b = 64. The Huffman wavelet tree storage is (nH0 + 2σ log n) bits, with zero-order entropy H0 ≈ 2.1.
    • Sharded parallel processing: on a single compute node with 128 vCPUs and 2TiB memory, the very large corpus is split into independent shards of at most about 700GB and built in parallel.

    External-memory-based query engine

    To reduce memory usage, the system keeps index files on disk via memory mapping (mmap):

    • Frequency counting: uses backward search to perform the find operation to compute the query string's corresponding interval in the SA, with time complexity O(|Q|H0). It relies on the following LF mapping formula:
      LF(i) = C[c] + rank(c, i)
      This maps the i-th occurrence of character c in the BWT string L to the corresponding position in the sorted first column F.
    • Document reconstruction: first uses locate to find the original text position (complexity O(aH0)), combines with binary search over the offset file to find document boundaries, then calls reconstruct to rebuild the text (complexity O((b+d)H0), where d is the number of reconstructed bytes), using a multithreaded block reconstruction mechanism.

    Benchmark contamination detection and classification protocol

    For a test sample, extract the set S of all 50-character substrings with a step of 1 word, and compute the proportion of substrings appearing in the corpus:

    η = (∑s ∈ S 𝕀[count(s) > 0])/(|S|)

    Classify according to η as clean (η < 20%), suspicious (20% ≤ η < 80%), and dirty (η ≥ 80%). For samples judged dirty, extract the 50-character substring with the lowest frequency in the corpus plus 400 characters of context before and after, and call gpt-4o-mini to classify into four scenarios: Type 1 (question-answer verbatim), Type 2 (answer expressed in natural language), Type 3 (only the question without the corresponding answer), and Type 4 (false positive match).

  4. What experiments did the paper conduct?

    The experiments evaluated system construction and query efficiency, and calculated contamination rates for 24 benchmarks in an 83TB corpus, finding GSM8K contamination at 74.20% in a specific crawler.

    Experimental setup

    • Models under test: the paper's experimental evaluation targets 24 benchmarks and an 83TB text corpus, without running generative models on downstream tasks; in the dirty sample classification experiment, gpt-4o-mini is used as the LLM-as-a-judge model.
    • Evaluation corpora and benchmarks: corpora include the Pile (training set 1.308TB, validation set 1.4GB), DCLM-baseline (16.666TB), and 7 Common Crawl dumps from January to July 2025 (CC-2025-05 to CC-2025-30, totaling 65.085TB), with 83.059TB of text in total (Table 1). Benchmarks cover 24 test sets across 5 domains (Table 6).
    • Comparison baselines: system performance baselines are the SDSL library (index build speed and memory) and infini-gram (query retrieval latency).
    • Metric definitions: index storage multiplier (index size / corpus size), index build time (node-days or seconds), peak RAM (MB), query latency (seconds/milliseconds), substring overlap ratio η, dirty rate (proportion of samples with η ≥ 80%), and suspicious rate.
    • Review and sampling method: benchmarks with test set sizes greater than 1000 items are uniformly randomly downsampled to 1000 items (subtasks sampled proportionally); latency tests average 100 random queries per setting.

    Main results

    The table below shows dirty rates for 7 representative benchmarks across different corpora (from Table 2, values are percentages %):

    Swipe horizontally to read the table

    BenchmarkTest set sizePile-trainDCLM-baselineCC-2025-05CC-2025-21
    MMLU100013.2028.4013.5011.70
    GSM8K10000.005.005.0074.20
    AIME-2024300.000.0010.0040.00
    HumanEval1640.000.000.000.00
    ARC-Challenge10001.8034.1011.904.20
    SQuAD10002.8040.102.702.00
    HLE8810.000.300.100.00

    Note: the table lists representative benchmarks from each domain; full results for all 24 benchmarks are in the original paper's Table 2 and Table 7.

    • Widely used core benchmarks have high contamination rates: the authors note that in DCLM-baseline, MMLU's dirty rate reaches 28.40% (reported as 28.40% in Table 2 and 27.70% in the main text), and ARC-Challenge reaches 34.10% (stated as 32.6% in the main text), indicating that recently reported model capabilities may include a memorization component.
    • Corpus scale and time passage increase contamination: contamination rates are generally lower in the earlier Pile-train, while newer benchmarks are gradually contaminated in newer crawls; for example, AIME-2024 reaches a dirty rate of 40.00% in CC-2025-21 and GSM8K reaches 74.20%.
    • Clear domain differences: commonsense reasoning and reading comprehension benchmarks have higher contamination rates across corpora, while code benchmarks (e.g., HumanEval, LiveCodeBench) remain relatively clean in the tested corpora.

    System index build efficiency and throughput comparison

    • Small-scale corpus benchmark: on a single 8.7GB DCLM-baseline file, SDSL took 5,847 seconds to build with 74,807MB peak memory; INFINI-GRAM MINI took 324 seconds (18× speedup) with 23,742MB peak memory (3.2× reduction).
    • Large-scale corpus overall build: a single node with 128 vCPUs and 2TiB memory completed indexing of the entire 83.059TB corpus (137 shards) in 98.8 node-days, with a total index size of 36.884TB and an average storage multiplier of 0.44× (Table 1).
    • Authors' interpretation: the parallelization improvements allow the system to index PB-scale corpora at affordable hardware cost and time.

    Query and retrieval latency evaluation

    • Test setup and results: average latency of 100 queries tested on GCP SSD disks (80,000 IOPS, 1200 MB/s throughput) (Table 4). Short queries (|Q| ≤ 10) had latency under 0.4 seconds across all corpora; long queries (|Q|=1000) took 7.957 seconds on CC-2025-05 and 25.47 seconds on DCLM-baseline. Text reconstruction of d=100 bytes was under 2 seconds across corpora, and d=3000 bytes took 4.456 seconds on DCLM-baseline.
    • Comparison with suffix arrays: retrieving 10 bytes of text on Pile-train, infini-gram latency was 13ms and INFINI-GRAM MINI was 106ms (Table 5).
    • Authors' interpretation: query latency is determined by disk I/O, and more shards increase seek overhead; FM-index does not store original text contiguously, so document reconstruction latency is higher than with suffix arrays.

    Qualitative attribution analysis of contamination types

    • Test setup and distribution: gpt-4o-mini is used to classify dirty entries in Pile-train, DCLM-baseline, and CC-2025-05 into four categories (Section 4.3).
    • Classification statistics: Type 1 (question-answer verbatim) has the highest proportion, at 72.5%, 82.6%, and 58% in Pile-train, DCLM-baseline, and CC-2025-05 respectively; Type 2 (answer expressed in natural language) accounts for 2.1% to 6.2%; Type 3 (only the question without the answer) accounts for 10.9% to 30.2%; Type 4 (false positive short questions) accounts for 1% to 3.1%.
    • Authors' interpretation: the vast majority of dirty entries fully contain both the question and the answer, so models can obtain answers through rote memorization, highlighting the need for uncontaminated benchmarks and corpus decontamination.

    Other ablations and analyses

    • Stage-by-stage build time analysis (Table 3): using a single DCLM-baseline shard (667GB) as an example, SA+BWT took 29,543 seconds, wavelet tree 6,257 seconds, ISA sampling 2,659 seconds, alphabet 2,895 seconds, SA sampling 2,232 seconds, totaling 12.1 hours.
    • Effect of text duplication rate on build time: a Pile-train shard (653GB), due to a document duplication rate above 60%, took 41,710 seconds in the SA+BWT stage and 15.7 hours total for the shard, higher than DCLM-baseline (Section B).
    • Relationship between sampling rate and index size: with a=32, b=64, the index storage multiplier is 0.44×; if a, b are set to very large values, the index size limit is 0.26× of the corpus (Section 3.1).
  5. What are some points that can be further explored?

    The authors point out limitations such as document retrieval latency, multi-modal co-occurrence, and exact matching constraints. The actual experiments cover an 83TB corpus, 24 evaluation benchmarks, and four fine-grained contamination categories.

    Limitations and future directions noted by the authors

    • High document retrieval latency: FM-index does not store the original text as contiguous data blocks; retrieving a document requires character-by-character reconstruction and many random address reads, so reconstructing 3000 characters takes 4.5 seconds on DCLM-baseline; the authors note that optimization techniques such as disk page prefetching could be explored in the future (from Limitations).
    • Insufficient support for multi-pattern co-occurrence queries: mapping matches within a suffix array range back to original text positions in FM-index is too expensive, making it difficult for the system to support co-occurrence matching of multiple patterns (from Limitations).
    • Coverage limits of exact-match retrieval: the system currently supports only case-sensitive strict substring matching, which may fail to detect benchmark contamination instances with minor textual discrepancies (from Limitations).
    • Potential risks from corpus-inherent content: retrieved web text may contain bias, toxicity, or sensitive information (from Limitations).
    • Ongoing maintenance and downstream application expansion: the authors plan to continue building indexes on the latest Common Crawl dumps and updating the online monitoring bulletin board (from §4.4), and plan to explore applications such as task-specific dataset construction and training corpus cleaning and deduplication (from §4).

    Experimental coverage

    • Indexed corpus coverage: actually built 3 corpora with 10 subsets in total (Pile-train, Pile-val, DCLM-baseline, and 7 Common Crawl dumps from January to July 2025), with total indexed text of 83.059TB (Table 1).
    • Evaluation benchmark coverage: benchmark contamination analysis covered 24 public evaluation benchmarks across 5 domains; datasets with test sets larger than 1000 items were randomly downsampled to 1000 items (Table 2, Table 6).
    • Fine-grained classification evaluation scope: LLM-assisted classification experiments were conducted only on dirty samples judged in three corpora, Pile-train, DCLM-baseline, and CC-2025-05, using gpt-4o-mini for judgment (§4.3, App. §I).
    • Query latency hardware evaluation setup: latency benchmarks were based on a single GCP n2-highcpu-64 node with pd-balanced SSD storage (80,000 IOPS, 1200 MB/s throughput), testing 8 query lengths and 7 reconstruction lengths, with 100 repetitions per group (App. §C, Table 4).
    • Unreported information: the paper does not report quantitative changes in specific model evaluation scores after removing contaminated samples from benchmarks, nor does it report agreement statistics between LLM-as-a-judge judgments and human expert annotations.
  6. Summarize the main content of the paper

    The authors developed a text retrieval system based on FM-index and measured GSM8K contamination at 74.20% in a specific crawler, and set up a monitoring bulletin board.
    • Work positioning: This study addresses the problem of excessive storage overhead in exact matching search over massive pretraining text, building a large-scale retrieval and contamination monitoring system INFINI-GRAM MINI based on the compressed index structure FM-index.
    • Core challenge: Language model evaluation relies on uncontaminated test sets, but previous exact search systems with storage multipliers of 2× to 29× limited their feasibility for systematic screening across tens of TB or even PB-scale internet training corpora.
    • System architecture: It builds a sampled suffix array and a BWT compressed with Huffman wavelet trees directly on raw UTF-8 bytes, achieving 18× build acceleration through sharded multi-threaded parallelization, and supports low-memory on-demand retrieval via disk memory mapping.
    • Main experimental results: The system indexed an 83.059TB corpus with a 0.44× storage multiplier (total index size 36.884TB, Table 1); on an 8.7GB corpus, peak memory was reduced by 3.2× compared to SDSL; contamination detection showed MMLU has a dirty rate of 28.40% in DCLM-baseline, and GSM8K reaches 74.20% in CC-2025-21 (Table 2); among dirty entries, 58% to 82.6% are questions and correct answers appearing verbatim (Section 4.3).
    • Conclusion and implications: The authors point out that benchmark contamination substantially impacts the objective evaluation of current large language model capabilities, and that direct memorization in training data may lead to inflated estimates of models' true reasoning abilities; they call on the community to prioritize training data decontamination and leakage-resistant benchmark design, and have open-sourced an online bulletin board that continuously tracks contamination dynamics.
Read originalarxiv.org