Skip to content

Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learning

Skip →Environments map (start here)
main track #12corefrontierpaperrubric 12/122025 · ~55 min

Bowen Jin, Hansi Zeng, Zhenrui Yue, …, Jiawei Han

Read first: Proximal Policy Optimization (PPO) · DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models

Status

TL;DR. Search-R1 lets an LLM call a search engine in the middle of its own reasoning and trains that behaviour with RL. The only reward is whether the final answer exactly matches the gold answer. Passages returned by the retriever are part of the context but are masked out of the loss, so the policy learns when to search and what to ask, not how to write Wikipedia.

Why it matters now. This is the cleanest bridge from IR to RL agents. The retriever is a normal dense retriever (E5) over a normal corpus (the 2018 Wikipedia dump), so everything you know about recall and query formulation still applies. What changes is that the query writer is now a policy optimised for downstream answer accuracy. Almost every later search-agent paper in this section, and many systems evaluated on BrowseComp-Plus, reuses this recipe or its codebase. “R1” in the name refers to the DeepSeek-R1 style of outcome-reward RL, not to a model release.

Treat the search engine R\mathcal{R} as part of the environment. The policy generates text. When it closes a <search> tag, generation pauses, the query is sent to the retriever, and the top-3 passages are appended inside <information> tags. Generation then resumes. A rollout ends when the model writes <answer>…</answer> or reaches the action budget B=4B = 4. If the model emits an invalid action, the system appends a short “rethink” message and lets it continue.

The objective is the usual KL-regularised RL objective, but now the rollout yy depends on the retriever. The PPO version (Eq. 2 of the paper) is

J(θ)=E[1∑tI(yt)∑t: I(yt)=1min⁡(ρtAt, clip(ρt,1−ϵ,1+ϵ)At)],ρt=πθ(yt∣x,y<t;R)πold(yt∣x,y<t;R)\mathcal{J}(\theta)=\mathbb{E}\left[\frac{1}{\sum_t I(y_t)}\sum_{t:\,I(y_t)=1}\min\big(\rho_t A_t,\ \mathrm{clip}(\rho_t,1-\epsilon,1+\epsilon)A_t\big)\right],\qquad \rho_t=\frac{\pi_\theta(y_t\mid x,y_{<t};\mathcal{R})}{\pi_{\text{old}}(y_t\mid x,y_{<t};\mathcal{R})}

where I(yt)=1I(y_t)=1 for tokens the model generated and 00 for retrieved tokens. The same mask is applied to the KL term. The reward is a single number at the end, r=EM(apred,agold)∈{0,1}r = \mathrm{EM}(a_{\text{pred}}, a_{\text{gold}}) \in \{0, 1\}. There is no format reward and no learned reward model. With PPO, a critic and GAE spread this reward into per-token advantages (γ=λ=1\gamma=\lambda=1). With GRPO, five rollouts per question are normalised against each other and every generated token of a rollout gets the same advantage.

One Search-R1 rollout and what the loss sees A rollout with two search turns is drawn as a strip of segments. Row one: the question, a think segment, a search segment, and an information segment. Row two: think, search, information, and answer. Think, search and answer segments are written by the policy and marked I equals 1, so they are trained. Information segments are inserted by the environment, a frozen E5 retriever over the 2018 Wikipedia dump that returns the top 3 passages, and are marked I equals 0, so they are masked out of the policy-gradient and KL terms. Below, the left panel says the loss sums only over generated tokens and divides by their count, and that removing the mask lowered the 7B base PPO average from 0.431 to 0.343. The right panel says one exact-match reward of 0 or 1 arrives at the end, with no format reward and no reward model; PPO turns it into per-token advantages with a critic and GAE, GRPO gives every token of a rollout the same group-normalised advantage, and the policy may take at most four actions. One rollout with two search turns question x prompt <think> I = 1 <search> I = 1 <information> I = 0 (masked) <think> I = 1 <search> I = 1 <information> I = 0 (masked) <answer> I = 1 Environment R (frozen) E5 over the 2018 Wikipedia dump top-3 passages per <search> What the loss sees sum over tokens with I(yₜ) = 1 only divide by the number of generated tokens the KL to π_ref is masked the same way no mask (7B base, PPO): avg EM 0.431 → 0.343 One scalar reward at the end r = EM(predicted answer, gold) ∈ {0, 1} no format reward, no learned reward model PPO: critic + GAE give per-token advantages GRPO: 5 rollouts, one advantage per rollout budget: at most B = 4 actions per rollout
Original sketch. The policy writes the think, search and answer segments; the frozen retriever writes the information segments, which are masked (I = 0) out of the policy-gradient and KL terms. Numbers are from the paper (Table 4, §4).

