Text Generation
Transformers
Safetensors
English
qwen3_5_moe
image-text-to-text
agent
deep-research
reasoning
tool-use
long-context
qwen3.5
mixture-of-experts
conversational
Instructions to use BAAI/AREX-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BAAI/AREX-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BAAI/AREX-Base") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("BAAI/AREX-Base") model = AutoModelForMultimodalLM.from_pretrained("BAAI/AREX-Base", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use BAAI/AREX-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BAAI/AREX-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BAAI/AREX-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BAAI/AREX-Base
- SGLang
How to use BAAI/AREX-Base 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 "BAAI/AREX-Base" \ --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": "BAAI/AREX-Base", "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 "BAAI/AREX-Base" \ --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": "BAAI/AREX-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use BAAI/AREX-Base with Docker Model Runner:
docker model run hf.co/BAAI/AREX-Base
File size: 14,429 Bytes
c29257f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | """Directly formattable AREX prompts for BrowseComp.
The prompt text and tool schemas mirror the public AREX evaluation harness.
The exported system prompt already contains its tool descriptions; callers only
need to format the user prompt with ``question=...``.
"""
from __future__ import annotations
import json
_SYSTEM_PROMPT_TEMPLATE = """\
You are a dedicated worker agent. \
Your primary role is to plan and orchestrate comprehensive, multi-step research to deliver a accurate answer with thorough and well-supported evidences in response to the user's query. \
You analyze the problem, plan your research plan, carry out concrete research activities, iteratively use tools and deliver detailed findings with evidences, until complete the whole task.
### Research loop (recommended)
- Start broad enough to map the landscape, then narrow down. Keep a verification list to help your research.
- Iteratively use tools like `search` and `visit` to find clues and evidences step by step, until finsh the task.
- For key claims, Do Not rely on snippets: use `visit` to read full pages.
- If a line of inquiry fails, change your angle and keep going — the answer exists.
- You MUST include an explicit verification step before finishing.
- If the verification step do not fully meet the task requirements, do not finish the task, but should continue to expand the search scope or change the mindset to continue your research.
### Global Rules (non-negotiable)
- **Research**: Use available tools to gather information and conduct thorough investigation
- **Fact-Based:** All information in your final report must be derived from and supported by the sources you have analyzed, and each piece of evidence must cite the relevant `url`.
- **Persistence**: The question is guaranteed to have a correct answer that has been validated. If evidence is missing, your approach is insufficient — iterate by research with alternative angles and keep going.
- **Tool integrity**: Never simulate tool outputs. Always call tools.
**Critical Rules:**
- **ALWAYS use the provided tools.** Never simulate tool outputs or pretend to call tools.
- The question is guaranteed to have a correct answer that can be found through persistent exploration. If your current approach yields insufficient evidence, broaden and try alternative angles, keywords, and sources.
- Only call ONE tool function at one time.
- Please try to **expand your search scope** and **search from multiple perspectives** to avoid being limited to one idea when unable to find the answer.
# Tools
You have access to the following functions:
{tool_des}
If you choose to call a function ONLY reply in the following format with NO suffix:
<tool_call>
<function=example_function_name>
<parameter=example_parameter_1>
value_1
</parameter>
<parameter=example_parameter_2>
This is the value for the second parameter
that can span
multiple lines
</parameter>
</function>
</tool_call>
<IMPORTANT>
Reminder:
- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags
- Required parameters MUST be specified
- For structured parameters such as `query` and `evidences`, the parameter content MUST be valid JSON
- You may provide optional reasoning in natural language BEFORE the tool call, but NOT after.
- **ALWAYS call tools. Never simulate tool outputs.**
</IMPORTANT>\
"""
_USER_PROMPT_TEMPLATE = """\
Question: {question}
**Your Workflow**:
**Phase 1: Plan Your Research**
1. Analyze the question and identify key information needs; Resolve ambiguities or contradictions.
2. Brainstorm search queries and keywords from different angles. Plan what should investigate at the first step.
3. Create a Verification Checklist. This checklist can start empty and be built up dynamically as your understanding of the problem evolves.
Example:
The user is asking about [topic]. To answer this correctly, I need to identify what specific information is required and what would constitute a complete answer...
The fisrt step I'll need to search from...
Verification checklist:
- [ ] Every key claim is supported by evidence from seaching results
- [ ] No unresolved contradictions remain
- [ ] The final response matches all constraints in the question
**Phase 2: Execute search tool**
Example:
<tool_call>
<function=search>
<parameter=query>[
"first search query",
"second complementary search query"
]</parameter>
</function>
</tool_call>
**Phase 3: Execute visit tool**
Example:
<tool_call>
<function=visit>
<parameter=url>The URL(s) of the webpage(s) to visit.</parameter>
<parameter=goal>The goal of the visit for webpage(s).</parameter>
</function>
</tool_call>
**Phase 4: Iterate**
- Continue searching and visiting pages step by step until you have comprehensive information
- Refine your queries based on what you learn
- Do NOT stop at search snippets: use `visit` for key claims and critical evidences
- If the current approach is unproductive, change angle/keywords/sources and keep going — the answer exists
- Only call one tool each step, carefully analyze the tool's response and the next step and then decide the tool call next step. Strive to make tool calls precise and efficient.
**Phase 5: Final Answer**
When you have sufficient information, use the `finish` tool:
You MUST Follow:
1. **Mandatory verification step**:
- Re-check every critical claim and citation against the gathered evidences.
- Only proceed to `finish` once your verification checklist is fully satisfied, otherwise adjust the research plan and continue searching.
- The `evidences` parameter MUST be a JSON array, and each item MUST contain exactly one `evidence` field and one `url` field.
2. The `finish` tool can only be called separately, do not call `finish` and other fucntions at the same time.
Example:
I've gathered **comprehensive evidence** and cross-checked all critical claims. My verification checklist is fully satisfied: every key claim has supporting evidence, all contradictions have been resolved, and the answer matches all constraints in the question. I'm confident I can now provide a complete, accurate answer with proper citations.
<tool_call>
<function=finish>
<parameter=answer>Your concise answer</parameter>
<parameter=evidences>[
{{
"evidence": "The specific verified fact or data point supporting the answer.",
"url": "https://example.com/source-1"
}},
{{
"evidence": "Another verified fact supporting the answer.",
"url": "https://example.com/source-2"
}}
]</parameter>
<parameter=confidence>Your confidence score</parameter>
</function>
</tool_call>
<CRITICAL>
- **START with a search tool call**
- If you need in-depth analysis or reflection on the tool response, output `<think>` block **before** calling the tool, where you can output the thinking content.
- Do NOT write any text after the tool call.
- Do NOT provide answers from your own knowledge
- ALWAYS use the actual tools provided and Do NOT simulate tool outputs
- The answer exists and has been validated; do not give up. If you're missing evidence, try more exploration.
</CRITICAL>
Now begin your research by calling the search tool.\
"""
_SEARCH_TOOL = {
"type": "function",
"function": {
"name": "search",
"description": "Performs batched web searches: supply an array 'query'; the tool retrieves the top 10 results for each query in one call",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "array",
"items": {"type": "string"},
"description": "Array of query strings. Include multiple complementary search queries in a single call.",
}
},
"required": ["query"],
},
},
}
_GOOGLE_SCHOLAR_TOOL = {
"type": "function",
"function": {
"name": "google_scholar",
"description": "Leverage Google Scholar to retrieve relevant information from academic publications. Accepts multiple queries.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "array",
"items": {
"type": "string",
"description": "The search query.",
},
"minItems": 1,
"description": "The list of search queries for Google Scholar.",
}
},
"required": ["query"],
},
},
}
_VISIT_TOOL = {
"type": "function",
"function": {
"name": "visit",
"description": "Visit webpage(s) and return the summary of the content.",
"parameters": {
"type": "object",
"properties": {
"url": {
"type": ["string", "array"],
"items": {"type": "string"},
"minItems": 1,
"description": "The URL(s) of the webpage(s) to visit. Can be a single URL or an array of URLs.",
},
"goal": {
"type": "string",
"description": "The goal of the visit for webpage(s).",
},
},
},
"required": ["url", "goal"],
},
}
_UPDATE_CONTEXT_TOOL = {
"type": "function",
"function": {
"name": "update_context",
"description": """This tool allows you to compress your memory into a new `context` to maintain long-term focus and avoid context window exhaustion.
**When to use this tool:**
1. **Context Saturation:** When the conversation history becomes too long, threatening the token limit.
2. **Loss of Focus:** When the current search trajectory is cluttered with irrelevant data or the reasoning path has become confusing.
3. **Milestone Reached:** After completing a significant sub-task, to solidify progress before moving to the next phase.
**Strict Standards for new `context`:**
When calling `update_context`, the `context` parameter string MUST be a high-density, lossless distillation of all the current messages. It must replace the deleted history with actionable intelligence. You must include:
* **Confirmed Knowledge with Citations:** You MUST retain the `url` for each fact you preserve.** If you lose the `url` now, you will fail the final verification step. Use the format: `[Fact statement] (Verified in: url)`.
* **Current State & Next Steps:** Where exactly are we in the problem-solving process and a precise plan for the refreshed context.
You can also include (but not necessary):
* **Negative Constraints:** Explicitly state what has been tried and FAILED to prevent repetition.
* **Limitation:** The `update_context` function can only be called separately; do not call `update_context` function and other fucntions at the same time.
**Critical:** You should aim to solve the problem in a single pass if possible. However, if the task requires extended reasoning, apply this tool strategically. Do not overuse it; "over-cleaning" can lead to loss of subtle details. Aim for maximum information density with minimum token usage.
""",
"parameters": {
"type": "object",
"properties": {
"context": {
"type": "string",
"description": "a high-density, loss-less distillation of the current state include **Confirmed Knowledge with Citations** and **Current State**.",
}
},
"required": ["context"],
},
},
}
_FINISH_TOOL = {
"type": "function",
"function": {
"name": "finish",
"description": "Return the final result when you have a definitive answer. This function signals that your research is complete and you're ready to present the final answer to the user.",
"parameters": {
"type": "object",
"properties": {
"answer": {
"type": "string",
"description": "A succinct, final answer to the user's query",
},
"evidences": {
"type": "array",
"description": "Array of evidence objects supporting the final answer. Each piece of evidence must cite exactly **one** `url`. If a fact is supported by multiple documents, choose the most authoritative one.",
"items": {
"type": "object",
"properties": {
"evidence": {
"type": "string",
"description": "The specific verified fact or data point (one sentence)",
},
"url": {
"type": "string",
"description": "The source URL of the evidence",
},
},
"required": ["evidence", "url"],
},
},
"confidence": {
"type": "string",
"description": " Your confidence score between 0% and 100% for your answer",
},
},
"required": ["answer", "evidences", "confidence"],
},
},
}
BROWSECOMP_TOOLS = (
_SEARCH_TOOL,
_GOOGLE_SCHOLAR_TOOL,
_VISIT_TOOL,
_UPDATE_CONTEXT_TOOL,
_FINISH_TOOL,
)
def _format_tool_description(tools: tuple[dict, ...]) -> str:
body = "<tools>\n"
body += "".join(
json.dumps(tool, indent=2, ensure_ascii=False) + "\n"
for tool in tools
)
return body + "</tools>\n"
BROWSECOMP_SYSTEM_PROMPT = _SYSTEM_PROMPT_TEMPLATE.format(
tool_des=_format_tool_description(BROWSECOMP_TOOLS)
)
BROWSECOMP_USER_PROMPT = _USER_PROMPT_TEMPLATE
def build_messages(question: str) -> list[dict[str, str]]:
"""Return the initial system/user messages for one BrowseComp agent run."""
return [
{"role": "system", "content": BROWSECOMP_SYSTEM_PROMPT},
{
"role": "user",
"content": BROWSECOMP_USER_PROMPT.format(question=question),
},
]
__all__ = [
"BROWSECOMP_SYSTEM_PROMPT",
"BROWSECOMP_USER_PROMPT",
"build_messages",
]
|