Search From the Start: Search-Native Pretraining for Language Models

Media reports Hugging Face Papers Source language: Chinese

This paper proposes Search-Native Pretraining, augmenting pretraining corpora with web-search queries and responses to teach language models search capabilities from…

Full text

Search From the Start: Search-Native Pretraining for Language Models

Kaustubh Ponkshe* Gyung Hyun Je* Stefan Taga

Colin Raffel Martin Jaggi

EPFL University of Toronto *Equal contribution. ††thanks: Corresponding authors: kaustubh.ponkshe@epfl.ch and jayje@cs.toronto.edu.

Abstract

Modern language models (LMs) are increasingly deployed with access to search tools at inference. Yet pretraining remains predominantly focused on predicting static text, with search capabilities typically introduced during post-training. We propose Search-Native Pretraining as a practical route to teach search capability during pretraining from ordinary text corpora. Specifically, we augment pretraining corpus at scale with web-search queries and retrieve web response using a local index. Training on this augmented corpus teaches models to generate search calls and incorporate retrieved evidence during language modeling. Across Wikipedia and DCLM-Edu corpora and 360M to 3.3B parameter scales, search-pretrained models (QueryLM) show improved performance on knowledge-intensive tasks and higher steerability toward the retrieved evidence. Crucially, their advantage persists after supervised fine-tuning of both search-pretrained and conventionally pretrained models, indicating that the tested post-training procedures do not fully recover the capabilities developed during pretraining. Throughout our experiments, we find that a 1.4B QueryLM consistently beats or matches the performance of a FLOP-matched 3.3B baseline model across all knowledge intensive tasks. These results establish search-pretraining as a practical way to develop foundational search capabilities during pretraining. Training artifacts are available at .

Figure 1: QueryLM is better at searching for and using evidence. (a) After Search-Native Pretraining, QueryLM with search outperforms the compute-matched baseline and the largest open-weight base models (SmolLM3-3B, Qwen2.5-3B) without search, despite their orders of magnitude more pretraining compute. (b) QueryLM keeps higher accuracy on eight knowledge-intensive QA tasks after Standard SFT of both models. (c) After Search SFT, QueryLM more often follows counterfactual evidence that contradicts established facts (LLM-judged answers on the same eight tasks).

1 Introduction

Language models (LMs) have finite capacity to store factual knowledge in their parameters (Morris et al., 2025; Huang et al., 2026a), which can limit their performance on knowledge-intensive tasks. This poses a particular challenge for smaller models, as facts that cannot be inferred from general patterns must be memorized during pretraining (Allen-Zhu & Li, 2024). Even when successfully encoded, knowledge in weights can become outdated as real-world facts change (Vu et al., 2023). Teaching an LM to search address these limitations by allowing factual knowledge to remain externally retrievable, with sources that can be updated without retraining the model. Prior work has explored several ways to incorporate retrieved knowledge at inference time (Lazaridou et al., 2022; Nakano et al., 2022; Parisi et al., 2022; Shuster et al., 2022; Asai et al., 2023; Schick et al., 2023; Yao et al., 2023; Jin et al., 2025). These capabilities are typically introduced during post-training (OpenAI et al., 2025; Dong et al., 2026; Kang et al., 2026), after the model has been pretrained to predict the next token without access to search.

However, recent work demonstrates the benefits of early exposure to capability-relevant data during pretraining Zhang et al. (2025); Baek et al. (2026); Minder et al. (2026). Yet scaling such data to develop new capability during pretraining remains challenging, often requiring practitioners to rely on limited or synthetically generated data Gunasekar et al. (2023); Shao et al. (2024). We therefore ask:

“Can ordinary pretraining documents be augmented at scale to teach a downstream capability such as search, while preserving the original next-token prediction objective?”

In particular, we want an LM to use search to access diverse and evolving knowledge sources, such as the internet. To teach the search ability during pretraining, we augment the training corpus with inline web-search tool calls and corresponding web-retrieved evidence that help predict the original document continuation. These augmentations demonstrate when to seek information beyond the available text, what to search for, and how to use the returned evidence to predict the continuation. Together, they form our Search-Native Pretraining approach.

Figure 2: Search-Native Pretraining pipeline overview. (1) We augment training documents with inline search queries and corresponding search results, intended to contain useful knowledge for predicting original document continuation. (2) We train on (1), computing loss only on original document tokens and search queries (green), while search results are masked (gray). (3) During inference, QueryLM generates search queries to retrieve relevant information from an external knowledge base.
Figure 2: Search-Native Pretraining pipeline overview. (1) We augment training documents with inline search queries and corresponding search results, intended to contain useful knowledge for predicting original document continuation. (2) We train on (1), computing loss only on original document tokens and search queries (green), while search results are masked (gray). (3) During inference, QueryLM generates search queries to retrieve relevant information from an external knowledge base.

