Files
prime-rl/examples/basic/wiki-search/README.md
T
faresobeidandGitHub 23017482f9 chore(configs): remove configs/basic and unreferenced debug configs (#3777)
Removes `configs/basic/` and the debug configs
`configs/debug/concurrency.toml` and `configs/debug/multi-env/`.

**Why:** `configs/basic/*` are dev-size copies of `examples/basic/*`,
and they have already drifted from them. For example,
`configs/basic/reverse-text/rl.toml` no longer has the eval block. The
remaining differences are GPU count, batch size and group size, which
can all be set from the CLI. No test runs these configs;
`test_configs.py` only checks that they parse, using a glob. Nothing in
the repo references the two debug configs, so they have no owner and
will drift the same way.

**Changes**
- Deleted
`configs/basic/{alphabet-sort,hendrycks-sanity,reverse-text,wiki-search,wordle}`,
`configs/debug/concurrency.toml`, and `configs/debug/multi-env/`. Kept
`configs/debug/{algo,eval,fake}`.
- `README.md`: the 2-GPU check now uses
`examples/basic/reverse-text/rl.toml`. That example already defaults to
1 trainer GPU + 1 inference GPU.
- `configs/README.md` / `examples/README.md`: removed the `basic/` and
`multi-env/` entries and the "smoke-tested" claim.
- `examples/basic/{wiki-search,wordle,hendrycks-sanity}/README.md`:
added the 2-GPU overrides `--deployment.num-train-gpus 1
--deployment.num-infer-gpus 1 --orchestrator.batch-size 128`. Inference
DP adjusts to the GPU count automatically.

**Breaking:** commands like `uv run rl @ configs/basic/...` no longer
work. Use `examples/basic/...`, with the overrides above for 2 GPUs.

**Validation**
- `rl @ examples/basic/{wiki-search,wordle,hendrycks-sanity}/rl.toml
--deployment.num-train-gpus 1 --deployment.num-infer-gpus 1
--orchestrator.batch-size 128 --dry-run`: all three resolve. For wordle,
the resolved inference has `data_parallel_size = 1`.
- `pytest tests/unit/test_configs.py -m "not gpu"`: 199 passed.
- `ruff check .` and `ruff format --check .`: clean.
- No GPU runs; this machine has no GPU.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation and config path removal only; users must switch to
example configs and optional CLI flags for 2-GPU dev runs.
> 
> **Overview**
> Removes duplicate **`configs/basic/`** tutorial configs and two
unreferenced debug configs (**`concurrency.toml`**,
**`multi-env/rl.toml`**), so **`examples/basic/`** is the single source
for small end-to-end runs.
> 
> **Breaking:** `uv run rl @ configs/basic/...` no longer works. The
root README’s 2-GPU stack check now uses
**`examples/basic/reverse-text/rl.toml`**. **`configs/README.md`**
documents **`debug/algo`**, **`fake`**, and **`eval`** only.
> 
> For former 2-GPU **`basic`** setups, **`hendrycks-sanity`**,
**`wiki-search`**, and **`wordle`** READMEs document CLI overrides:
`--deployment.num-train-gpus 1 --deployment.num-infer-gpus 1
--orchestrator.batch-size 128`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4776cecdef44708f93c73075a5d57b5eb87a007f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-10-03 12:37:05 -07:00

5.3 KiB

Wiki Search

In this example, we demonstrate how to train Qwen3-4B-Instruct-2507 to answer trivia questions by searching through a Wikipedia corpus using multi-turn tool use. This example highlights several key features of prime-rl and verifiers environment features:

  • Single-file configuration: All training settings (trainer, orchestrator, and inference) are specified in a single rl.toml file
  • LoRA training: Efficient fine-tuning using LoRA (Low-Rank Adaptation) on attention and MLP layers
  • Multi-turn tool use: The model learns to use V1 tools across multiple turns through native function calling
  • Locally-hosted storage: Uses ChromaDB and its local embedding model for retrieval
  • LLM judges: Uses an LLM judge to evaluate answer quality alongside tool execution metrics
  • Online difficulty buffer: Uses difficulty-based sampling to ensure rollouts have strictly non-zero advantages

This example runs on 8 GPUs (6 for inference, 2 for training). To run on 2 GPUs (1 inference, 1 trainer), add --deployment.num-train-gpus 1 --deployment.num-infer-gpus 1 --orchestrator.batch-size 128 to the rl command.

Setup

The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:

uv run python -c "import wiki_search"

Set up the credentials for the configured reference judge:

export OPENAI_API_KEY=your_api_key_here

We'll use two terminals: one for the inference server, one for everything else. To watch the run while it trains — metrics, resolved configs, rollout traces, and logs in one place — start the local dashboard and open http://localhost:7788:

uv run dashboard

Task

The wiki-search environment requires the model to answer trivia questions by:

  1. Searching for relevant Wikipedia pages using semantic search over page titles
  2. Browsing page sections to find relevant information
  3. Reading specific sections to extract answers
  4. Answering the question correctly and coherently

The taskset provides three tools:

  • wiki_search_pages(query): Performs embedding-based search over Wikipedia page titles, returning the top 10 relevant pages
  • wiki_view_sections(page_id): Lists all sections available in a Wikipedia page
  • wiki_read_section(section_id): Retrieves the content of a specific section

The corpus is indexed in ChromaDB using its local embedding model. On first run, the taskset builds the index from willcb/rare-wiki-pages and stores it under ~/.cache/wiki_search by default.

Scoring

The taskset uses a reference-answer judge (default: openai/gpt-5.4-nano) to evaluate whether the final answer is both correct and coherent.

The judge compares the model's response against the ground truth answer and returns a binary score (1.0 for correct and coherent, 0.0 otherwise).

Configuration

This example uses a single rl.toml file that contains all configuration for trainer, orchestrator, and inference in a single place. This simplifies configuration for single-node training via rl.py.

Key configuration highlights:

  • LoRA training: Rank 8, alpha 32 for efficient fine-tuning
  • Tool calling: Uses Hermes parser for automatic tool selection with Qwen3-4B-Instruct-2507
  • Multi-turn: Tool calls and results are carried across turns by the V1 harness
  • Online difficulty buffer: Uses difficulty-based sampling with 2x oversampling

Baseline Evaluation

Start the inference server:

# Run this in the inference terminal
uv run inference --vllm.enable-lora --vllm.model Qwen/Qwen3-4B-Instruct-2507 --vllm.tool-call-parser hermes

Evaluate the base model:

# Run this in the other terminal
uv run eval @ examples/basic/wiki-search/eval.toml

RL Training

Train with the unified config file:

# Run this in the other terminal
uv run rl @ examples/basic/wiki-search/rl.toml \
  --run.name rl \
  --monitors.wandb.project your-project-name \
  --monitors.wandb.name your-run-name

The unified config file automatically configures:

  • Trainer: LoRA fine-tuning with specified hyperparameters
  • Orchestrator: Rollout generation with tool calling enabled
  • Inference: vLLM server for Qwen3-4B-Instruct-2507 with tool parsing enabled

This will write DCP checkpoints in outputs/rl/checkpoints/step_*.

Evaluation

Evaluate your trained model:

# Run this in the inference terminal
uv run inference --vllm.enable-lora --vllm.model <user>/Qwen3-4B-Instruct-WikiSearch-RL --vllm.tool-call-parser hermes
# Run this in the other terminal
uv run eval @ examples/basic/wiki-search/eval.toml -m <user>/Qwen3-4B-Instruct-WikiSearch-RL

Taskset Configuration

The V1 taskset fixes the question bank and searchable corpus. You can replace its reference judge in rl.toml:

[[orchestrator.train.source]]
name = "wiki-search"
taskset = { id = "wiki-search", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
harness = { id = "null" }
runtime = { type = "subprocess" }

Notes

  • The first run will build the ChromaDB index, which may take a minute or two
  • Ensure the selected judge's API credentials are available in your environment
  • The ChromaDB index persists under ~/.cache/wiki_search; set WIKI_SEARCH_CACHE to move it
  • Tool calling requires enable_auto_tool_choice = true and a compatible parser (Hermes is recommended)