Appendix I gives this case (paraphrased; Qwen2.5-7B). Question: Curious is a women’s fragrance by a singer born in what city and state? Gold: McComb, Mississippi.

StepWho writes itContent
1policy, trained<think>: I need the singer behind “Curious”, then her birthplace.
2policy, trained<search> Curious fragrance information
3retriever, masked<information> a passage titled Curious (fragrance): a perfume by Britney Spears for Elizabeth Arden
4policy, trained<search> Britney Spears birthplace
5retriever, masked<information> the Britney Spears article: born in McComb, Mississippi
6policy, trained<search> McComb, Mississippi location (a redundant check)
7policy, trained<answer> McComb, Mississippi → EM = 1

The RL-trained model without search (R1) answers “Houston” after guessing the wrong singer. Notice step 6: outcome-only reward gives the redundant query the same credit as the useful ones. That is the credit-assignment gap later papers attack.

Prompted search (IRCoT, Search-o1)R1-style RL without searchSearch-R1
Retriever in the loopyes, at inferencenoyes, during training rollouts
Weights trainednonepolicy, outcome rewardpolicy, outcome reward
Retrieved tokens in lossn/an/amasked
RewardnoneEMEM, no format reward
EvidenceTable 2 baselinesTable 2 R1 rowsTable 2, Table 4

What did not change: the retriever, the corpus and the passage count are fixed during training, and the reward still checks only the final answer.