Figure 2: Search-Native Pretraining pipeline overview. (1) We augment training documents with inline search queries and corresponding search results, intended to contain useful knowledge for predicting original document continuation. (2) We train on (1), computing loss only on original document tokens and search queries (green), while search results are masked (gray). (3) During inference, QueryLM generates search queries to retrieve relevant information from an external knowledge base.

We construct search-augmented pretraining corpora from the knowledge-rich Wikipedia corpus and DCLM-Edu, which represents a realistic pretraining setting. The augmented DCLM-Edu corpus contains over 100B tokens of document text, search queries, and retrieved responses. Using these corpora, we train QueryLM models from scratch at scales from 360M to 3.3B parameters. When search is available, QueryLM improves on knowledge-intensive tasks compared with FLOP-matched baselines (Section 5.1). Our 400M model with search also exceeds the average QA performance of SmolLM3-3B evaluated without search, despite using approximately 6,700 times less pretraining compute (Figure 1). The advantage over FLOP-matched baselines persists after both models undergo search-augmented fine-tuning, showing that the tested post-training recipe does not fully recover the benefit of learning search during pretraining (Section 5.1). Beyond answering more questions correctly, QueryLM more readily adjusts its predictions to supplied evidence, including evidence that contradicts facts seen during training (Section 5.2). General capabilities remain broadly comparable after search fine-tuning (Section 5.3), while our ablations examine how retrieval quality, response length, and insertion frequency affect performance and training cost (Section 6). These results support Search-Native Pretraining as a scalable approach to teaching models to search for and use external information from the start of training.

2 Related Work

LM knowledge retention.

Prior work has explored the limits of factual knowledge acquisition in language model parameters (Kandpal et al., 2023; Morris et al., 2025), highlighting challenges due to task feature interference (Huang et al., 2026a), reduced model plasticity (Kim et al., 2025; Springer et al., 2025), and forgetting (Liao et al., 2024; Luo et al., 2025). These challenges persists when the acquired knowledge becomes outdated and requires post-hoc editing (Lazaridou et al., 2021; Gu et al., 2024). Proposed mitigation includes data selection to prioritize learnable facts (Mindermann et al., 2022; Ye et al., 2026), modified parameter updates for reduced interference and easier editing (Wang et al., 2023; Ghosal et al., 2025), increasing model plasticity (Chen et al., 2024), and complementing parametric knowledge with externally retrieved information (discussed below). Building on these efforts, we address the limitation of parametric knowledge by pretraining an LM to fill in the knowledge gap through search and ground its generation on retrieved passages.

External knowledge base.

Prior work improves LMs on knowledge-intensive tasks by equipping them with external knowledge or tools. Inference-time or post-training approaches provide access to API-based tools or search engine during generation (Lazaridou et al., 2022; Nakano et al., 2022; Parisi et al., 2022; Shuster et al., 2022; Asai et al., 2023; Schick et al., 2023; Yao et al., 2023; Jin et al., 2025). Among these work, Toolformer (Schick et al., 2023) is particularly relevant to our approach, as it injects tool call demonstrations inline and fine-tunes an LM to issue relevant tool calls. Pretraining-focused efforts have explored jointly trained retrievers (Guu et al., 2020) or a specialized layer to attend to retrieved information (Borgeaud et al., 2022). More recent approaches, such as LMLM (Zhao et al., 2025) and Co-LMLM (Feldman et al., 2026), build an explicit entity-based key-value stores from training or downstream task data and trains an LM to query these stores. Unlike past methods, QueryLM learns to issue flexible search queries during pretraining from scratch, without architectural modification or an explicit entity-based key-value store.

Pretraining data augmentation.

Previous studies have shown the benefits of introducing downstream capability-relevant data earlier during pretraining (Akter et al., 2025b; Zhou et al., 2026), encoding desired behavior such as instruction-following ability (Cheng et al., 2024), reduced toxicity (Maini et al., 2025), higher steerability (Gao et al., 2025), improved reasoning (Akter et al., 2025a; Ruan et al., 2025), knowledge synthesis (Huang et al., 2026b). We similarly find that early exposure to search demonstrations in Search-Native Pretraining yields benefits that persist through post-training.

3 Search-Native Pretraining

Search-Native Pretraining trains a language model to issue search queries and incorporate retrieved evidence into subsequent generation. We construct demonstrations of these interactions by augmenting the training documents with search queries and externally retrieved evidence, while preserving the original document text.

Figure 3: Document annotation example with inline search queries and retrieved documents.

3.1 When and What to Search

For each document, we identify a set of search query insertion points 𝒜={a1,…,ak}\mathcal{A}=\{a_{1},...,a_{k}\}, each aia_{i} separating a prefix pip_{i}, which sets the context motivating a search, from a suffix sis_{i}, the original document continuation. A good insertion point follows the prefix pip_{i} that naturally motivates a search query qiq_{i}, containing specific and relevant keywords from pip_{i} to retrieve useful context rir_{i} (Figure 3). We denote the collections of queries and retrieved responses as Q={qi}i=1kQ=\{q_{i}\}_{i=1}^{k} and R={ri}i=1kR=\{r_{i}\}_{i=1}^{k}, respectively.

