Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +583 -0
- SYSTEM_PROMPT.txt +5 -0
- chat_template.jinja +126 -0
- config.json +266 -0
- generation_config.json +7 -0
- model-00001-of-00003.safetensors +3 -0
- model-00002-of-00003.safetensors +3 -0
- model-00003-of-00003.safetensors +3 -0
- model.safetensors +3 -0
- model.safetensors.index.json +0 -0
- params.json +47 -0
- processor_config.json +42 -0
- recipe.yaml +37 -0
- special_tokens_map.json +0 -0
- tekken.json +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tekken.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,583 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: vllm
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- fr
|
| 6 |
+
- es
|
| 7 |
+
- de
|
| 8 |
+
- it
|
| 9 |
+
- pt
|
| 10 |
+
- nl
|
| 11 |
+
- zh
|
| 12 |
+
- ja
|
| 13 |
+
- ko
|
| 14 |
+
- ar
|
| 15 |
+
license: apache-2.0
|
| 16 |
+
inference: false
|
| 17 |
+
base_model:
|
| 18 |
+
- mistralai/Ministral-3-14B-Reasoning-2512
|
| 19 |
+
extra_gated_description: >-
|
| 20 |
+
If you want to learn more about how we process your personal data, please read
|
| 21 |
+
our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
|
| 22 |
+
tags:
|
| 23 |
+
- mistral-common
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
# Ministral 3 14B Reasoning 2512
|
| 27 |
+
|
| 28 |
+
The largest model in the Ministral 3 family, **Ministral 3 14B** offers frontier capabilities and performance comparable to its larger [Mistral Small 3.2 24B](https://huggingface.co/mistralai/Mistral-Small-3.2-Instruct-2506) counterpart. A powerful and efficient language model with vision capabilities.
|
| 29 |
+
|
| 30 |
+
This model is the reasoning post-trained version, trained for reasoning tasks, making it ideal for math, coding and stem related use cases.
|
| 31 |
+
|
| 32 |
+
The Ministral 3 family is designed for edge deployment, capable of running on a wide range of hardware. Ministral 3 14B can even be deployed locally, capable of fitting in 32GB of VRAM in BF16, and less than 24GB of RAM/VRAM when quantized.
|
| 33 |
+
|
| 34 |
+
## Key Features
|
| 35 |
+
Ministral 3 14B consists of two main architectural components:
|
| 36 |
+
- **13.5B Language Model**
|
| 37 |
+
- **0.4B Vision Encoder**
|
| 38 |
+
|
| 39 |
+
The Ministral 3 14B Reasoning model offers the following capabilities:
|
| 40 |
+
- **Vision**: Enables the model to analyze images and provide insights based on visual content, in addition to text.
|
| 41 |
+
- **Multilingual**: Supports dozens of languages, including English, French, Spanish, German, Italian, Portuguese, Dutch, Chinese, Japanese, Korean, Arabic.
|
| 42 |
+
- **System Prompt**: Maintains strong adherence and support for system prompts.
|
| 43 |
+
- **Agentic**: Offers best-in-class agentic capabilities with native function calling and JSON outputting.
|
| 44 |
+
- **Reasoning**: Excels at complex, multi-step reasoning and dynamic problem-solving.
|
| 45 |
+
- **Edge-Optimized**: Delivers best-in-class performance at a small scale, deployable anywhere.
|
| 46 |
+
- **Apache 2.0 License**: Open-source license allowing usage and modification for both commercial and non-commercial purposes.
|
| 47 |
+
- **Large Context Window**: Supports a 256k context window.
|
| 48 |
+
|
| 49 |
+
### Use Cases
|
| 50 |
+
Private AI deployments where advanced capabilities meet practical hardware constraints:
|
| 51 |
+
- Private/custom chat and AI assistant deployments in constrained environments
|
| 52 |
+
- Advanced local agentic use cases
|
| 53 |
+
- Fine-tuning and specialization
|
| 54 |
+
- And more...
|
| 55 |
+
|
| 56 |
+
Bringing advanced AI capabilities to most environments.
|
| 57 |
+
|
| 58 |
+
## Ministral 3 Family
|
| 59 |
+
|
| 60 |
+
| Model Name | Type | Precision | Link |
|
| 61 |
+
|--------------------------------|--------------------|-----------|------------------------------------------------------------------------------------------|
|
| 62 |
+
| Ministral 3 3B Base 2512 | Base pre-trained | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-3B-Base-2512) |
|
| 63 |
+
| Ministral 3 3B Instruct 2512 | Instruct post-trained | FP8 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-3B-Instruct-2512) |
|
| 64 |
+
| Ministral 3 3B Reasoning 2512 | Reasoning capable | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-3B-Reasoning-2512) |
|
| 65 |
+
| Ministral 3 8B Base 2512 | Base pre-trained | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-8B-Base-2512) |
|
| 66 |
+
| Ministral 3 8B Instruct 2512 | Instruct post-trained | FP8 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-8B-Instruct-2512) |
|
| 67 |
+
| Ministral 3 8B Reasoning 2512 | Reasoning capable | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-8B-Reasoning-2512) |
|
| 68 |
+
| Ministral 3 14B Base 2512 | Base pre-trained | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-14B-Base-2512) |
|
| 69 |
+
| Ministral 3 14B Instruct 2512 | Instruct post-trained | FP8 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-14B-Instruct-2512) |
|
| 70 |
+
| **Ministral 3 14B Reasoning 2512** | **Reasoning capable** | **BF16** | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-14B-Reasoning-2512) |
|
| 71 |
+
|
| 72 |
+
Other formats available [here](https://huggingface.co/collections/mistralai/ministral-3-additional-checkpoints).
|
| 73 |
+
|
| 74 |
+
## Benchmark Results
|
| 75 |
+
|
| 76 |
+
We compare Ministral 3 to similar sized models.
|
| 77 |
+
|
| 78 |
+
### Reasoning
|
| 79 |
+
|
| 80 |
+
| Model | AIME25 | AIME24 | GPQA Diamond | LiveCodeBench |
|
| 81 |
+
|---------------------------|-------------|-------------|--------------|---------------|
|
| 82 |
+
| **Ministral 3 14B** | <u>0.850</u>| <u>0.898</u>| <u>0.712</u> | <u>0.646</u> |
|
| 83 |
+
| Qwen3-14B (Thinking) | 0.737 | 0.837 | 0.663 | 0.593 |
|
| 84 |
+
| | | | | |
|
| 85 |
+
| **Ministral 3 8B** | 0.787 | <u>0.860</u>| 0.668 | <u>0.616</u> |
|
| 86 |
+
| Qwen3-VL-8B-Thinking | <u>0.798</u>| <u>0.860</u>| <u>0.671</u> | 0.580 |
|
| 87 |
+
| | | | | |
|
| 88 |
+
| **Ministral 3 3B** | <u>0.721</u>| <u>0.775</u>| 0.534 | <u>0.548</u> |
|
| 89 |
+
| Qwen3-VL-4B-Thinking | 0.697 | 0.729 | <u>0.601</u> | 0.513 |
|
| 90 |
+
|
| 91 |
+
### Instruct
|
| 92 |
+
|
| 93 |
+
| Model | Arena Hard | WildBench | MATH Maj@1 | MM MTBench |
|
| 94 |
+
|---------------------------|-------------|------------|-------------|------------------|
|
| 95 |
+
| **Ministral 3 14B** | <u>0.551</u>| <u>68.5</u>| <u>0.904</u>| <u>8.49</u> |
|
| 96 |
+
| Qwen3 14B (Non-Thinking) | 0.427 | 65.1 | 0.870 | NOT MULTIMODAL |
|
| 97 |
+
| Gemma3-12B-Instruct | 0.436 | 63.2 | 0.854 | 6.70 |
|
| 98 |
+
| | | | | |
|
| 99 |
+
| **Ministral 3 8B** | 0.509 | <u>66.8</u>| 0.876 | <u>8.08</u> |
|
| 100 |
+
| Qwen3-VL-8B-Instruct | <u>0.528</u>| 66.3 | <u>0.946</u>| 8.00 |
|
| 101 |
+
| | | | | |
|
| 102 |
+
| **Ministral 3 3B** | 0.305 | <u>56.8</u>| 0.830 | 7.83 |
|
| 103 |
+
| Qwen3-VL-4B-Instruct | <u>0.438</u>| <u>56.8</u>| <u>0.900</u>| <u>8.01</u> |
|
| 104 |
+
| Qwen3-VL-2B-Instruct | 0.163 | 42.2 | 0.786 | 6.36 |
|
| 105 |
+
| Gemma3-4B-Instruct | 0.318 | 49.1 | 0.759 | 5.23 |
|
| 106 |
+
|
| 107 |
+
### Base
|
| 108 |
+
|
| 109 |
+
| Model | Multilingual MMLU | MATH CoT 2-Shot | AGIEval 5-shot | MMLU Redux 5-shot | MMLU 5-shot | TriviaQA 5-shot |
|
| 110 |
+
|---------------------|-------------------|-----------------|----------------|-------------------|-------------|-----------------|
|
| 111 |
+
| **Ministral 3 14B** | 0.742 | <u>0.676</u> | 0.648 | 0.820 | 0.794 | 0.749 |
|
| 112 |
+
| Qwen3 14B Base | <u>0.754</u> | 0.620 | <u>0.661</u> | <u>0.837</u> | <u>0.804</u>| 0.703 |
|
| 113 |
+
| Gemma 3 12B Base | 0.690 | 0.487 | 0.587 | 0.766 | 0.745 | <u>0.788</u> |
|
| 114 |
+
| | | | | | | |
|
| 115 |
+
| **Ministral 3 8B** | <u>0.706</u> | <u>0.626</u> | 0.591 | 0.793 | <u>0.761</u>| <u>0.681</u> |
|
| 116 |
+
| Qwen 3 8B Base | 0.700 | 0.576 | <u>0.596</u> | <u>0.794</u> | 0.760 | 0.639 |
|
| 117 |
+
| | | | | | | |
|
| 118 |
+
| **Ministral 3 3B** | 0.652 | <u>0.601</u> | 0.511 | 0.735 | 0.707 | 0.592 |
|
| 119 |
+
| Qwen 3 4B Base | <u>0.677</u> | 0.405 | <u>0.570</u> | <u>0.759</u> | <u>0.713</u>| 0.530 |
|
| 120 |
+
| Gemma 3 4B Base | 0.516 | 0.294 | 0.430 | 0.626 | 0.589 | <u>0.640</u> |
|
| 121 |
+
|
| 122 |
+
## Usage
|
| 123 |
+
|
| 124 |
+
The model can be used with the following frameworks;
|
| 125 |
+
- [`vllm`](https://github.com/vllm-project/vllm): See [here](#vllm)
|
| 126 |
+
- [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
|
| 127 |
+
|
| 128 |
+
### vLLM
|
| 129 |
+
|
| 130 |
+
We recommend using this model with [vLLM](https://github.com/vllm-project/vllm).
|
| 131 |
+
|
| 132 |
+
#### Installation
|
| 133 |
+
|
| 134 |
+
Make sure to install most recent vllm:
|
| 135 |
+
|
| 136 |
+
```
|
| 137 |
+
uv pip install -U vllm \
|
| 138 |
+
--torch-backend=auto \
|
| 139 |
+
--extra-index-url https://wheels.vllm.ai/nightly
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
Doing so should automatically install [`mistral_common >= 1.8.6`](https://github.com/mistralai/mistral-common/releases/tag/v1.8.6).
|
| 143 |
+
|
| 144 |
+
To check:
|
| 145 |
+
```
|
| 146 |
+
python -c "import mistral_common; print(mistral_common.__version__)"
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
You can also make use of a ready-to-go [docker image](https://github.com/vllm-project/vllm/blob/main/Dockerfile) or on the [docker hub](https://hub.docker.com/layers/vllm/vllm-openai/latest/images/sha256-de9032a92ffea7b5c007dad80b38fd44aac11eddc31c435f8e52f3b7404bbf39).
|
| 150 |
+
|
| 151 |
+
#### Serve
|
| 152 |
+
|
| 153 |
+
To fully exploit the `Ministral-3-14B-Reasoning-2512` we recommed using 2xH200 GPUs for deployment due to its large context. However if you don't need a large context, you can fall back to a single GPU.
|
| 154 |
+
|
| 155 |
+
A simple launch command is:
|
| 156 |
+
|
| 157 |
+
```bash
|
| 158 |
+
|
| 159 |
+
vllm serve mistralai/Ministral-3-14B-Reasoning-2512 \
|
| 160 |
+
--tensor-parallel-size 2 \
|
| 161 |
+
--tokenizer_mode mistral --config_format mistral --load_format mistral \
|
| 162 |
+
--enable-auto-tool-choice --tool-call-parser mistral \
|
| 163 |
+
--reasoning-parser mistral
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
Key parameter notes:
|
| 167 |
+
|
| 168 |
+
* enable-auto-tool-choice: Required when enabling tool usage.
|
| 169 |
+
* tool-call-parser mistral: Required when enabling tool usage.
|
| 170 |
+
* reasoning-parser mistral: Required when enabling reasoning.
|
| 171 |
+
|
| 172 |
+
Additional flags:
|
| 173 |
+
|
| 174 |
+
* You can set `--max-model-len` to preserve memory. By default it is set to `262144` which is quite large but not necessary for most scenarios.
|
| 175 |
+
* You can set `--max-num-batched-tokens` to balance throughput and latency, higher means higher throughput but higher latency.
|
| 176 |
+
|
| 177 |
+
#### Usage of the model
|
| 178 |
+
|
| 179 |
+
Here we asumme that the model `mistralai/Ministral-3-8B-Reasoning-2512` is served and you can ping it to the domain `localhost` with the port `8000` which is the default for vLLM.
|
| 180 |
+
|
| 181 |
+
<details>
|
| 182 |
+
<summary>Vision Reasoning</summary>
|
| 183 |
+
|
| 184 |
+
Let's see if the Ministral 3 model knows when to pick a fight !
|
| 185 |
+
|
| 186 |
+
```python
|
| 187 |
+
from typing import Any
|
| 188 |
+
|
| 189 |
+
from openai import OpenAI
|
| 190 |
+
from huggingface_hub import hf_hub_download
|
| 191 |
+
|
| 192 |
+
# Modify OpenAI's API key and API base to use vLLM's API server.
|
| 193 |
+
openai_api_key = "EMPTY"
|
| 194 |
+
openai_api_base = "http://localhost:8000/v1"
|
| 195 |
+
|
| 196 |
+
TEMP = 0.7
|
| 197 |
+
TOP_P = 0.95
|
| 198 |
+
MAX_TOK = 262144
|
| 199 |
+
client = OpenAI(
|
| 200 |
+
api_key=openai_api_key,
|
| 201 |
+
base_url=openai_api_base,
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
models = client.models.list()
|
| 205 |
+
model = models.data[0].id
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def load_system_prompt(repo_id: str, filename: str) -> dict[str, Any]:
|
| 209 |
+
file_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 210 |
+
with open(file_path, "r") as file:
|
| 211 |
+
system_prompt = file.read()
|
| 212 |
+
|
| 213 |
+
index_begin_think = system_prompt.find("[THINK]")
|
| 214 |
+
index_end_think = system_prompt.find("[/THINK]")
|
| 215 |
+
|
| 216 |
+
return {
|
| 217 |
+
"role": "system",
|
| 218 |
+
"content": [
|
| 219 |
+
{"type": "text", "text": system_prompt[:index_begin_think]},
|
| 220 |
+
{
|
| 221 |
+
"type": "thinking",
|
| 222 |
+
"thinking": system_prompt[
|
| 223 |
+
index_begin_think + len("[THINK]") : index_end_think
|
| 224 |
+
],
|
| 225 |
+
"closed": True,
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"type": "text",
|
| 229 |
+
"text": system_prompt[index_end_think + len("[/THINK]") :],
|
| 230 |
+
},
|
| 231 |
+
],
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
|
| 236 |
+
|
| 237 |
+
image_url = "https://static.wikia.nocookie.net/essentialsdocs/images/7/70/Battle.png/revision/latest?cb=20220523172438"
|
| 238 |
+
|
| 239 |
+
messages = [
|
| 240 |
+
SYSTEM_PROMPT,
|
| 241 |
+
{
|
| 242 |
+
"role": "user",
|
| 243 |
+
"content": [
|
| 244 |
+
{
|
| 245 |
+
"type": "text",
|
| 246 |
+
"text": "What action do you think I should take in this situation? List all the possible actions and explain why you think they are good or bad.",
|
| 247 |
+
},
|
| 248 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 249 |
+
],
|
| 250 |
+
},
|
| 251 |
+
]
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
stream = client.chat.completions.create(
|
| 255 |
+
model=model,
|
| 256 |
+
messages=messages,
|
| 257 |
+
stream=True,
|
| 258 |
+
temperature=TEMP,
|
| 259 |
+
top_p=TOP_P,
|
| 260 |
+
max_tokens=MAX_TOK,
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
print("client: Start streaming chat completions...:\n")
|
| 264 |
+
printed_reasoning_content = False
|
| 265 |
+
answer = []
|
| 266 |
+
|
| 267 |
+
for chunk in stream:
|
| 268 |
+
reasoning_content = None
|
| 269 |
+
content = None
|
| 270 |
+
# Check the content is reasoning_content or content
|
| 271 |
+
if hasattr(chunk.choices[0].delta, "reasoning_content"):
|
| 272 |
+
reasoning_content = chunk.choices[0].delta.reasoning_content
|
| 273 |
+
if hasattr(chunk.choices[0].delta, "content"):
|
| 274 |
+
content = chunk.choices[0].delta.content
|
| 275 |
+
|
| 276 |
+
if reasoning_content is not None:
|
| 277 |
+
if not printed_reasoning_content:
|
| 278 |
+
printed_reasoning_content = True
|
| 279 |
+
print("Start reasoning:\n", end="", flush=True)
|
| 280 |
+
print(reasoning_content, end="", flush=True)
|
| 281 |
+
elif content is not None:
|
| 282 |
+
# Extract and print the content
|
| 283 |
+
if not reasoning_content and printed_reasoning_content:
|
| 284 |
+
answer.extend(content)
|
| 285 |
+
print(content, end="", flush=True)
|
| 286 |
+
|
| 287 |
+
if answer:
|
| 288 |
+
print("\n\n=============\nAnswer\n=============\n")
|
| 289 |
+
print("".join(answer))
|
| 290 |
+
else:
|
| 291 |
+
print("\n\n=============\nNo Answer\n=============\n")
|
| 292 |
+
print(
|
| 293 |
+
"No answer was generated by the model, probably because the maximum number of tokens was reached."
|
| 294 |
+
)
|
| 295 |
+
```
|
| 296 |
+
|
| 297 |
+
Now we'll make it compute some maths !
|
| 298 |
+
|
| 299 |
+
```python
|
| 300 |
+
from typing import Any
|
| 301 |
+
|
| 302 |
+
from openai import OpenAI
|
| 303 |
+
from huggingface_hub import hf_hub_download
|
| 304 |
+
|
| 305 |
+
# Modify OpenAI's API key and API base to use vLLM's API server.
|
| 306 |
+
openai_api_key = "EMPTY"
|
| 307 |
+
openai_api_base = "http://localhost:8000/v1"
|
| 308 |
+
|
| 309 |
+
TEMP = 0.7
|
| 310 |
+
TOP_P = 0.95
|
| 311 |
+
MAX_TOK = 262144
|
| 312 |
+
client = OpenAI(
|
| 313 |
+
api_key=openai_api_key,
|
| 314 |
+
base_url=openai_api_base,
|
| 315 |
+
)
|
| 316 |
+
|
| 317 |
+
models = client.models.list()
|
| 318 |
+
model = models.data[0].id
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
def load_system_prompt(repo_id: str, filename: str) -> dict[str, Any]:
|
| 322 |
+
file_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 323 |
+
with open(file_path, "r") as file:
|
| 324 |
+
system_prompt = file.read()
|
| 325 |
+
|
| 326 |
+
index_begin_think = system_prompt.find("[THINK]")
|
| 327 |
+
index_end_think = system_prompt.find("[/THINK]")
|
| 328 |
+
|
| 329 |
+
return {
|
| 330 |
+
"role": "system",
|
| 331 |
+
"content": [
|
| 332 |
+
{"type": "text", "text": system_prompt[:index_begin_think]},
|
| 333 |
+
{
|
| 334 |
+
"type": "thinking",
|
| 335 |
+
"thinking": system_prompt[
|
| 336 |
+
index_begin_think + len("[THINK]") : index_end_think
|
| 337 |
+
],
|
| 338 |
+
"closed": True,
|
| 339 |
+
},
|
| 340 |
+
{
|
| 341 |
+
"type": "text",
|
| 342 |
+
"text": system_prompt[index_end_think + len("[/THINK]") :],
|
| 343 |
+
},
|
| 344 |
+
],
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
|
| 349 |
+
|
| 350 |
+
image_url = "https://i.ytimg.com/vi/5Y3xLHeyKZU/hqdefault.jpg"
|
| 351 |
+
|
| 352 |
+
messages = [
|
| 353 |
+
SYSTEM_PROMPT,
|
| 354 |
+
{
|
| 355 |
+
"role": "user",
|
| 356 |
+
"content": [
|
| 357 |
+
{
|
| 358 |
+
"type": "text",
|
| 359 |
+
"text": "Solve the equations. If they contain only numbers, use your calculator, else only think. Answer in the language of the image.",
|
| 360 |
+
},
|
| 361 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 362 |
+
],
|
| 363 |
+
},
|
| 364 |
+
]
|
| 365 |
+
|
| 366 |
+
stream = client.chat.completions.create(
|
| 367 |
+
model=model,
|
| 368 |
+
messages=messages,
|
| 369 |
+
stream=True,
|
| 370 |
+
temperature=TEMP,
|
| 371 |
+
top_p=TOP_P,
|
| 372 |
+
max_tokens=MAX_TOK,
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
print("client: Start streaming chat completions...:\n")
|
| 376 |
+
printed_reasoning_content = False
|
| 377 |
+
answer = []
|
| 378 |
+
|
| 379 |
+
for chunk in stream:
|
| 380 |
+
reasoning_content = None
|
| 381 |
+
content = None
|
| 382 |
+
# Check the content is reasoning_content or content
|
| 383 |
+
if hasattr(chunk.choices[0].delta, "reasoning_content"):
|
| 384 |
+
reasoning_content = chunk.choices[0].delta.reasoning_content
|
| 385 |
+
if hasattr(chunk.choices[0].delta, "content"):
|
| 386 |
+
content = chunk.choices[0].delta.content
|
| 387 |
+
|
| 388 |
+
if reasoning_content is not None:
|
| 389 |
+
if not printed_reasoning_content:
|
| 390 |
+
printed_reasoning_content = True
|
| 391 |
+
print("Start reasoning:\n", end="", flush=True)
|
| 392 |
+
print(reasoning_content, end="", flush=True)
|
| 393 |
+
if content is not None:
|
| 394 |
+
# Extract and print the content
|
| 395 |
+
if not reasoning_content and printed_reasoning_content:
|
| 396 |
+
answer.extend(content)
|
| 397 |
+
print(content, end="", flush=True)
|
| 398 |
+
|
| 399 |
+
if answer:
|
| 400 |
+
print("\n\n=============\nAnswer\n=============\n")
|
| 401 |
+
print("".join(answer))
|
| 402 |
+
else:
|
| 403 |
+
print("\n\n=============\nNo Answer\n=============\n")
|
| 404 |
+
print(
|
| 405 |
+
"No answer was generated by the model, probably because the maximum number of tokens was reached."
|
| 406 |
+
)
|
| 407 |
+
```
|
| 408 |
+
|
| 409 |
+
</details>
|
| 410 |
+
|
| 411 |
+
<details>
|
| 412 |
+
<summary>Text-Only Request</summary>
|
| 413 |
+
|
| 414 |
+
Let's do more maths and leave it up to the model to figure out how to achieve a result.
|
| 415 |
+
|
| 416 |
+
```python
|
| 417 |
+
from typing import Any
|
| 418 |
+
from openai import OpenAI
|
| 419 |
+
from huggingface_hub import hf_hub_download
|
| 420 |
+
|
| 421 |
+
# Modify OpenAI's API key and API base to use vLLM's API server.
|
| 422 |
+
openai_api_key = "EMPTY"
|
| 423 |
+
openai_api_base = "http://localhost:8000/v1"
|
| 424 |
+
|
| 425 |
+
TEMP = 0.7
|
| 426 |
+
TOP_P = 0.95
|
| 427 |
+
MAX_TOK = 262144
|
| 428 |
+
client = OpenAI(
|
| 429 |
+
api_key=openai_api_key,
|
| 430 |
+
base_url=openai_api_base,
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
models = client.models.list()
|
| 434 |
+
model = models.data[0].id
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
def load_system_prompt(repo_id: str, filename: str) -> dict[str, Any]:
|
| 438 |
+
file_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 439 |
+
with open(file_path, "r") as file:
|
| 440 |
+
system_prompt = file.read()
|
| 441 |
+
|
| 442 |
+
index_begin_think = system_prompt.find("[THINK]")
|
| 443 |
+
index_end_think = system_prompt.find("[/THINK]")
|
| 444 |
+
|
| 445 |
+
return {
|
| 446 |
+
"role": "system",
|
| 447 |
+
"content": [
|
| 448 |
+
{"type": "text", "text": system_prompt[:index_begin_think]},
|
| 449 |
+
{
|
| 450 |
+
"type": "thinking",
|
| 451 |
+
"thinking": system_prompt[
|
| 452 |
+
index_begin_think + len("[THINK]") : index_end_think
|
| 453 |
+
],
|
| 454 |
+
"closed": True,
|
| 455 |
+
},
|
| 456 |
+
{
|
| 457 |
+
"type": "text",
|
| 458 |
+
"text": system_prompt[index_end_think + len("[/THINK]") :],
|
| 459 |
+
},
|
| 460 |
+
],
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
|
| 465 |
+
|
| 466 |
+
query = "Use each number in 2,5,6,3 exactly once, along with any combination of +, -, ×, ÷ (and parentheses for grouping), to make the number 24."
|
| 467 |
+
|
| 468 |
+
messages = [
|
| 469 |
+
SYSTEM_PROMPT,
|
| 470 |
+
{"role": "user", "content": query}
|
| 471 |
+
]
|
| 472 |
+
stream = client.chat.completions.create(
|
| 473 |
+
model=model,
|
| 474 |
+
messages=messages,
|
| 475 |
+
stream=True,
|
| 476 |
+
temperature=TEMP,
|
| 477 |
+
top_p=TOP_P,
|
| 478 |
+
max_tokens=MAX_TOK,
|
| 479 |
+
)
|
| 480 |
+
|
| 481 |
+
print("client: Start streaming chat completions...:\n")
|
| 482 |
+
printed_reasoning_content = False
|
| 483 |
+
answer = []
|
| 484 |
+
|
| 485 |
+
for chunk in stream:
|
| 486 |
+
reasoning_content = None
|
| 487 |
+
content = None
|
| 488 |
+
# Check the content is reasoning_content or content
|
| 489 |
+
if hasattr(chunk.choices[0].delta, "reasoning_content"):
|
| 490 |
+
reasoning_content = chunk.choices[0].delta.reasoning_content
|
| 491 |
+
if hasattr(chunk.choices[0].delta, "content"):
|
| 492 |
+
content = chunk.choices[0].delta.content
|
| 493 |
+
|
| 494 |
+
if reasoning_content is not None:
|
| 495 |
+
if not printed_reasoning_content:
|
| 496 |
+
printed_reasoning_content = True
|
| 497 |
+
print("Start reasoning:\n", end="", flush=True)
|
| 498 |
+
print(reasoning_content, end="", flush=True)
|
| 499 |
+
if content is not None:
|
| 500 |
+
# Extract and print the content
|
| 501 |
+
if not reasoning_content and printed_reasoning_content:
|
| 502 |
+
answer.extend(content)
|
| 503 |
+
print(content, end="", flush=True)
|
| 504 |
+
|
| 505 |
+
if answer:
|
| 506 |
+
print("\n\n=============\nAnswer\n=============\n")
|
| 507 |
+
print("".join(answer))
|
| 508 |
+
else:
|
| 509 |
+
print("\n\n=============\nNo Answer\n=============\n")
|
| 510 |
+
print("No answer was generated by the model, probably because the maximum number of tokens was reached.")
|
| 511 |
+
```
|
| 512 |
+
|
| 513 |
+
</details>
|
| 514 |
+
|
| 515 |
+
### Transformers
|
| 516 |
+
|
| 517 |
+
You can also use Ministral 3 3B Reasoning 2512 with `Transformers` !
|
| 518 |
+
Make sure to install `Transformers` from its first v5 release candidate or from "main":
|
| 519 |
+
|
| 520 |
+
```
|
| 521 |
+
pip install transformers==5.0.0rc0
|
| 522 |
+
```
|
| 523 |
+
|
| 524 |
+
To make the best use of our model with `Transformers` make sure to have [installed](https://github.com/mistralai/mistral-common) `mistral-common >= 1.8.6` to use our tokenizer.
|
| 525 |
+
|
| 526 |
+
```bash
|
| 527 |
+
pip install mistral-common --upgrade
|
| 528 |
+
```
|
| 529 |
+
|
| 530 |
+
Then load our tokenizer along with the model and generate:
|
| 531 |
+
|
| 532 |
+
<details>
|
| 533 |
+
<summary>Python snippet</summary>
|
| 534 |
+
|
| 535 |
+
```python
|
| 536 |
+
import torch
|
| 537 |
+
from transformers import Mistral3ForConditionalGeneration, MistralCommonBackend
|
| 538 |
+
|
| 539 |
+
model_id = "mistralai/Ministral-3-14B-Reasoning-2512"
|
| 540 |
+
|
| 541 |
+
tokenizer = MistralCommonBackend.from_pretrained(model_id)
|
| 542 |
+
model = Mistral3ForConditionalGeneration.from_pretrained(
|
| 543 |
+
model_id, torch_dtype=torch.bfloat16, device_map="auto"
|
| 544 |
+
)
|
| 545 |
+
|
| 546 |
+
image_url = "https://static.wikia.nocookie.net/essentialsdocs/images/7/70/Battle.png/revision/latest?cb=20220523172438"
|
| 547 |
+
|
| 548 |
+
messages = [
|
| 549 |
+
{
|
| 550 |
+
"role": "user",
|
| 551 |
+
"content": [
|
| 552 |
+
{
|
| 553 |
+
"type": "text",
|
| 554 |
+
"text": "What action do you think I should take in this situation? List all the possible actions and explain why you think they are good or bad.",
|
| 555 |
+
},
|
| 556 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 557 |
+
],
|
| 558 |
+
},
|
| 559 |
+
]
|
| 560 |
+
|
| 561 |
+
tokenized = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True)
|
| 562 |
+
|
| 563 |
+
tokenized["input_ids"] = tokenized["input_ids"].to(device="cuda")
|
| 564 |
+
tokenized["pixel_values"] = tokenized["pixel_values"].to(dtype=torch.bfloat16, device="cuda")
|
| 565 |
+
image_sizes = [tokenized["pixel_values"].shape[-2:]]
|
| 566 |
+
|
| 567 |
+
output = model.generate(
|
| 568 |
+
**tokenized,
|
| 569 |
+
image_sizes=image_sizes,
|
| 570 |
+
max_new_tokens=8092,
|
| 571 |
+
)[0]
|
| 572 |
+
|
| 573 |
+
decoded_output = tokenizer.decode(output[len(tokenized["input_ids"][0]):])
|
| 574 |
+
print(decoded_output)
|
| 575 |
+
```
|
| 576 |
+
|
| 577 |
+
</details>
|
| 578 |
+
|
| 579 |
+
## License
|
| 580 |
+
|
| 581 |
+
This model is licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0.txt).
|
| 582 |
+
|
| 583 |
+
*You must not use this model in a manner that infringes, misappropriates, or otherwise violates any third party’s rights, including intellectual property rights.*
|
SYSTEM_PROMPT.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HOW YOU SHOULD THINK AND ANSWER
|
| 2 |
+
|
| 3 |
+
First draft your thinking process (inner monologue) until you arrive at a response. Format your response using Markdown, and use LaTeX for any mathematical equations. Write both your thoughts and the response in the same language as the input.
|
| 4 |
+
|
| 5 |
+
Your thinking process must follow the template below:[THINK]Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate the response to the user.[/THINK]Here, provide a self-contained response.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{#- Default system message if no system prompt is passed. #}
|
| 2 |
+
{%- set default_system_message = '# HOW YOU SHOULD THINK AND ANSWER\n\nFirst draft your thinking process (inner monologue) until you arrive at a response. Format your response using Markdown, and use LaTeX for any mathematical equations. Write both your thoughts and the response in the same language as the input.\n\nYour thinking process must follow the template below:[THINK]Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate the response to the user.[/THINK]Here, provide a self-contained response.' %}
|
| 3 |
+
|
| 4 |
+
{#- Begin of sequence token. #}
|
| 5 |
+
{{- bos_token }}
|
| 6 |
+
|
| 7 |
+
{#- Handle system prompt if it exists. #}
|
| 8 |
+
{#- System prompt supports text content or text and thinking chunks. #}
|
| 9 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 10 |
+
{{- '[SYSTEM_PROMPT]' -}}
|
| 11 |
+
{%- if messages[0]['content'] is string %}
|
| 12 |
+
{{- messages[0]['content'] -}}
|
| 13 |
+
{%- else %}
|
| 14 |
+
{%- for block in messages[0]['content'] %}
|
| 15 |
+
{%- if block['type'] == 'text' %}
|
| 16 |
+
{{- block['text'] }}
|
| 17 |
+
{%- elif block['type'] == 'thinking' %}
|
| 18 |
+
{{- '[THINK]' + block['thinking'] + '[/THINK]' }}
|
| 19 |
+
{%- else %}
|
| 20 |
+
{{- raise_exception('Only text and thinking chunks are supported in system message contents.') }}
|
| 21 |
+
{%- endif %}
|
| 22 |
+
{%- endfor %}
|
| 23 |
+
{%- endif %}
|
| 24 |
+
{{- '[/SYSTEM_PROMPT]' -}}
|
| 25 |
+
{%- set loop_messages = messages[1:] %}
|
| 26 |
+
{%- else %}
|
| 27 |
+
{%- set loop_messages = messages %}
|
| 28 |
+
{%- if default_system_message != '' %}
|
| 29 |
+
{{- '[SYSTEM_PROMPT]' + default_system_message + '[/SYSTEM_PROMPT]' }}
|
| 30 |
+
{%- endif %}
|
| 31 |
+
{%- endif %}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
{#- Tools definition #}
|
| 35 |
+
{%- set tools_definition = '' %}
|
| 36 |
+
{%- set has_tools = false %}
|
| 37 |
+
{%- if tools is defined and tools is not none and tools|length > 0 %}
|
| 38 |
+
{%- set has_tools = true %}
|
| 39 |
+
{%- set tools_definition = '[AVAILABLE_TOOLS]' + (tools| tojson) + '[/AVAILABLE_TOOLS]' %}
|
| 40 |
+
{{- tools_definition }}
|
| 41 |
+
{%- endif %}
|
| 42 |
+
|
| 43 |
+
{#- Checks for alternating user/assistant messages. #}
|
| 44 |
+
{%- set ns = namespace(index=0) %}
|
| 45 |
+
{%- for message in loop_messages %}
|
| 46 |
+
{%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}
|
| 47 |
+
{%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}
|
| 48 |
+
{{- raise_exception('After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results.') }}
|
| 49 |
+
{%- endif %}
|
| 50 |
+
{%- set ns.index = ns.index + 1 %}
|
| 51 |
+
{%- endif %}
|
| 52 |
+
{%- endfor %}
|
| 53 |
+
|
| 54 |
+
{#- Handle conversation messages. #}
|
| 55 |
+
{%- for message in loop_messages %}
|
| 56 |
+
|
| 57 |
+
{#- User messages supports text content or text and image chunks. #}
|
| 58 |
+
{%- if message['role'] == 'user' %}
|
| 59 |
+
{%- if message['content'] is string %}
|
| 60 |
+
{{- '[INST]' + message['content'] + '[/INST]' }}
|
| 61 |
+
{%- elif message['content'] | length > 0 %}
|
| 62 |
+
{{- '[INST]' }}
|
| 63 |
+
{%- if message['content'] | length == 2 %}
|
| 64 |
+
{%- set blocks = message['content'] | sort(attribute='type') %}
|
| 65 |
+
{%- else %}
|
| 66 |
+
{%- set blocks = message['content'] %}
|
| 67 |
+
{%- endif %}
|
| 68 |
+
{%- for block in blocks %}
|
| 69 |
+
{%- if block['type'] == 'text' %}
|
| 70 |
+
{{- block['text'] }}
|
| 71 |
+
{%- elif block['type'] in ['image', 'image_url'] %}
|
| 72 |
+
{{- '[IMG]' }}
|
| 73 |
+
{%- else %}
|
| 74 |
+
{{- raise_exception('Only text, image and image_url chunks are supported in user message content.') }}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endfor %}
|
| 77 |
+
{{- '[/INST]' }}
|
| 78 |
+
{%- else %}
|
| 79 |
+
{{- raise_exception('User message must have a string or a list of chunks in content') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
|
| 82 |
+
{#- Assistant messages supports text content or text, image and thinking chunks. #}
|
| 83 |
+
{%- elif message['role'] == 'assistant' %}
|
| 84 |
+
{%- if (message['content'] is none or message['content'] == '' or message['content']|length == 0) and (message['tool_calls'] is not defined or message['tool_calls'] is none or message['tool_calls']|length == 0) %}
|
| 85 |
+
{{- raise_exception('Assistant message must have a string or a list of chunks in content or a list of tool calls.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
|
| 88 |
+
{%- if message['content'] is string and message['content'] != '' %}
|
| 89 |
+
{{- message['content'] }}
|
| 90 |
+
{%- elif message['content'] | length > 0 %}
|
| 91 |
+
{%- for block in message['content'] %}
|
| 92 |
+
{%- if block['type'] == 'text' %}
|
| 93 |
+
{{- block['text'] }}
|
| 94 |
+
{%- elif block['type'] == 'thinking' %}
|
| 95 |
+
{{- '[THINK]' + block['thinking'] + '[/THINK]' }}
|
| 96 |
+
{%- else %}
|
| 97 |
+
{{- raise_exception('Only text and thinking chunks are supported in assistant message contents.') }}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- endfor %}
|
| 100 |
+
{%- endif %}
|
| 101 |
+
|
| 102 |
+
{%- if message['tool_calls'] is defined and message['tool_calls'] is not none and message['tool_calls']|length > 0 %}
|
| 103 |
+
{%- for tool in message['tool_calls'] %}
|
| 104 |
+
{{- '[TOOL_CALLS]' }}
|
| 105 |
+
{%- set name = tool['function']['name'] %}
|
| 106 |
+
{%- set arguments = tool['function']['arguments'] %}
|
| 107 |
+
{%- if arguments is not string %}
|
| 108 |
+
{%- set arguments = arguments|tojson|safe %}
|
| 109 |
+
{%- elif arguments == '' %}
|
| 110 |
+
{%- set arguments = '{}' %}
|
| 111 |
+
{%- endif %}
|
| 112 |
+
{{- name + '[ARGS]' + arguments }}
|
| 113 |
+
{%- endfor %}
|
| 114 |
+
{%- endif %}
|
| 115 |
+
|
| 116 |
+
{{- eos_token }}
|
| 117 |
+
|
| 118 |
+
{#- Tool messages only supports text content. #}
|
| 119 |
+
{%- elif message['role'] == 'tool' %}
|
| 120 |
+
{{- '[TOOL_RESULTS]' + message['content']|string + '[/TOOL_RESULTS]' }}
|
| 121 |
+
|
| 122 |
+
{#- Raise exception for unsupported roles. #}
|
| 123 |
+
{%- else %}
|
| 124 |
+
{{- raise_exception('Only user, assistant and tool roles are supported, got ' + message['role'] + '.') }}
|
| 125 |
+
{%- endif %}
|
| 126 |
+
{%- endfor %}
|
config.json
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Mistral3ForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"dtype": "bfloat16",
|
| 6 |
+
"image_token_index": 10,
|
| 7 |
+
"model_type": "mistral3",
|
| 8 |
+
"multimodal_projector_bias": false,
|
| 9 |
+
"projector_hidden_act": "gelu",
|
| 10 |
+
"quantization_config": {
|
| 11 |
+
"config_groups": {
|
| 12 |
+
"group_0": {
|
| 13 |
+
"format": "pack-quantized",
|
| 14 |
+
"input_activations": null,
|
| 15 |
+
"output_activations": null,
|
| 16 |
+
"targets": [
|
| 17 |
+
"Linear"
|
| 18 |
+
],
|
| 19 |
+
"weights": {
|
| 20 |
+
"actorder": null,
|
| 21 |
+
"block_structure": null,
|
| 22 |
+
"dynamic": false,
|
| 23 |
+
"group_size": 32,
|
| 24 |
+
"num_bits": 4,
|
| 25 |
+
"observer": "mse",
|
| 26 |
+
"observer_kwargs": {},
|
| 27 |
+
"strategy": "group",
|
| 28 |
+
"symmetric": true,
|
| 29 |
+
"type": "int"
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"format": "pack-quantized",
|
| 34 |
+
"global_compression_ratio": null,
|
| 35 |
+
"ignore": [
|
| 36 |
+
"model.vision_tower.transformer.layers.0.feed_forward.gate_proj",
|
| 37 |
+
"model.vision_tower.transformer.layers.0.feed_forward.up_proj",
|
| 38 |
+
"model.vision_tower.transformer.layers.0.feed_forward.down_proj",
|
| 39 |
+
"model.vision_tower.transformer.layers.0.attention.k_proj",
|
| 40 |
+
"model.vision_tower.transformer.layers.0.attention.v_proj",
|
| 41 |
+
"model.vision_tower.transformer.layers.0.attention.q_proj",
|
| 42 |
+
"model.vision_tower.transformer.layers.0.attention.o_proj",
|
| 43 |
+
"model.vision_tower.transformer.layers.1.feed_forward.gate_proj",
|
| 44 |
+
"model.vision_tower.transformer.layers.1.feed_forward.up_proj",
|
| 45 |
+
"model.vision_tower.transformer.layers.1.feed_forward.down_proj",
|
| 46 |
+
"model.vision_tower.transformer.layers.1.attention.k_proj",
|
| 47 |
+
"model.vision_tower.transformer.layers.1.attention.v_proj",
|
| 48 |
+
"model.vision_tower.transformer.layers.1.attention.q_proj",
|
| 49 |
+
"model.vision_tower.transformer.layers.1.attention.o_proj",
|
| 50 |
+
"model.vision_tower.transformer.layers.2.feed_forward.gate_proj",
|
| 51 |
+
"model.vision_tower.transformer.layers.2.feed_forward.up_proj",
|
| 52 |
+
"model.vision_tower.transformer.layers.2.feed_forward.down_proj",
|
| 53 |
+
"model.vision_tower.transformer.layers.2.attention.k_proj",
|
| 54 |
+
"model.vision_tower.transformer.layers.2.attention.v_proj",
|
| 55 |
+
"model.vision_tower.transformer.layers.2.attention.q_proj",
|
| 56 |
+
"model.vision_tower.transformer.layers.2.attention.o_proj",
|
| 57 |
+
"model.vision_tower.transformer.layers.3.feed_forward.gate_proj",
|
| 58 |
+
"model.vision_tower.transformer.layers.3.feed_forward.up_proj",
|
| 59 |
+
"model.vision_tower.transformer.layers.3.feed_forward.down_proj",
|
| 60 |
+
"model.vision_tower.transformer.layers.3.attention.k_proj",
|
| 61 |
+
"model.vision_tower.transformer.layers.3.attention.v_proj",
|
| 62 |
+
"model.vision_tower.transformer.layers.3.attention.q_proj",
|
| 63 |
+
"model.vision_tower.transformer.layers.3.attention.o_proj",
|
| 64 |
+
"model.vision_tower.transformer.layers.4.feed_forward.gate_proj",
|
| 65 |
+
"model.vision_tower.transformer.layers.4.feed_forward.up_proj",
|
| 66 |
+
"model.vision_tower.transformer.layers.4.feed_forward.down_proj",
|
| 67 |
+
"model.vision_tower.transformer.layers.4.attention.k_proj",
|
| 68 |
+
"model.vision_tower.transformer.layers.4.attention.v_proj",
|
| 69 |
+
"model.vision_tower.transformer.layers.4.attention.q_proj",
|
| 70 |
+
"model.vision_tower.transformer.layers.4.attention.o_proj",
|
| 71 |
+
"model.vision_tower.transformer.layers.5.feed_forward.gate_proj",
|
| 72 |
+
"model.vision_tower.transformer.layers.5.feed_forward.up_proj",
|
| 73 |
+
"model.vision_tower.transformer.layers.5.feed_forward.down_proj",
|
| 74 |
+
"model.vision_tower.transformer.layers.5.attention.k_proj",
|
| 75 |
+
"model.vision_tower.transformer.layers.5.attention.v_proj",
|
| 76 |
+
"model.vision_tower.transformer.layers.5.attention.q_proj",
|
| 77 |
+
"model.vision_tower.transformer.layers.5.attention.o_proj",
|
| 78 |
+
"model.vision_tower.transformer.layers.6.feed_forward.gate_proj",
|
| 79 |
+
"model.vision_tower.transformer.layers.6.feed_forward.up_proj",
|
| 80 |
+
"model.vision_tower.transformer.layers.6.feed_forward.down_proj",
|
| 81 |
+
"model.vision_tower.transformer.layers.6.attention.k_proj",
|
| 82 |
+
"model.vision_tower.transformer.layers.6.attention.v_proj",
|
| 83 |
+
"model.vision_tower.transformer.layers.6.attention.q_proj",
|
| 84 |
+
"model.vision_tower.transformer.layers.6.attention.o_proj",
|
| 85 |
+
"model.vision_tower.transformer.layers.7.feed_forward.gate_proj",
|
| 86 |
+
"model.vision_tower.transformer.layers.7.feed_forward.up_proj",
|
| 87 |
+
"model.vision_tower.transformer.layers.7.feed_forward.down_proj",
|
| 88 |
+
"model.vision_tower.transformer.layers.7.attention.k_proj",
|
| 89 |
+
"model.vision_tower.transformer.layers.7.attention.v_proj",
|
| 90 |
+
"model.vision_tower.transformer.layers.7.attention.q_proj",
|
| 91 |
+
"model.vision_tower.transformer.layers.7.attention.o_proj",
|
| 92 |
+
"model.vision_tower.transformer.layers.8.feed_forward.gate_proj",
|
| 93 |
+
"model.vision_tower.transformer.layers.8.feed_forward.up_proj",
|
| 94 |
+
"model.vision_tower.transformer.layers.8.feed_forward.down_proj",
|
| 95 |
+
"model.vision_tower.transformer.layers.8.attention.k_proj",
|
| 96 |
+
"model.vision_tower.transformer.layers.8.attention.v_proj",
|
| 97 |
+
"model.vision_tower.transformer.layers.8.attention.q_proj",
|
| 98 |
+
"model.vision_tower.transformer.layers.8.attention.o_proj",
|
| 99 |
+
"model.vision_tower.transformer.layers.9.feed_forward.gate_proj",
|
| 100 |
+
"model.vision_tower.transformer.layers.9.feed_forward.up_proj",
|
| 101 |
+
"model.vision_tower.transformer.layers.9.feed_forward.down_proj",
|
| 102 |
+
"model.vision_tower.transformer.layers.9.attention.k_proj",
|
| 103 |
+
"model.vision_tower.transformer.layers.9.attention.v_proj",
|
| 104 |
+
"model.vision_tower.transformer.layers.9.attention.q_proj",
|
| 105 |
+
"model.vision_tower.transformer.layers.9.attention.o_proj",
|
| 106 |
+
"model.vision_tower.transformer.layers.10.feed_forward.gate_proj",
|
| 107 |
+
"model.vision_tower.transformer.layers.10.feed_forward.up_proj",
|
| 108 |
+
"model.vision_tower.transformer.layers.10.feed_forward.down_proj",
|
| 109 |
+
"model.vision_tower.transformer.layers.10.attention.k_proj",
|
| 110 |
+
"model.vision_tower.transformer.layers.10.attention.v_proj",
|
| 111 |
+
"model.vision_tower.transformer.layers.10.attention.q_proj",
|
| 112 |
+
"model.vision_tower.transformer.layers.10.attention.o_proj",
|
| 113 |
+
"model.vision_tower.transformer.layers.11.feed_forward.gate_proj",
|
| 114 |
+
"model.vision_tower.transformer.layers.11.feed_forward.up_proj",
|
| 115 |
+
"model.vision_tower.transformer.layers.11.feed_forward.down_proj",
|
| 116 |
+
"model.vision_tower.transformer.layers.11.attention.k_proj",
|
| 117 |
+
"model.vision_tower.transformer.layers.11.attention.v_proj",
|
| 118 |
+
"model.vision_tower.transformer.layers.11.attention.q_proj",
|
| 119 |
+
"model.vision_tower.transformer.layers.11.attention.o_proj",
|
| 120 |
+
"model.vision_tower.transformer.layers.12.feed_forward.gate_proj",
|
| 121 |
+
"model.vision_tower.transformer.layers.12.feed_forward.up_proj",
|
| 122 |
+
"model.vision_tower.transformer.layers.12.feed_forward.down_proj",
|
| 123 |
+
"model.vision_tower.transformer.layers.12.attention.k_proj",
|
| 124 |
+
"model.vision_tower.transformer.layers.12.attention.v_proj",
|
| 125 |
+
"model.vision_tower.transformer.layers.12.attention.q_proj",
|
| 126 |
+
"model.vision_tower.transformer.layers.12.attention.o_proj",
|
| 127 |
+
"model.vision_tower.transformer.layers.13.feed_forward.gate_proj",
|
| 128 |
+
"model.vision_tower.transformer.layers.13.feed_forward.up_proj",
|
| 129 |
+
"model.vision_tower.transformer.layers.13.feed_forward.down_proj",
|
| 130 |
+
"model.vision_tower.transformer.layers.13.attention.k_proj",
|
| 131 |
+
"model.vision_tower.transformer.layers.13.attention.v_proj",
|
| 132 |
+
"model.vision_tower.transformer.layers.13.attention.q_proj",
|
| 133 |
+
"model.vision_tower.transformer.layers.13.attention.o_proj",
|
| 134 |
+
"model.vision_tower.transformer.layers.14.feed_forward.gate_proj",
|
| 135 |
+
"model.vision_tower.transformer.layers.14.feed_forward.up_proj",
|
| 136 |
+
"model.vision_tower.transformer.layers.14.feed_forward.down_proj",
|
| 137 |
+
"model.vision_tower.transformer.layers.14.attention.k_proj",
|
| 138 |
+
"model.vision_tower.transformer.layers.14.attention.v_proj",
|
| 139 |
+
"model.vision_tower.transformer.layers.14.attention.q_proj",
|
| 140 |
+
"model.vision_tower.transformer.layers.14.attention.o_proj",
|
| 141 |
+
"model.vision_tower.transformer.layers.15.feed_forward.gate_proj",
|
| 142 |
+
"model.vision_tower.transformer.layers.15.feed_forward.up_proj",
|
| 143 |
+
"model.vision_tower.transformer.layers.15.feed_forward.down_proj",
|
| 144 |
+
"model.vision_tower.transformer.layers.15.attention.k_proj",
|
| 145 |
+
"model.vision_tower.transformer.layers.15.attention.v_proj",
|
| 146 |
+
"model.vision_tower.transformer.layers.15.attention.q_proj",
|
| 147 |
+
"model.vision_tower.transformer.layers.15.attention.o_proj",
|
| 148 |
+
"model.vision_tower.transformer.layers.16.feed_forward.gate_proj",
|
| 149 |
+
"model.vision_tower.transformer.layers.16.feed_forward.up_proj",
|
| 150 |
+
"model.vision_tower.transformer.layers.16.feed_forward.down_proj",
|
| 151 |
+
"model.vision_tower.transformer.layers.16.attention.k_proj",
|
| 152 |
+
"model.vision_tower.transformer.layers.16.attention.v_proj",
|
| 153 |
+
"model.vision_tower.transformer.layers.16.attention.q_proj",
|
| 154 |
+
"model.vision_tower.transformer.layers.16.attention.o_proj",
|
| 155 |
+
"model.vision_tower.transformer.layers.17.feed_forward.gate_proj",
|
| 156 |
+
"model.vision_tower.transformer.layers.17.feed_forward.up_proj",
|
| 157 |
+
"model.vision_tower.transformer.layers.17.feed_forward.down_proj",
|
| 158 |
+
"model.vision_tower.transformer.layers.17.attention.k_proj",
|
| 159 |
+
"model.vision_tower.transformer.layers.17.attention.v_proj",
|
| 160 |
+
"model.vision_tower.transformer.layers.17.attention.q_proj",
|
| 161 |
+
"model.vision_tower.transformer.layers.17.attention.o_proj",
|
| 162 |
+
"model.vision_tower.transformer.layers.18.feed_forward.gate_proj",
|
| 163 |
+
"model.vision_tower.transformer.layers.18.feed_forward.up_proj",
|
| 164 |
+
"model.vision_tower.transformer.layers.18.feed_forward.down_proj",
|
| 165 |
+
"model.vision_tower.transformer.layers.18.attention.k_proj",
|
| 166 |
+
"model.vision_tower.transformer.layers.18.attention.v_proj",
|
| 167 |
+
"model.vision_tower.transformer.layers.18.attention.q_proj",
|
| 168 |
+
"model.vision_tower.transformer.layers.18.attention.o_proj",
|
| 169 |
+
"model.vision_tower.transformer.layers.19.feed_forward.gate_proj",
|
| 170 |
+
"model.vision_tower.transformer.layers.19.feed_forward.up_proj",
|
| 171 |
+
"model.vision_tower.transformer.layers.19.feed_forward.down_proj",
|
| 172 |
+
"model.vision_tower.transformer.layers.19.attention.k_proj",
|
| 173 |
+
"model.vision_tower.transformer.layers.19.attention.v_proj",
|
| 174 |
+
"model.vision_tower.transformer.layers.19.attention.q_proj",
|
| 175 |
+
"model.vision_tower.transformer.layers.19.attention.o_proj",
|
| 176 |
+
"model.vision_tower.transformer.layers.20.feed_forward.gate_proj",
|
| 177 |
+
"model.vision_tower.transformer.layers.20.feed_forward.up_proj",
|
| 178 |
+
"model.vision_tower.transformer.layers.20.feed_forward.down_proj",
|
| 179 |
+
"model.vision_tower.transformer.layers.20.attention.k_proj",
|
| 180 |
+
"model.vision_tower.transformer.layers.20.attention.v_proj",
|
| 181 |
+
"model.vision_tower.transformer.layers.20.attention.q_proj",
|
| 182 |
+
"model.vision_tower.transformer.layers.20.attention.o_proj",
|
| 183 |
+
"model.vision_tower.transformer.layers.21.feed_forward.gate_proj",
|
| 184 |
+
"model.vision_tower.transformer.layers.21.feed_forward.up_proj",
|
| 185 |
+
"model.vision_tower.transformer.layers.21.feed_forward.down_proj",
|
| 186 |
+
"model.vision_tower.transformer.layers.21.attention.k_proj",
|
| 187 |
+
"model.vision_tower.transformer.layers.21.attention.v_proj",
|
| 188 |
+
"model.vision_tower.transformer.layers.21.attention.q_proj",
|
| 189 |
+
"model.vision_tower.transformer.layers.21.attention.o_proj",
|
| 190 |
+
"model.vision_tower.transformer.layers.22.feed_forward.gate_proj",
|
| 191 |
+
"model.vision_tower.transformer.layers.22.feed_forward.up_proj",
|
| 192 |
+
"model.vision_tower.transformer.layers.22.feed_forward.down_proj",
|
| 193 |
+
"model.vision_tower.transformer.layers.22.attention.k_proj",
|
| 194 |
+
"model.vision_tower.transformer.layers.22.attention.v_proj",
|
| 195 |
+
"model.vision_tower.transformer.layers.22.attention.q_proj",
|
| 196 |
+
"model.vision_tower.transformer.layers.22.attention.o_proj",
|
| 197 |
+
"model.vision_tower.transformer.layers.23.feed_forward.gate_proj",
|
| 198 |
+
"model.vision_tower.transformer.layers.23.feed_forward.up_proj",
|
| 199 |
+
"model.vision_tower.transformer.layers.23.feed_forward.down_proj",
|
| 200 |
+
"model.vision_tower.transformer.layers.23.attention.k_proj",
|
| 201 |
+
"model.vision_tower.transformer.layers.23.attention.v_proj",
|
| 202 |
+
"model.vision_tower.transformer.layers.23.attention.q_proj",
|
| 203 |
+
"model.vision_tower.transformer.layers.23.attention.o_proj",
|
| 204 |
+
"model.multi_modal_projector.patch_merger.merging_layer",
|
| 205 |
+
"model.multi_modal_projector.linear_1",
|
| 206 |
+
"model.multi_modal_projector.linear_2",
|
| 207 |
+
"lm_head"
|
| 208 |
+
],
|
| 209 |
+
"kv_cache_scheme": null,
|
| 210 |
+
"quant_method": "compressed-tensors",
|
| 211 |
+
"quantization_status": "compressed",
|
| 212 |
+
"sparsity_config": {},
|
| 213 |
+
"transform_config": {},
|
| 214 |
+
"version": "0.12.3.a20251114"
|
| 215 |
+
},
|
| 216 |
+
"spatial_merge_size": 2,
|
| 217 |
+
"text_config": {
|
| 218 |
+
"attention_dropout": 0.0,
|
| 219 |
+
"head_dim": 128,
|
| 220 |
+
"hidden_act": "silu",
|
| 221 |
+
"hidden_size": 5120,
|
| 222 |
+
"initializer_range": 0.02,
|
| 223 |
+
"intermediate_size": 16384,
|
| 224 |
+
"max_position_embeddings": 262144,
|
| 225 |
+
"model_type": "ministral3",
|
| 226 |
+
"num_attention_heads": 32,
|
| 227 |
+
"num_hidden_layers": 40,
|
| 228 |
+
"num_key_value_heads": 8,
|
| 229 |
+
"rms_norm_eps": 1e-05,
|
| 230 |
+
"rope_parameters": {
|
| 231 |
+
"beta_fast": 32.0,
|
| 232 |
+
"beta_slow": 1.0,
|
| 233 |
+
"factor": 16.0,
|
| 234 |
+
"llama_4_scaling_beta": 0.1,
|
| 235 |
+
"mscale": 1.0,
|
| 236 |
+
"mscale_all_dim": 1.0,
|
| 237 |
+
"original_max_position_embeddings": 16384,
|
| 238 |
+
"rope_theta": 1000000000.0,
|
| 239 |
+
"rope_type": "yarn",
|
| 240 |
+
"type": "yarn"
|
| 241 |
+
},
|
| 242 |
+
"sliding_window": null,
|
| 243 |
+
"use_cache": true,
|
| 244 |
+
"vocab_size": 131072
|
| 245 |
+
},
|
| 246 |
+
"transformers_version": "5.0.0.dev0",
|
| 247 |
+
"vision_config": {
|
| 248 |
+
"attention_dropout": 0.0,
|
| 249 |
+
"head_dim": 64,
|
| 250 |
+
"hidden_act": "silu",
|
| 251 |
+
"hidden_size": 1024,
|
| 252 |
+
"image_size": 1540,
|
| 253 |
+
"initializer_range": 0.02,
|
| 254 |
+
"intermediate_size": 4096,
|
| 255 |
+
"model_type": "pixtral",
|
| 256 |
+
"num_attention_heads": 16,
|
| 257 |
+
"num_channels": 3,
|
| 258 |
+
"num_hidden_layers": 24,
|
| 259 |
+
"patch_size": 14,
|
| 260 |
+
"rope_parameters": {
|
| 261 |
+
"rope_theta": 10000.0,
|
| 262 |
+
"rope_type": "default"
|
| 263 |
+
}
|
| 264 |
+
},
|
| 265 |
+
"vision_feature_layer": -1
|
| 266 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 1,
|
| 3 |
+
"eos_token_id": 2,
|
| 4 |
+
"max_length": 262144,
|
| 5 |
+
"pad_token_id": 11,
|
| 6 |
+
"transformers_version": "5.0.0.dev0"
|
| 7 |
+
}
|
model-00001-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94595fb482260e76375b02c1c9e529dd93aef24f4e1b870f24a90f58d98df29d
|
| 3 |
+
size 4997437320
|
model-00002-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3ba4c93fd826d1f46dc563dd2ab2e10137f21944472d19b7b4c0871e636e194c
|
| 3 |
+
size 4996667240
|
model-00003-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:367579ebb1886eedd0254816069243135c08b3ffc52cfd1ecba440d3b39f8550
|
| 3 |
+
size 411107768
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7291c881406d3702616e00ac91512519534ce5500f6fdc698b03a3e4aab97a3
|
| 3 |
+
size 10405191456
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
params.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dim": 5120,
|
| 3 |
+
"n_layers": 40,
|
| 4 |
+
"head_dim": 128,
|
| 5 |
+
"hidden_dim": 16384,
|
| 6 |
+
"n_heads": 32,
|
| 7 |
+
"n_kv_heads": 8,
|
| 8 |
+
"rope_theta": 1000000000.0,
|
| 9 |
+
"norm_eps": 1e-05,
|
| 10 |
+
"vocab_size": 131072,
|
| 11 |
+
"tied_embeddings": false,
|
| 12 |
+
"max_position_embeddings": 262144,
|
| 13 |
+
"llama_4_scaling": {
|
| 14 |
+
"original_max_position_embeddings": 16384,
|
| 15 |
+
"beta": 0.1
|
| 16 |
+
},
|
| 17 |
+
"q_lora_rank": null,
|
| 18 |
+
"qk_rope_head_dim": null,
|
| 19 |
+
"qk_nope_head_dim": null,
|
| 20 |
+
"kv_lora_rank": null,
|
| 21 |
+
"v_head_dim": null,
|
| 22 |
+
"yarn": {
|
| 23 |
+
"original_max_position_embeddings": 16384,
|
| 24 |
+
"factor": 16,
|
| 25 |
+
"apply_scale": false,
|
| 26 |
+
"beta": 32,
|
| 27 |
+
"alpha": 1
|
| 28 |
+
},
|
| 29 |
+
"vision_encoder": {
|
| 30 |
+
"image_token_id": 10,
|
| 31 |
+
"intermediate_size": 4096,
|
| 32 |
+
"num_hidden_layers": 24,
|
| 33 |
+
"num_attention_heads": 16,
|
| 34 |
+
"mm_projector_id": "patch_merge",
|
| 35 |
+
"spatial_merge_size": 2,
|
| 36 |
+
"hidden_size": 1024,
|
| 37 |
+
"num_channels": 3,
|
| 38 |
+
"image_size": 1540,
|
| 39 |
+
"max_image_size": 1540,
|
| 40 |
+
"patch_size": 14,
|
| 41 |
+
"rope_theta": 10000.0,
|
| 42 |
+
"add_pre_mm_projector_layer_norm": true,
|
| 43 |
+
"adapter_bias": false,
|
| 44 |
+
"image_break_token_id": 12,
|
| 45 |
+
"image_end_token_id": 13
|
| 46 |
+
}
|
| 47 |
+
}
|
processor_config.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_break_token": "[IMG_BREAK]",
|
| 3 |
+
"image_end_token": "[IMG_END]",
|
| 4 |
+
"image_processor": {
|
| 5 |
+
"crop_size": null,
|
| 6 |
+
"data_format": "channels_first",
|
| 7 |
+
"device": null,
|
| 8 |
+
"disable_grouping": null,
|
| 9 |
+
"do_center_crop": null,
|
| 10 |
+
"do_convert_rgb": true,
|
| 11 |
+
"do_normalize": true,
|
| 12 |
+
"do_pad": null,
|
| 13 |
+
"do_rescale": true,
|
| 14 |
+
"do_resize": true,
|
| 15 |
+
"image_mean": [
|
| 16 |
+
0.48145466,
|
| 17 |
+
0.4578275,
|
| 18 |
+
0.40821073
|
| 19 |
+
],
|
| 20 |
+
"image_processor_type": "PixtralImageProcessorFast",
|
| 21 |
+
"image_seq_length": null,
|
| 22 |
+
"image_std": [
|
| 23 |
+
0.26862954,
|
| 24 |
+
0.26130258,
|
| 25 |
+
0.27577711
|
| 26 |
+
],
|
| 27 |
+
"input_data_format": null,
|
| 28 |
+
"pad_size": null,
|
| 29 |
+
"patch_size": 14,
|
| 30 |
+
"processor_class": "PixtralProcessor",
|
| 31 |
+
"resample": 3,
|
| 32 |
+
"rescale_factor": 0.00392156862745098,
|
| 33 |
+
"return_tensors": null,
|
| 34 |
+
"size": {
|
| 35 |
+
"longest_edge": 1540
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"image_token": "[IMG]",
|
| 39 |
+
"patch_size": 14,
|
| 40 |
+
"processor_class": "PixtralProcessor",
|
| 41 |
+
"spatial_merge_size": 2
|
| 42 |
+
}
|
recipe.yaml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
default_stage:
|
| 2 |
+
default_modifiers:
|
| 3 |
+
AWQModifier:
|
| 4 |
+
config_groups:
|
| 5 |
+
group_0:
|
| 6 |
+
targets: [Linear]
|
| 7 |
+
weights:
|
| 8 |
+
num_bits: 4
|
| 9 |
+
type: int
|
| 10 |
+
symmetric: true
|
| 11 |
+
group_size: 32
|
| 12 |
+
strategy: group
|
| 13 |
+
block_structure: null
|
| 14 |
+
dynamic: false
|
| 15 |
+
actorder: null
|
| 16 |
+
scale_dtype: null
|
| 17 |
+
zp_dtype: null
|
| 18 |
+
observer: mse
|
| 19 |
+
observer_kwargs: {}
|
| 20 |
+
input_activations: null
|
| 21 |
+
output_activations: null
|
| 22 |
+
format: null
|
| 23 |
+
targets: [Linear]
|
| 24 |
+
ignore: ['re:.*embed_tokens', 're:.*input_layernorm', 're:.*post_attention_layernorm',
|
| 25 |
+
're:.*norm', 're:.*lm_head', 're:.*multi_modal_projector.*', 're:.*vision_tower.*']
|
| 26 |
+
mappings:
|
| 27 |
+
- smooth_layer: re:.*input_layernorm$
|
| 28 |
+
balance_layers: ['re:.*q_proj$', 're:.*k_proj$', 're:.*v_proj$']
|
| 29 |
+
- smooth_layer: re:.*v_proj$
|
| 30 |
+
balance_layers: ['re:.*o_proj$']
|
| 31 |
+
- smooth_layer: re:.*post_attention_layernorm$
|
| 32 |
+
balance_layers: ['re:.*gate_proj$', 're:.*up_proj$']
|
| 33 |
+
- smooth_layer: re:.*up_proj$
|
| 34 |
+
balance_layers: ['re:.*down_proj$']
|
| 35 |
+
offload_device: !!python/object/apply:torch.device [cpu]
|
| 36 |
+
duo_scaling: true
|
| 37 |
+
n_grid: 20
|
special_tokens_map.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tekken.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e29d19ea32eb7e26e6c0572d57cb7f9eca0f4420e0e0fe6ae1cf3be94da1c0d6
|
| 3 |
+
size 16753777
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:577575622324b2e099e2648be26bdeb5e5815ffe66d7004e9e3ddbf421db6bf1
|
| 3 |
+
size 17078110
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|