Instructions to use yuanqianhao/MemSearcher-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yuanqianhao/MemSearcher-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yuanqianhao/MemSearcher-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yuanqianhao/MemSearcher-7B") model = AutoModelForCausalLM.from_pretrained("yuanqianhao/MemSearcher-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yuanqianhao/MemSearcher-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yuanqianhao/MemSearcher-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yuanqianhao/MemSearcher-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yuanqianhao/MemSearcher-7B
- SGLang
How to use yuanqianhao/MemSearcher-7B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "yuanqianhao/MemSearcher-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yuanqianhao/MemSearcher-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "yuanqianhao/MemSearcher-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yuanqianhao/MemSearcher-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yuanqianhao/MemSearcher-7B with Docker Model Runner:
docker model run hf.co/yuanqianhao/MemSearcher-7B
MemSearcher-7B
Model Summary
MemSearcher-7B is a search agent built on Qwen/Qwen2.5-7B-Instruct and trained with
multi-context GRPO, the end-to-end reinforcement-learning method introduced in
MemSearcher.
Unlike ReAct-style agents that concatenate the entire interaction history into the context — producing long, noisy inputs and linearly growing compute — MemSearcher maintains a compact, iteratively-updated memory. At every turn the backbone LLM sees only two short inputs, the question and the current memory, then it reasons, decides whether to search, and rewrites the memory to keep only question-relevant information. This keeps the context length nearly constant across turns without sacrificing accuracy.
Evaluation
Exact Match (EM) on seven single- and multi-hop QA benchmarks (Wikipedia-18 corpus):
| Model | NQ | TriviaQA | PopQA | HotpotQA | 2Wiki | MuSiQue | Bamboogle | Avg. |
|---|---|---|---|---|---|---|---|---|
| MemSearcher 3B | 47.0 | 63.8 | 47.9 | 43.9 | 43.5 | 17.9 | 42.4 | 43.8 |
| MemSearcher 7B | 52.7 | 68.1 | 47.8 | 50.8 | 48.6 | 25.8 | 48.8 | 48.9 |
| MemSearcher 14B | 53.7 | 71.1 | 48.8 | 51.8 | 51.5 | 27.2 | 57.6 | 51.7 |
This card is for the 7B model (highlighted row).
Key Features
- 🧠 Compact memory — keeps only question-relevant information instead of the full history.
- 📏 Near-constant context — token count stays stable across multi-turn interactions, cutting compute/memory.
- 🎯 Multi-context GRPO — propagates trajectory-level advantages to every turn for true end-to-end RL.
- 🔍 Strong QA performance — outperforms strong history-concatenation (ReAct-style) baselines across 7 benchmarks.
How It Works
At turn i the context is just (question, memory_{i-1}). The model:
- Reasons inside
<think>...</think>; - Searches when it lacks knowledge (a
wikipedia_searchtool call), or answers in\boxed{}when the memory suffices; - Updates the memory from the retrieved results, retaining only what helps answer the question.
Training uses multi-context GRPO: it samples a group of trajectories, then propagates each trajectory's advantage to all of its per-turn contexts, enabling stable end-to-end optimization of reasoning, search, and memory management.
Quickstart
MemSearcher is an agent that needs a Wikipedia retriever and the multi-turn orchestration loop. The simplest path is the released code:
git clone https://github.com/icip-cas/MemSearcher && cd MemSearcher
# 1) start the wiki-18 retriever (see README "Retriever Serving")
# 2) serve this model with SGLang
MODEL_PATH=yuanqianhao/MemSearcher-7B TP=2 PORT=80 bash launch_server.sh
# 3) run the agentic evaluation
GENERATOR_MODEL=yuanqianhao/MemSearcher-7B DATA_DIR=./data SAVE_DIR=./eval \
SGL_REMOTE_URL=http://127.0.0.1:80 RETRIEVER_URL=http://127.0.0.1:8000/search bash eval.sh
The model weights load with standard transformers (AutoModelForCausalLM.from_pretrained("yuanqianhao/MemSearcher-7B")),
but reproducing the reported numbers requires the retriever + agent loop above.
Training Data
Trained on the NQ + HotpotQA training split — the same data as Search-R1 — re-wrapped into MemSearcher's re_call format. See the code repository for the exact preparation script.
Citation
@article{yuan2025memsearcher,
title={MemSearcher: Training LLMs to Reason, Search and Manage Memory via End-to-End Reinforcement Learning},
author={Yuan, Qianhao and Lou, Jie and Li, Zichao and Chen, Jiawei and Lu, Yaojie and Lin, Hongyu and Sun, Le and Zhang, Debing and Han, Xianpei},
journal={arXiv preprint arXiv:2511.02805},
year={2025}
}
License
Released under Apache-2.0, following the base model Qwen/Qwen2.5-7B-Instruct.
- Downloads last month
- 45