Extending prior work (Zhao et al., 2025), which places insertion points before an entity’s associated value (e.g., between “Dante Alighieri was born in” and “May 1265”), we consider more general insertion locations, such as immediately after a specific term mention without a linked value (e.g., placed after “Dante Alighieri ”) or positions where relevant information depends on distant context (e.g., between “Dante Alighieri, […], originally titled his masterwork” and “La Commedia”). We use an LM to identify suitable insertion points and generate corresponding search queries. To efficiently annotate the pretraining corpus at scale, we first fine-tune a small annotator model (MϕM_{\phi}) and then use the trained annotator to augment the full corpus.

Annotator model.

We create a small search-augmented dataset (𝒟seed\mathcal{D}_{\mathrm{seed}}) from an initial pool of 10,000 Wikipedia documents, annotated using GLM-5.2 (GLM-5-Team et al., 2026) as the teacher model. We prompt the teacher to identify insertion points before specific facts that could benefit from external retrieval, such as names, dates, and quantities.

The teacher first identifies candidate insertion locations using the entire document but subsequently generates a search query given only the corresponding left context. Query generation therefore uses the same available text as at inference. To remove insertions with failed or empty search result, we retrieve and clean search responses for each search query (process detailed in Section 3.2). Finally, we fine-tune Gemma 4 E4B (Gemma Team et al., 2026) on 𝒟seed\mathcal{D}_{\mathrm{seed}} to produce the search query annotator, MϕM_{\phi}. Further details on annotator training are given in Section A.1.

Annotating pretraining corpus.

For efficient search query insertion at pretraining scale, we process each sequence xx of length TT with MϕM_{\phi}, the fine-tuned annotatir model, in a single causal forward pass and compute query insertion scores following each ii-th sequence token xix_{i} as

πi(x)=Pr(<|WEB-QUERY>∣x1:i),i=1,…,T,\pi_{i}(x)=\Pr\left(\texttt{<|WEB-QUERY>}\mid x_{1:i}\right),\quad i=1,\ldots,T,

where πi​(x)\pi_{i}(x) is the probability of inserting a search query immediately after token xix_{i}. Positions with πi​(x)\pi_{i}(x) exceeding a threshold τ∈[0,1]\tau\in[0,1] form the final insertion set 𝒜={i∈{1,…,T}∣πi​(x)≥τ}={a1,…,ak}\mathcal{A}=\{i\in\{1,\ldots,T\}\mid\pi_{i}(x)\geq\tau\}=\{a_{1},\ldots,a_{k}\}. Candidate insertion positions can therefore be scored in parallel within each document. Our approach for sampling search insertion points refer to augmentation strategy in Schick et al. (2023). Finally, MϕM_{\phi} generates a query qiq_{i} for each aia_{i} given corresponding prefix pip_{i} until the closing delimiter. These queries are then passed to the search response retrieval pipeline (Section 3.2).

Insertion filtering.

For pretraining corpus, we use τ=0.05\tau=0.05 as an initial filtering method to restrict the number of search queries inserted per document and drop low-quality search queries. We then do additional filtering using ROUGE-1 F1 overlap between the retrieved response rir_{i} and the original continuation sis_{i}, using lexical overlap as a proxy for relevance. The filtering threshold values and the filtering protocol are given in Section A.1.

3.2 Simulating Web Response During Pretraining

To simulate a realistic and cost-efficient web-response, we use BM25 index over Sphere (Piktus et al., 2022), a public dataset containing a broad collection of 134M web documents. We consider candidate indexes over different corpus based on retrieval coverage and storage requirements, detailed in Section 6.2 and Section A.1.

For each search query qiq_{i}, we retrieve the top-10 scoring raw passages and select sentences with the most keyword stem overlap with the query, producing the web response rir_{i} used in training corpus annotation. The choice of how much retrieved information to retain introduces a trade-off: shorter search response reduces training overhead but may remove relevant information, and cleaning the raw passage using an LLM may help select more query-relevant information but incurs higher data preparation cost. We evaluate the impact of training with web-response of different lengths and cleaning approach in Section 6.3 and Section 6.4.

3.3 Pretraining Objective

We train language models autoregressively on the annotated pretraining corpus. Given an annotated sequence x~\tilde{x} of length T~=|x~|\widetilde{T}=|\tilde{x}| and indices ℐℛ⊆{1,…,T~}\mathcal{I_{R}}\subseteq\{1,\ldots,\widetilde{T}\} for web-response tokens (i.e., rir_{i} and <|WEB-RESPONSE|> tokens), the training objective is

