sid1-qwen3-4b
a Qwen3-based search agent
2 min readupdated
The sid1-qwen3-4b model is a specialized fine-tune of the base Qwen/Qwen3-4B model (4 billion parameters), trained using Group Relative Policy Optimization (GRPO). Instead of answering questions directly, the model acts as a search agent: it retrieves relevant documents from a database using semantic and keyword search, performs multiple search steps, and returns a ranked list of document IDs. The development is based on the SID-1 concept and adapted for three dataset benchmarks.
Key features
- Unsupervised reinforcement learning (GRPO) where the reward is the NDCG metric of the ranked document list.
- Use of four tools: semantic search, keyword search (BM25), document reading, and final report.
- Improved NDCG and recall scores compared to the base Qwen3-4B model.
- High rate of correct tool calls (99.9%) and report completions.
What you can do
- Integrate the model as a retrieval step in Question-Answering (QA) systems for complex multi-step queries.
- Use the demo space on Hugging Face Spaces to test the agent and view recorded search runs.
- Study the training loop code and reference agent for your own search agent experiments.
Example
import json, re, torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "masterofaudio2077/sid1-qwen3-4b"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto").eval()
SYSTEM_PROMPT = (
"You are a retrieval agent. You are given a question. Do not answer it. Find the documents in the collection that are needed to answer it "
"and report their ids, most relevant first."
)
msgs = [{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "When did the luxury division of the maker of the Toyopet Master change the RX 350 body style?"}]
prompt = tok.apply_chat_template(msgs, add_generation_prompt=True, enable_thinking=True, tokenize=False)
Read more
DetailsBenchmarks: NDCG 0.684 (1 sample), 0.729 (4-sample fusion)
Hardware requirements: peak VRAM consumption during training was 32.6 GiB
Limitations: early stopping at step 175 out of the planned 400, works only with English and a specific tool schema
License: Apache 2.0










Comments