Text Generation
Transformers
Safetensors
English
Chinese
qwen3_5
image-text-to-text
Merge
agsi
qwen
reasoning
coding
agentic
terminal-use
swe-bench
tool-use
conversational
Instructions to use OliviaRossi/MiMo-Ornith-9B-AGSI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OliviaRossi/MiMo-Ornith-9B-AGSI with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OliviaRossi/MiMo-Ornith-9B-AGSI") 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("OliviaRossi/MiMo-Ornith-9B-AGSI") model = AutoModelForMultimodalLM.from_pretrained("OliviaRossi/MiMo-Ornith-9B-AGSI", 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 OliviaRossi/MiMo-Ornith-9B-AGSI with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OliviaRossi/MiMo-Ornith-9B-AGSI" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OliviaRossi/MiMo-Ornith-9B-AGSI", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OliviaRossi/MiMo-Ornith-9B-AGSI
- SGLang
How to use OliviaRossi/MiMo-Ornith-9B-AGSI 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 "OliviaRossi/MiMo-Ornith-9B-AGSI" \ --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": "OliviaRossi/MiMo-Ornith-9B-AGSI", "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 "OliviaRossi/MiMo-Ornith-9B-AGSI" \ --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": "OliviaRossi/MiMo-Ornith-9B-AGSI", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OliviaRossi/MiMo-Ornith-9B-AGSI with Docker Model Runner:
docker model run hf.co/OliviaRossi/MiMo-Ornith-9B-AGSI
Enable reasoning-effort tiers and preserve-thinking in chat_template.jinja
Browse files- chat_template.jinja +66 -4
chat_template.jinja
CHANGED
|
@@ -46,10 +46,51 @@
|
|
| 46 |
{{- raise_exception('Unexpected content type.') }}
|
| 47 |
{%- endif %}
|
| 48 |
{%- endmacro %}
|
|
|
|
| 49 |
{%- if not messages %}
|
| 50 |
{{- raise_exception('No messages provided.') }}
|
| 51 |
{%- endif %}
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
{{- '<|im_start|>system\n' }}
|
| 54 |
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 55 |
{%- for tool in tools %}
|
|
@@ -64,13 +105,23 @@
|
|
| 64 |
{{- '\n\n' + content }}
|
| 65 |
{%- endif %}
|
| 66 |
{%- endif %}
|
|
|
|
|
|
|
|
|
|
| 67 |
{{- '<|im_end|>\n' }}
|
| 68 |
{%- else %}
|
| 69 |
{%- if messages[0].role == 'system' %}
|
| 70 |
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
|
|
|
|
|
|
|
|
|
| 71 |
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
|
|
|
|
|
|
| 72 |
{%- endif %}
|
| 73 |
{%- endif %}
|
|
|
|
|
|
|
| 74 |
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 75 |
{%- for message in messages[::-1] %}
|
| 76 |
{%- set index = (messages|length - 1) - loop.index0 %}
|
|
@@ -85,6 +136,7 @@
|
|
| 85 |
{%- if ns.multi_step_tool %}
|
| 86 |
{{- raise_exception('No user query found in messages.') }}
|
| 87 |
{%- endif %}
|
|
|
|
| 88 |
{%- for message in messages %}
|
| 89 |
{%- set content = render_content(message.content, true)|trim %}
|
| 90 |
{%- if message.role == "system" %}
|
|
@@ -104,11 +156,19 @@
|
|
| 104 |
{%- endif %}
|
| 105 |
{%- endif %}
|
| 106 |
{%- set reasoning_content = reasoning_content|trim %}
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
{%- else %}
|
| 110 |
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 111 |
{%- endif %}
|
|
|
|
|
|
|
| 112 |
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 113 |
{%- for tool_call in message.tool_calls %}
|
| 114 |
{%- if tool_call.function is defined %}
|
|
@@ -151,9 +211,11 @@
|
|
| 151 |
{{- raise_exception('Unexpected message role: ' ~ message.role) }}
|
| 152 |
{%- endif %}
|
| 153 |
{%- endfor %}
|
|
|
|
|
|
|
| 154 |
{%- if add_generation_prompt %}
|
| 155 |
{{- '<|im_start|>assistant\n' }}
|
| 156 |
-
{%- if
|
| 157 |
{{- '<think>\n\n</think>\n\n' }}
|
| 158 |
{%- else %}
|
| 159 |
{{- '<think>\n' }}
|
|
|
|
| 46 |
{{- raise_exception('Unexpected content type.') }}
|
| 47 |
{%- endif %}
|
| 48 |
{%- endmacro %}
|
| 49 |
+
|
| 50 |
{%- if not messages %}
|
| 51 |
{{- raise_exception('No messages provided.') }}
|
| 52 |
{%- endif %}
|
| 53 |
+
|
| 54 |
+
{# --- 1. REASONING EFFORT RESOLUTION & PRESERVE-THINKING DISCOVERY --- #}
|
| 55 |
+
{%- if preserve_reasoning is defined and preserve_reasoning is not none %}
|
| 56 |
+
{%- set _preserve_thinking = preserve_reasoning %}
|
| 57 |
+
{%- elif preserve_thinking is defined and preserve_thinking is not none %}
|
| 58 |
+
{%- set _preserve_thinking = preserve_thinking %}
|
| 59 |
+
{%- else %}
|
| 60 |
+
{%- set _preserve_thinking = true %}
|
| 61 |
+
{%- endif %}
|
| 62 |
+
|
| 63 |
+
{%- set _raw_effort = (reasoning_effort | string | lower) if reasoning_effort is defined and reasoning_effort is not none else ((thinking_effort | string | lower) if thinking_effort is defined and thinking_effort is not none else 'medium') %}
|
| 64 |
+
{%- set _enable_thinking = true %}
|
| 65 |
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 66 |
+
{%- set _enable_thinking = false %}
|
| 67 |
+
{%- elif _raw_effort in ['none', 'off', 'false', '0'] %}
|
| 68 |
+
{%- set _enable_thinking = false %}
|
| 69 |
+
{%- endif %}
|
| 70 |
+
|
| 71 |
+
{%- set _resolved_effort = 'medium' %}
|
| 72 |
+
{%- if _raw_effort in ['minimal', 'min', 'low', '1'] %}
|
| 73 |
+
{%- set _resolved_effort = 'low' %}
|
| 74 |
+
{%- elif _raw_effort in ['high', '3'] %}
|
| 75 |
+
{%- set _resolved_effort = 'high' %}
|
| 76 |
+
{%- elif _raw_effort in ['xhigh', 'max', 'extreme', 'ultracode', '4'] %}
|
| 77 |
+
{%- set _resolved_effort = 'xhigh' %}
|
| 78 |
+
{%- endif %}
|
| 79 |
+
|
| 80 |
+
{%- set _effort_prompt = '' %}
|
| 81 |
+
{%- if _enable_thinking %}
|
| 82 |
+
{%- if _resolved_effort == 'low' %}
|
| 83 |
+
{%- set _effort_prompt = 'Reasoning effort is set to low. Keep your thinking concise, efficient, and direct to the point.' %}
|
| 84 |
+
{%- elif _resolved_effort == 'high' %}
|
| 85 |
+
{%- set _effort_prompt = 'Reasoning effort is set to high. Think thoroughly through all steps, verify logic, and test potential edge cases.' %}
|
| 86 |
+
{%- elif _resolved_effort == 'xhigh' %}
|
| 87 |
+
{%- set _effort_prompt = 'Reasoning effort is set to xhigh. Please think exhaustively through the task, systematically exploring alternative hypotheses and proving edge cases before answering.' %}
|
| 88 |
+
{%- endif %}
|
| 89 |
+
{%- endif %}
|
| 90 |
+
|
| 91 |
+
{# --- 2. SYSTEM PROMPT & TOOL DECLARATIONS --- #}
|
| 92 |
+
{%- set _has_tools = (tools and tools is iterable and tools is not mapping) %}
|
| 93 |
+
{%- if _has_tools %}
|
| 94 |
{{- '<|im_start|>system\n' }}
|
| 95 |
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 96 |
{%- for tool in tools %}
|
|
|
|
| 105 |
{{- '\n\n' + content }}
|
| 106 |
{%- endif %}
|
| 107 |
{%- endif %}
|
| 108 |
+
{%- if _effort_prompt %}
|
| 109 |
+
{{- '\n\n' + _effort_prompt }}
|
| 110 |
+
{%- endif %}
|
| 111 |
{{- '<|im_end|>\n' }}
|
| 112 |
{%- else %}
|
| 113 |
{%- if messages[0].role == 'system' %}
|
| 114 |
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 115 |
+
{%- if _effort_prompt %}
|
| 116 |
+
{%- set content = content + ('\n\n' + _effort_prompt if content else _effort_prompt) %}
|
| 117 |
+
{%- endif %}
|
| 118 |
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 119 |
+
{%- elif _effort_prompt %}
|
| 120 |
+
{{- '<|im_start|>system\n' + _effort_prompt + '<|im_end|>\n' }}
|
| 121 |
{%- endif %}
|
| 122 |
{%- endif %}
|
| 123 |
+
|
| 124 |
+
{# --- 3. MULTI-TURN MESSAGE EXTRACTION & REASONING PRESERVATION --- #}
|
| 125 |
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 126 |
{%- for message in messages[::-1] %}
|
| 127 |
{%- set index = (messages|length - 1) - loop.index0 %}
|
|
|
|
| 136 |
{%- if ns.multi_step_tool %}
|
| 137 |
{{- raise_exception('No user query found in messages.') }}
|
| 138 |
{%- endif %}
|
| 139 |
+
|
| 140 |
{%- for message in messages %}
|
| 141 |
{%- set content = render_content(message.content, true)|trim %}
|
| 142 |
{%- if message.role == "system" %}
|
|
|
|
| 156 |
{%- endif %}
|
| 157 |
{%- endif %}
|
| 158 |
{%- set reasoning_content = reasoning_content|trim %}
|
| 159 |
+
|
| 160 |
+
{# Honor preserve_thinking: keep prior thoughts if true, strip older thoughts if false #}
|
| 161 |
+
{%- if _preserve_thinking or loop.index0 > ns.last_query_index %}
|
| 162 |
+
{%- if reasoning_content %}
|
| 163 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 164 |
+
{%- else %}
|
| 165 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 166 |
+
{%- endif %}
|
| 167 |
{%- else %}
|
| 168 |
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 169 |
{%- endif %}
|
| 170 |
+
|
| 171 |
+
{# Function call serialization #}
|
| 172 |
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 173 |
{%- for tool_call in message.tool_calls %}
|
| 174 |
{%- if tool_call.function is defined %}
|
|
|
|
| 211 |
{{- raise_exception('Unexpected message role: ' ~ message.role) }}
|
| 212 |
{%- endif %}
|
| 213 |
{%- endfor %}
|
| 214 |
+
|
| 215 |
+
{# --- 4. GENERATION PROMPT PREFILL --- #}
|
| 216 |
{%- if add_generation_prompt %}
|
| 217 |
{{- '<|im_start|>assistant\n' }}
|
| 218 |
+
{%- if not _enable_thinking %}
|
| 219 |
{{- '<think>\n\n</think>\n\n' }}
|
| 220 |
{%- else %}
|
| 221 |
{{- '<think>\n' }}
|