ℒ(θ)=−∑t=1T~𝟏[t∉ℐℛ]logpθ(x~t∣x~<t).\mathcal{L}(\theta)=-\sum_{t=1}^{\widetilde{T}}\mathbf{1}[t\notin\mathcal{I_{R}}]\log p_{\theta}(\tilde{x}_{t}\mid\tilde{x}_{<t}).

The model therefore is trained with a next-token prediction objective on the original document text, search queries qiq_{i}, and the special token <|WEB-QUERY|>, while masking the loss on web response tokens rir_{i}. This allows the model to condition the original document continuation on the web-response but avoids explicitly training it to reproduce the web response.

4 Experimental Setup

4.1 Pretraining Setup

Pretraining corpora.

We pretrain models using Search-Native Pretraining on two corpora: Wikipedia and DCLM-Edu (Allal et al., 2025). Wikipedia provides a compact, knowledge-rich setting for controlled experiments. DCLM-Edu extends the study to more diverse web text, testing whether the benefits persist beyond encyclopedic documents. Both corpora use the annotation pipeline described in Section 3, with the same annotation model. See Appendix Section A.2 for data preprocessing details.

Baselines.

For each of QueryLM across varying scales, we pretrain a baseline model with the same architecture on original document text without search augmentation. We approximately match each baseline’s pretraining FLOPs to the corresponding QueryLM, including computation on retrieved response tokens despite their exclusion from the loss during Search-Native Pretraining (see Section A.2 for detail). We include LMLM (360M) and Co-LMLM (400M) models off-the-shelf as our baselines. Our 360M-QueryLM trained on Wikipedia provides the closest comparison with LMLM, and our 400M-QueryLM (overtrained) on DCLM-Edu is compared with Co-LMLM trained on FineWeb.

Model architectures and training budgets.

For Wikipedia, we train decoder-only Transformers from scratch with 360M parameters using the SmolLM2 configuration (Allal et al., 2025), to have the closest match to LMLM baseline. Wikipedia QueryLM is trained on 33.4B tokens total over four epochs, with 4.01B tokens from original document tokens and 4.33B from search augmentation per epoch.

For DCLM-Edu, we train nanochat configurations from scratch at 400M, 1.4B, and 3.3B parameters, excluding value embeddings. The 400M, 1.4B and 3.3B QueryLMs are trained on 10.6B, 44.0B, and 99.8B tokens, 6.8B, 28.2B and 64.0B tokens from original document tokens (approx. 20 per parameter). We include a deliberately over-trained 400M DCLM-Edu QueryLM (65.1B document tokens, 101.5B processed) to support comparison with Co-LMLM trained on FineWeb. Further architecture details, optimization settings, and training budgets are given in Section A.2.

4.2 Supervised Fine-Tuning

After pretraining, we fine-tune both QueryLM and the FLOP-matched baselines to develop user-assistant conversation behavior. We use two different supervised fine-tuning (SFT) mixtures to answer different questions. First, we perform standard SFT on a subsample of the Dolci dataset, which includes a search mixture, following the SFT setup of Olmo 3 (Olmo et al., 2026). Since many of the search traces in Dolci exceed our context length, we add our own search traces on SmolTalk conversations in an equal ratio. This setup tests whether QueryLM retains its advantage in the typical pipeline, where search is only introduced in post-training. Second, we introduce Search SFT, which uses a much higher proportion of search-augmented data. The Search SFT mixture contains 52,806 conversations from SmolTalk (Allal et al., 2025) and SmolTalk2, covering general chat skills and tool calling. We additionally augment selected SmolTalk conversations with search interactions generated by our annotation model. The main goal is to evaluate whether the advantages Search-Native Pretraining can be fully recovered in post-training with a search-heavy data distribution. Further training details are provided in Section A.3.

4.3 Evaluation

Tasks.

We consider TriviaQA (Joshi et al., 2017), NQ-Open (Kwiatkowski et al., 2019), PopQA (Mallen et al., 2023), and WebQuestions (Berant et al., 2013) as factual knowledge probing tasks (“Factual QA”), as well as HotpotQA (Yang et al., 2018), 2WikiMultiHopQA (Ho et al., 2020), MuSiQue (Trivedi et al., 2022), and Bamboogle (Press et al., 2023) for multi-hop question answering (“Multi-hop”) using the Search-R1 evaluation suite (Jin et al., 2025). To assess factual grounding, we use on FreshQA (Vu et al., 2023) for time-sensitive factual question answering, and HaluEval (Li et al., 2023) and RAGTruth (Niu et al., 2024) for faithfulness to supplied evidence in hallucination-prone settings. Lastly, we evaluate QueryLM on general language understanding and commonsense reasoning benchmarks. Task details are included in Section A.4.1.

Prompting.