All numbers are paper-reported (arXiv v5), EM on seven QA datasets, the same E5 retriever over 2018 Wikipedia with top-3 passages, Qwen2.5 base and instruct models.

  • Main table (Table 2). Averages for Qwen2.5-7B: Search-R1-base 0.431, Search-R1-instruct 0.385, rejection sampling 0.348, RAG 0.304, R1-base 0.276, IRCoT 0.239, Search-o1 0.206. For Qwen2.5-3B: Search-R1-instruct 0.325, Search-R1-base 0.303, RAG 0.270. The 7B base model reaches 0.480 on NQ and 0.433 on HotpotQA (in-domain) and 0.196 on Musique.
  • Headline percentages. The abstract’s 24% (7B) is relative to rejection sampling, the strongest 7B baseline; the contributions list’s 41% is relative to RAG. Both come from the same table.
  • PPO vs GRPO (Table 3). 7B base: PPO 0.431 vs GRPO 0.350; 7B instruct: 0.385 vs 0.396. At 3B the GRPO runs were slightly higher (base 0.312 vs 0.303). So neither optimiser wins everywhere; the paper’s stated preference for PPO is about stability.
  • Masking (Table 4). 0.431 with retrieved-token masking vs 0.343 without (7B base, PPO).
  • Top-k and group size (Tables 7–8). k = 3 gave 0.431 vs 0.375 for k = 1 and 0.400 for k = 5. Appendix H uses a REINFORCE special case at group size 1 (0.410), compared with grouped GRPO at sizes 3 (0.363) and 5 (0.350). Ordinary within-group normalization supplies no learning signal at group size 1, so the size-1 run is a different algorithm, not just a smaller group.
  • Setup. 500 steps on one 8×H100 node, batch 512, response length 500 tokens, retrieved content 500 tokens, actor learning rate 1e-6, KL coefficient 0.001.
  • Training and test share the environment. The same retriever and corpus are used everywhere. Whether the policy transfers to another retriever, a newer corpus or the live web is not tested here; ZeroSearch and DeepResearcher move in that direction.
  • EM is a narrow reward. It fits short entity answers and penalises correct paraphrases. Later papers switch to F1 or LLM judges and report different failure modes.
  • No query-level credit. The redundant search in the worked example earns the same reward as the decisive one.
  • Reproducibility. Independent reruns report lower Search-R1 averages than Table 2 (for example 0.403 in the 2026 study on the follow-ups page), and the paper itself evaluates the last stable checkpoint when runs diverge. Treat the absolute numbers as one configuration, not a ceiling.
  • Short budget. B = 4 actions and 4k tokens of context are far from the dozens of tool calls in BrowseComp-style tasks.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    The v5 abstract and §4.4 report 24% (7B) and 20% (3B) average relative improvement, while the contributions list reports 41% (7B) and 20% (3B) over RAG baselines. Using the Table 2 averages, reproduce all four numbers and say which baseline each one is measured against. Then state the one-sentence rule you would follow when quoting a headline gain from a paper like this.

    What a strong answer covers
    • 7B: best Search-R1 average 0.431 (base, PPO). Rejection sampling 0.348 is the strongest 7B baseline: 0.431 / 0.348 ≈ 1.24, so +24%. Plain RAG is 0.304: 0.431 / 0.304 ≈ 1.42, so +41%.
    • 3B: best Search-R1 average 0.325 (instruct). RAG at 0.270 is also the strongest 3B baseline, so both statements give 0.325 / 0.270 ≈ 1.20, or +20%.
    • The two 7B numbers differ only because the denominator changes. Neither is wrong, but the abstract and the bullet describe different comparisons.
    • Rule: quote the absolute numbers, the metric (EM), the baseline and the table, e.g. "0.431 vs 0.348 for rejection sampling, Table 2, Qwen2.5-7B", not a bare relative percentage.
  2. Mechanism

    Write the masked PPO surrogate Search-R1 uses. Explain what gradient the retrieved passage tokens would receive if I(y_t) were 1 everywhere, why that signal is harmful even though those tokens are "correct text", and why the paper also masks the KL term and normalises by the number of generated tokens.

    What a strong answer covers
    • The surrogate is the PPO-clip term summed over tokens with I(y_t) = 1 and divided by the count of such tokens; I(y_t) = 0 for tokens inserted from the retriever.
    • Without the mask, every passage token gets the trajectory advantage: the policy would be pushed to raise (or lower) the probability of generating Wikipedia text it never chose, i.e. to memorise or hallucinate passages rather than to decide when and what to search.
    • Passage text is off-policy for the model (its probability under π_θ can be tiny), so ratios and log-probabilities on those tokens are noisy and can dominate the update.
    • The KL to the reference model would otherwise also penalise or reward the model for how it "would have" written the passages, which is not a behaviour it controls; masking keeps the KL about the policy's own actions.
    • Normalising by generated tokens keeps the loss scale independent of how much text the retriever returned, so long retrievals do not dilute the policy signal. Table 4 reports 0.431 with the mask vs 0.343 without (7B base, PPO).
  3. What if…

    Appendix H finds that GRPO with group size 1 (0.410) beats size 3 (0.363) and size 5 (0.350) on the 7B base model, and calls size 1 "standard REINFORCE". In the released code a group with a single rollout gets mean 0 and std 1. Compute the advantages of a correct and a wrong rollout under size 1, and under size 5 with rewards (1, 0, 0, 0, 0) using the sample standard deviation. What does the comparison suggest about why the paper saw more stable training with size 1, and what else would you check before believing it?

    What a strong answer covers
    • Size 1: advantage = (r − 0) / 1 = r. The correct rollout gets +1 on every generated token and the wrong rollout gets 0, so wrong answers are never pushed down. It is REINFORCE without a baseline, on positive samples only.
    • Size 5: mean 0.2, sample std √(0.8 / 4) ≈ 0.447. The correct rollout gets (1 − 0.2) / 0.447 ≈ +1.79 and each wrong one gets (0 − 0.2) / 0.447 ≈ −0.45.
    • Normalising by a small std amplifies rare successes and actively pushes down failures; with long multi-turn rollouts this gives larger, noisier updates, consistent with faster reward growth and more collapses. Size 1 only reinforces successes, a gentler update that behaves like filtered imitation of the model's own correct searches.
    • Checks: equal number of rollouts per update (size 1 sees 5× fewer samples per prompt), several seeds, the collapse-checkpoint rule (the paper evaluates the last stable checkpoint), and whether size 1 simply trains more slowly so it is evaluated before over-optimising.
  4. Critique

    Search-R1 calls TriviaQA, PopQA, 2Wiki, Musique and Bamboogle "out-of-domain". List exactly what stays fixed between training and evaluation, and design one experiment that would falsify the claim that the learned search policy generalises beyond its training environment.

    What a strong answer covers
    • Fixed: the same E5 retriever, the same 2018 Wikipedia dump, the same top-3 passage format, the same tags and budget B = 4, and EM on short answers. Only the question distribution changes.
    • So "out-of-domain" here means new question styles, not a new corpus, a new retriever or a live web. Bamboogle has 125 questions, so small differences are noisy.
    • Falsifying experiment: keep the trained policy, but evaluate with (a) BM25 or a different dense retriever over the same dump, (b) a newer Wikipedia or a fixed web corpus such as BrowseComp-Plus, and (c) a live search API. A large drop that prompted baselines do not show would mean the policy fitted the retriever's quirks.
    • Add a no-retrieval control and an oracle-passage diagnostic to separate query skill from answer extraction; report EM and an LLM-judge accuracy because EM penalises correct paraphrases.
  5. Design

    You want to train a Search-R1-style agent on one 8×A100 node for a fixed scientific-paper corpus, using your own dense retriever, with 7B Qwen. Specify the reward, action budget, passage length and top-k, masking, optimiser, checkpoint policy and the three training curves you would watch, justifying each choice from the paper.

    What a strong answer covers
    • Reward: start with EM or a normalised short-answer match only if answers are short entities; otherwise expect the F1 / judge debates the follow-up papers raise. Avoid a format reward at first, as the paper did, but monitor format errors.
    • Budget and context: B around 4 and top-3 passages truncated to a few hundred tokens to fit a 4k window (the paper used 500 tokens of retrieved content); Table 7 found k = 3 better than 1 or 5.
    • Mask retrieved tokens in both the policy loss and the KL; normalise by generated tokens (Table 4).
    • Optimiser: PPO was more stable in the paper's runs; if using GRPO, keep groups small or watch for collapse, and save checkpoints often because the paper fell back to the last stable checkpoint.
    • Curves: training reward, response length (expect a drop then a rise), and valid searches per rollout; add held-out accuracy with a different retriever to catch overfitting to your own index.
  6. Research idea

    Search-R1 gives the same scalar EM reward to every generated token. Propose a way to give query-level credit using IR signals you could compute without new human labels, and the ablation that would show it beats outcome-only reward rather than just changing behaviour.

    What a strong answer covers
    • Candidate signals: whether a passage containing the gold answer string (or a supporting title, for HotpotQA) appears in the top-k after each query; the rank of that passage; novelty of retrieved passages versus earlier turns.
    • Turn it into a gated process bonus (only when the final answer is correct, or capped) to limit reward hacking such as issuing many cheap queries.
    • Ablation: same data, budget, optimiser and seeds; compare EM, number of searches and judge-rated query quality; include a control that adds the same number of reward bits at random to rule out a variance effect.
    • Connects to later work: Search-R2 uses a judge-scored density of useful retrieved chunks, and s3 rewards the gain over naive RAG; cite them as related designs, not as proof.

Done with this page?

Status