# Repository Briefing: allenai/dr-tulu2
> Source: https://repoforai.com/repo/allenai/dr-tulu2 (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/allenai/dr-tulu2
- **Category**: Agents & Frameworks (智能体与框架)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A (77/100 · Maintenance 35/35 · Adoption 11/25 · Releases 11/20 · License 20/20)
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: Docker, GPU, API
- **Momentum**: 73 ★ total (+14 24h / +73 7d) · 8 forks
- **When to Use**: Best for: Research teams studying multi-step search policies with controlled corpora, inspectable tool traces, and an evaluation path before committing to distributed training. Skip if: A single-pass RAG system covers the workload, live-web freshness is the overriding requirement, or you cannot operate GPU inference and local indexes.

## Overview
```text
### Architecture & Core Mechanics
DR Tulu 2 separates policy inference, tool execution, and reinforcement-learning training. In `drtulu2-client/`, a Python Verifiers environment connects a vLLM-served checkpoint to search and terminal tools. The harness lets the agent submit queries, open documents, and refine its search across successive tool calls before generating an answer. The demo shows HTTP JSON requests to `/search`; `load_environment` accepts separate search and terminal endpoint URLs.

In `drtulu2-training/`, Prime-RL handles the training loop and `literegistry` orchestrates tool servers during training. Each simulated task pairs a research question with a searchable document collection. Serving those collections locally keeps rollout queries independent of live search quotas. The separate tool endpoints also let engineers test corpus retrieval without starting vLLM or a training job.

### Key Capabilities & Differentiators
The 4B policy starts from Qwen3.5-4B and trains through General Web, Science, and Finance in that order. The General Web checkpoint selected at step 400 initializes Science; Science step 200 initializes Finance; step 100 is selected for Finance. The three corresponding Hugging Face corpora can be indexed locally with BM25 using `drtulu2-client/build_hf_indexes.sh`.

For BrowseComp-Plus, the client generates answers, records tool calls, and supports a separate grading pass via `eval.sh grade` after `eval.sh generate`. The included 32-question example is a small evaluation workflow, not a performance result. The tool layer can also search the live web through Serper and fetch pages through Jina, but that path uses different data and infrastructure from simulated training.

### Trade-offs & Limitations
Compared with a conventional retrieve-then-generate RAG pipeline, DR Tulu 2 makes iterative search part of the learned policy and exposes its tool-call trace for analysis. That is useful when reformulating queries or opening several documents is central to the task, but it adds sequential tool calls and more services to operate. If one retrieval pass is enough, the simpler pipeline is easier to deploy and debug.

Compared with a hosted web research API, local BM25 gives teams control over the corpus and removes per-query search charges and external search quotas from simulated rollouts. The trade-off is ownership of corpus storage, indexing, GPU serving, and training orchestration. Fixed collections cannot establish performance on a changing web; switching to live search restores external dependencies and rate limits. GPT-4.1 grading also means the standard grading path is not entirely offline, even if retrieval and inference are local.

### Hardware & Deployment Guide
Start with `./drtulu2-client/quickstart_docker.sh` to bring up the bundled demo search corpus and test the HTTP service on port 1214. For BrowseComp-Plus, run vLLM with the checkpoint, serve the benchmark corpus and its BM25 index, and run the Python evaluation client. Docker and Apptainer are both shown for the 32-question example. Local retrieval needs no live search API credentials; GPT-4.1 grading needs `OPENAI_API_KEY`, and live search and page fetching need `SERPER_API_KEY` and `JINA_API_KEY`, respectively.

Budget disk for the corpus and index separately from GPU memory for inference. The 4B parameter count is not a VRAM estimate: precision, context length, and concurrent sequences affect the vLLM footprint. For training, use the Prime-RL image-build and multi-node launch assets for Slurm or Beaker and size that workload separately from evaluation. No tagged release is listed, so pin the repository revision alongside model and data artifacts when reproducing a run.
```

## Key Capabilities
```text
- Policy: The 4B research agent starts from Qwen3.5-4B and learns multi-step tool use in simulated search environments.
- Search: `drtulu2-client/build_hf_indexes.sh` builds local BM25 indexes for the General Web, Science, and Finance corpora.
- Evaluation: The vLLM-backed Verifiers client records tool calls and separates BrowseComp-Plus generation from grading.
- Training stages: General Web step 400 initializes Science; Science step 200 initializes Finance, whose selected checkpoint is step 100.
- Cluster training: Prime-RL runs training, `literegistry` orchestrates tool servers, and launchers target Slurm and Beaker.
- Service smoke test: The Docker quickstart exposes a demo search service at `127.0.0.1:1214`, independent of model serving.
```

## Quick Start / Clone
```bash
curl -fsS http://127.0.0.1:1214/search \
  -H 'Content-Type: application/json' \
  -d '{"mode":"query","query":"astronomy","num_results":1}'
```