The base models are given four-shot search demonstration for all QA tasks. LMLM and Co-LMLM emit their own search queries to retrieve relevant values, and our FLOP-matched baseline uses its corresponding QueryLM’s search queries and retrieved results. After Search SFT, both QueryLM and FLOP-matched baselines are evaluated zero-shot and use their own search queries. Search is triggered for both base and SFT models with an injected <|WEB-QUERY> in the beginning of model generation. Both base and SFT models are given budget of 1 look-up for factual QA and 2 look-ups for multi-hop QA. We report % correct answer is contained given the 24-token generation budget for base models, and LLM-judged accuracy with 64 token generation budget for SFT models. Prompt examples are included in Section A.4.3. For each metric, we report the 95% confidence intervals with bootstrap over questions.

Retrieval source.

For fair comparison with LMLM, which indexes its Wikipedia training corpus as the external knoweldge base, our Wikipedia-trained QueryLM (360M) uses BM25 index over Wikipedia. Similarly, our DCLM-Edu-trained QueryLM (400M) uses BM25 index over Fineweb-Edu and Wikipedia to match Co-LMLM’s retrieval corpus. However, QueryLM can flexibly switch to a web-like retrieval source, we report our main results including retrievals from Tavily, an API-based search engine. In Section 6.2, we demonstrate that switching to a more realistic retrieval source like Tavily improves the model performance for both QueryLM and the FLOP-matched baselines.

5 Results

5.1 Search pretraining has advantage in knowledge intensive tasks

Figure 4: Base model performance on knowledge-intensive QA (avg. over eight tasks). 360M and 400M (overtrained) base QueryLM with LMLM and Co-LMLM.

Figure 5: Base and SFT model performance on knowledge-intensive QA (avg. over eight tasks) across scale and training corpus. Left: base models. Middle: after Search SFT. Right: after standard SFT (Dolci mixture). Per-task scores in Appendix Table 9, Table 10.

Base models.

We evaluate QueryLM on the eight knowledge-intensive QA tasks and report the average performance compared against our baselines.

QueryLM outperforms both LMLM and Co-LMLM when using Tavily as retrieval source (Figure 4). With matched retrieval sources, DCLM-Edu-trained QueryLM matches the performance of Co-LMLM. Wikipedia-trained QueryLM slightly underperforms LMLM, despite outperforming it on six of eight tasks, with exception being PopQA and WebQs. The structural similarity and potential factual overlap between PopQA, constructed from Wikidata knowledge triples, and LMLM’s Wikipedia-derived knowledge store may partially explain its strong performance on PopQA. Across model scales and pretraining corpora, QueryLM consistently outperforms the FLOP-matched baseline (Figure 5, left). Full results comparing open-weight base models and QueryLM from Figure 1-(a) are reported in Appendix, Table 8.

SFT models.

Since our method can be replicated in post-training, we evaluate the advantage of search-pretraining by fine-tuning QueryLM and FLOP-matched baselines on search-augmented data. With standard SFT, QueryLM retains much of its base performance (Figure 5, right). Even under the Search SFT recipe, with a high proportion of search demonstrations, fine-tuned baselines do not fully recover the benefit of search pretraining, especially at smaller model scales (Figure 5, middle). We hypothesize that Search-Native Pretraining is particularly beneficial for smaller models, as learning to search and ground its predictions on retrieved results compensates for their limited parametric knowledge. We further analyze the performance gap attributable to context grounding ability (Section 5.2) and search query writing quality (Section 6.1).

5.2 QueryLM uses retrieved context to update its answers

To investigate whether QueryLM grounds its predictions on retrieved evidence than on facts stored in its parameters, we measure its sensitivity to supplied evidence in a controlled setting, then evaluate whether the increased sensitivity translates to improvement on downstream tasks.

Updating knowledge based on counterfactual context.

(a) Model preference for facts seen during training. Positive margins favor the original value, and negative margins favor the counterfactual. Counterfactual axis is reversed.

(b) Model accuracy (LLM-judged) on the eight knowledge-intensive QA tasks.

Figure 6: DCLM-Edu-trained SFT QueryLM’s fact preference under no evidence, supporting evidence, and counterfactual evidence settings. No evidence: higher y-axis value indicates preference for original ground-truth facts. Original evidence and Counterfactual evidence: higher y-axis value indicates preference for facts supported by the evidence.

We first sample 1000 stated facts in DCLM-Edu training documents and measure the model preference between ground-truth and plausible-but-wrong (“counterfactual”) values, under retrievals supporting either options. For instance, we test if the counterfactual retrieval that falsely identifies Albert Einstein’s birth-year as 1889 (correct: 1879) increases the model’s preference for 1889. We use GPT-oss-120B (OpenAI et al., 2025) to edit the original ground-truth relevant evidence to instead support the counterfactual values. Model preference is measured using the log-probability difference between the original and counterfactual values, log⁡P⁡(original)−log⁡P⁡(counterfactual)\log P(\text{original})-\log P(\text{counterfactual}).

We find that both supporting and counterfactual evidence increase QueryLM’s preference for the corresponding values more strongly than for the baseline models (Figure 6(a)). See Section A.5.2 for detailed setup and discussion.

Generation grounded on relevant evidence.

We further evaluate QueryLM’s context-following ability across the eight QA tasks using either the original ground-truth supporting and the edited counterfactual context (Figure 6(b)). To assess context following ability independently of query generation ability, we hold search queries fixed across QueryLM and FLOP-matched baselines. Retrieval uses BM25 over Sphere. Details of setting are discussed in Section A.5.2.

QueryLM performs worse in closed-book setting, but is better at predicting the answer supported by supplied evidence, especially under counterfactual contexts. These results suggest that QueryLM relies more strongly on retrieved evidence. Additional evaluations on factual-groundedness benchmarks, including FreshQA, HaluEval, and RAGTruth, show similar trends (Appendix, Section A.5).

5.3 General capabilities

For completeness, we evaluate QueryLM on general language understanding and commonsense reasoning in closed-book setting (Appendix Section A.5.3, Table 13). QueryLM base model slightly underperforms the FLOP-matched baselines, whereas the two are comparable after SFT, with mixed results across tasks. Search pretraining preserves general capabilities, but its advantage on search-based tasks does not translate into consistent improvements in closed-book reasoning.

6 Discussion

6.1 How effective are QueryLM’s search queries?

We assess QueryLM and FLOP-matched baselines’ search query generation ability by comparing their downstream task performances using their own queries after Search SFT versus queries generated by a stronger model, Qwen3-30B-A3B-Instruct-2507 (Team, 2025). This allows us to assess the effectiveness of self-generated queries, and whether stronger query generation can narrow the performance gap between QueryLM and baselines. Both settings use BM25 over Sphere for retrieval.

Across model scales, replacing self-generated queries with Qwen-generated queries results in smaller performance gains for QueryLM than for the FLOP-matched baselines (Figure 7), suggesting that QueryLM generates more effective search queries. When the query source is fixed, QueryLM also outperforms the baselines at both 400M and 1.4B scales. However, this trend reverses at the 3.3B scale, potentially due to stronger parametric knowledge and in-context reasoning ability at a larger scales.

Figure 7: Effect of query strength on SFT models QA performance (avg. LLM-judged acc. (%)).

6.2 How does retrieval source affect QueryLM performance?

Figure 8: Effect of retrieval source on base model QA performance (avg. answer-contained score).

Using model-generated queries, we compare retrieval using BM25 over Wikipedia, BM25 over Sphere, and open-web search through Tavily. These settings vary in corpus coverage and retrieval backend, allowing us to assess how the choice of search source affects downstream accuracy. Tavily gives the highest accuracy in this comparison, motivating its use for downstream evaluation. For pretraining data annotation, however, API costs accumulate over millions of documents. We therefore use local BM25 retrieval over Sphere during annotation. Raw values and trends for SFT models are in Appendix Section A.5.4.

6.3 How does training-time search context affect performance?

Held-out document PPL QA with search

Pretraining context Compute No context Orig. Live Open-domain Multi-hop General

Standard (none) 1.00 7.57 10.01 9.70 3.2† 0.2† 35.1

QueryLM (default) 1.04 7.96 7.44 7.78 12.2 5.7 33.7

LM-summarized 0.79 7.60 7.09 7.47 8.3 0.5 34.9

Oracle 1.04 10.17 5.03 10.07 9.7 4.0 31.8

Table 1: Effect of the pretraining context (Wikipedia, 360M; same documents and queries, only the response text differs). †baseline evaluated closed book.

We construct two search response variants for training data augmentation using an LM summarizer (Gemma 4 E4B): summaries of raw retrieved documents (“LM-summarized”) and summaries of the training documents themselves, which contain explicit ground-truth value asked for by the search query (“oracle”). The former tests the benefit of cleaner retrieval context, while the latter examines the effect of training on highly relevant evidence and model’s generalization beyond this controlled setting. We compare both against the original Wikipedia-trained 360M QueryLM and a FLOP-matched baseline (“Standard”).

Without search context (”No context”), Oracle exhibits the highest perplexity on 400 held-out documents’ original tokens, followed by QueryLM and LM-summarized (Table 1). Perplexity drops slightly across all variants with the models’ inference-time queries and context (“Live”). With the original search annotations (“Orig.”), both Oracle and LM-summarized perplexity drops below QueryLM’s, indicating greater reliance on the retrieved context. However, their stronger context reliance does not translate to improved performance on downstream QA (“QA with search”) and general benchmark (“General”), suggesting limited generalization to a different retrieval setting (BM25 retrieval over Sphere).

6.4 Can we reduce training-time search response length and query frequency?

Held-out document PPL QA with search

Augmentation Blocks/doc Compute No context Gold Live Open-domain Multi-hop General

Standard (none) – 1.00 7.57 10.01 9.70 3.2† 0.2† 35.1

QueryLM (default) 8.2 1.04 7.96 7.44 7.78 12.2 5.7 33.7

50-char responses 3.8 0.55 7.90 7.85 7.95 8.2 0.9 33.8

Top-2 queries/doc 2.0 0.57 7.94 7.73 7.90 5.6 1.2 33.5

Table 2: Effect of context length and query frequency (Wikipedia, 360M). Blocks/doc: inserted query–response blocks per held-out document. Compute: pretraining FLOPs relative to the compute-matched baseline. Other columns as in Table 1. †baseline evaluated closed-book.

Longer responses and more frequent searches increase the amount of retrieved information available during pretraining, but also increase training cost. We examine two ways to reduce this overhead: shortening the retrieved context and limiting the number of query insertions.

In the first variant, we limit the response length from 600 (our default) to 50 characters, which reduces the added sequence length and may also remove information useful for predicting the continuation. In the second variant, we retain only the two insertions per document with the highest response-continuation overlap. We find that both variants substantially reduce the amount of search augmentation while still retaining reasonable search capability useful for downstream performance (Table 2). These results suggest that context length and insertion frequency offer ways to trade performance for lower training cost.

As the Top-2 variant is the most practical and cost-effective alternative to our default augmentation, we test the approach at scale by training a FLOP-matched 3.3B QueryLMTop-2\text{QueryLM\kern 0.59998pt\raisebox{2.79857pt}{\includegraphics[height=4.30554pt]{figures/icons/search.pdf}}}{}_{\text{Top-2}}. On knowledge-intensive QA, QueryLMTop-2\text{QueryLM\kern 0.59998pt\raisebox{2.79857pt}{\includegraphics[height=4.30554pt]{figures/icons/search.pdf}}}{}_{\text{Top-2}} performance falls between QueryLM and Standard after both Search SFT and standard SFT (Table 10), while on general capabilities it matches Standard within the confidence intervals (Table 13). QueryLMTop-2\text{QueryLM\kern 0.59998pt\raisebox{2.79857pt}{\includegraphics[height=4.30554pt]{figures/icons/search.pdf}}}{}_{\text{Top-2}} therefore offers a reasonable trade-off between downstream performance and annotation cost.

6.5 What is the cost of Search-Native Pretraining?

The annotation phase scans the training corpus of size DD and adds AA-many queries of length ℓq\ell_{q}, adding A​ℓA\ell more tokens to training corpus, where ℓ\ell is the size of query and response tokens. The data preparation is done once per corpus and can be reused across models. During inference, cost scales linearly with the number of search-calls, adding k​ℓk\ell for kk rounds of search and retrievals. Number of search queries (AA), tokens per query (ℓ\ell), and the number of queries at inference (kk) are hyperparameters that can be tweaked to reduce cost, whose impact is discussed in Section 6.3 and Section 6.4. See Table 14 in Appendix Section A.5.5 for a summary table.

7 Conclusion

Search-Native Pretraining aims to teach LMs two complementary skills during pretraining: what to search for and how to use retrieved evidence to continue generation, alongside the standard language modelling objective. Our results show that QueryLM acquires these capabilities, achieving higher performance on knowledge-intensive tasks with search and grounding its predictions more effectively in supplied evidence. The difference in the closed-book evaluations shows that the models are also successful in reframing much of the memorization in pretraining through the search objective. Together, these findings suggest that integrating search into pretraining can complement smaller models’ parametric memory by training them to access and use external knowledge effectively.

Acknowledgments

We acknowledge support by the Swiss AI Initiative visiting PhD fellowships, as well as by armasuisse S+T research contract AR-CYD-C-033.

References

Akter et al. (2025a) Syeda Nahida Akter, Shrimai Prabhumoye, John Kamalu, Sanjeev Satheesh, Eric Nyberg, Mostofa Patwary, Mohammad Shoeybi, and Bryan Catanzaro. Mind: Math informed synthetic dialogues for pretraining llms, 2025a. URL https://arxiv.org/abs/2410.12881.

Akter et al. (2025b) Syeda Nahida Akter, Shrimai Prabhumoye, Eric Nyberg, Mostofa Patwary, Mohammad Shoeybi, Yejin Choi, and Bryan Catanzaro. Front-loading reasoning: The synergy between pretraining and post-training data, 2025b. URL https://arxiv.org/abs/2510.03264.

Allal et al. (2025) Loubna Ben Allal, Anton Lozhkov, Elie Bakouch, Gabriel Martín Blázquez, Guilherme Penedo, Lewis Tunstall, Andrés Marafioti, Hynek Kydlíček, Agustín Piqueres Lajarín, Vaibhav Srivastav, et al. Smollm2: When smol goes big – data-centric training of a small language model, 2025. URL https://arxiv.org/abs/2502.02737.

Allen-Zhu & Li (2024) Zeyuan Allen-Zhu and Yuanzhi Li. Physics of language models: Part 3.3, knowledge capacity scaling laws, 2024. URL https://arxiv.org/abs/2404.05405.

Asai et al. (2023) Akari Asai, Zeqiu Wu, Yizhong Wang, Avirup Sil, and Hannaneh Hajishirzi. Self-rag: Learning to retrieve, generate, and critique through self-reflection, 2023. URL https://arxiv.org/abs/2310.11511.

Baek et al. (2026) Christina Baek, Ricardo Pio Monti, David Schwab, Amro Abbas, Rishabh Adiga, Cody Blakeney, Maximilian Böther, Paul Burstein, Aldo Gael Carranza, Alvin Deng, et al. The finetuner’s fallacy: When to pretrain with your finetuning data. arXiv preprint arXiv:2603.16177, 2026.

Bakouch et al. (2025) Elie Bakouch, Loubna Ben Allal, Anton Lozhkov, Nouamane Tazi, Lewis Tunstall, Carlos Miguel Patiño, Edward Beeching, Aymeric Roucher, Aksel Joonas Reedi, Quentin Gallouédec, Kashif Rasul, Nathan Habib, Clémentine Fourrier, Hynek Kydlicek, Guilherme Penedo, Hugo Larcher, Mathieu Morlon, Vaibhav Srivastav, Joshua Lochner, Xuan-Son Nguyen, Colin Raffel, Leandro von Werra, and Thomas Wolf. SmolLM3: smol, multilingual, long-context reasoner. https://huggingface.co/blog/smollm3, 2025.

Berant et al. (2013) Jonathan Berant, Andrew Chou, Roy Frostig, and Percy Liang. Semantic parsing on freebase from question-answer pairs. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, 2013.

Borgeaud et al. (2022) Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens, 2022. URL https://arxiv.org/abs/2112.04426.

Chen et al. (2024) Yihong Chen, Kelly Marchisio, Roberta Raileanu, David Ifeoluwa Adelani, Pontus Stenetorp, Sebastian Riedel, and Mikel Artetxe. Improving language plasticity via pretraining with active forgetting, 2024. URL https://arxiv.org/abs/2307.01163.

Cheng et al. (2024) Daixuan Cheng, Yuxian Gu, Shaohan Huang, Junyu Bi, Minlie Huang, and Furu Wei. Instruction pre-training: Language models are supervised multitask learners, 2024. URL https://arxiv.org/abs/2406.14491.

Dong et al. (2026) Guanting Dong, Junting Lu, Junjie Huang, Wanjun Zhong, Longxiang Liu, Shijue Huang, Zhenyu Li, Yang Zhao, Xiaoshuai Song, Xiaoxi Li, et al. Agent-world: Scaling real-world environment synthesis for evolving general agent intelligence. arXiv preprint arXiv:2604.18292, 2026.

Feldman et al. (2026) Yair Feldman, Linxi Zhao, Nathan Godey, Dongyoung Go, Yilun Hua, Kilian Q. Weinberger, Jennifer J. Sun, and Yoav Artzi. Co-lmlm: Continuous-query limited memory language models, 2026. URL https://arxiv.org/abs/2607.07707.

Gao et al. (2025) Tianyu Gao, Alexander Wettig, Luxi He, Yihe Dong, Sadhika Malladi, and Danqi Chen. Metadata conditioning accelerates language model pre-training, 2025. URL https://arxiv.org/abs/2501.01956.

Gemma Team et al. (2026) Gemma Team, Sherif El Abd, Vaibhav Aggarwal, Robin Algayres, Alek Andreev, Olivier Bachem, Ian Ballantyne, Cormac Brick, Victor Cărbune, Michelle Casbon, et al. Gemma 4 technical report, 2026. URL https://arxiv.org/abs/2607.02770.

Ghosal et al. (2025) Gaurav R. Ghosal, Pratyush Maini, and Aditi Raghunathan. Memorization sinks: Isolating memorization during llm training, 2025. URL https://arxiv.org/abs/2507.09937.

GLM-5-Team et al. (2026) GLM-5-Team, Aohan Zeng, Xin Lv, Zhenyu Hou, Zhengxiao Du, Qinkai Zheng, Bin Chen, Da Yin, Chendi Ge, Chenghua Huang, et al. Glm-5: from vibe coding to agentic engineering, 2026. URL https://arxiv.org/abs/2602.15763.

Grattafiori et al. (2024) Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, et al. The llama 3 herd of models, 2024. URL https://arxiv.org/abs/2407.21783.

Gu et al. (2024) Jia-Chen Gu, Hao-Xiang Xu, Jun-Yu Ma, Pan Lu, Zhen-Hua Ling, Kai-Wei Chang, and Nanyun Peng. Model edi

Sources

← Back to Daily AI Report