Text Generation
Safetensors
GGUF
English
mistral
ministral3
code
reasoning
lora
unsloth
knowledge-distillation
conversational
Instructions to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="adamjen/Devstral-Small-2-24B-Opus-Reasoning", filename="Devstral-Small-2-24B-Opus-Reasoning.Q4_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M # Run inference directly in the terminal: llama-cli -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M # Run inference directly in the terminal: llama-cli -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Use Docker
docker model run hf.co/adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "adamjen/Devstral-Small-2-24B-Opus-Reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "adamjen/Devstral-Small-2-24B-Opus-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
- Ollama
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with Ollama:
ollama run hf.co/adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
- Unsloth Studio
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for adamjen/Devstral-Small-2-24B-Opus-Reasoning to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for adamjen/Devstral-Small-2-24B-Opus-Reasoning to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for adamjen/Devstral-Small-2-24B-Opus-Reasoning to start chatting
- Pi
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- Docker Model Runner
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with Docker Model Runner:
docker model run hf.co/adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
- Lemonade
How to use adamjen/Devstral-Small-2-24B-Opus-Reasoning with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull adamjen/Devstral-Small-2-24B-Opus-Reasoning:Q4_K_M
Run and chat with the model
lemonade run user.Devstral-Small-2-24B-Opus-Reasoning-Q4_K_M
List all available models
lemonade list
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,161 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: mistralai/Devstral-Small-2-24B-Instruct-2512
|
| 4 |
+
datasets:
|
| 5 |
+
- nohurry/Opus-4.6-Reasoning-3000x-filtered
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- mistral
|
| 10 |
+
- ministral3
|
| 11 |
+
- code
|
| 12 |
+
- reasoning
|
| 13 |
+
- lora
|
| 14 |
+
- gguf
|
| 15 |
+
- unsloth
|
| 16 |
+
- knowledge-distillation
|
| 17 |
+
pipeline_tag: text-generation
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# Devstral-Small-2-24B Opus Reasoning
|
| 21 |
+
|
| 22 |
+
A LoRA fine-tune of [Devstral-Small-2-24B](https://huggingface.co/mistralai/Devstral-Small-2-24B-Instruct-2512) distilled on Claude 4.6 Opus `<think>...</think>` reasoning traces. The goal: give Devstral's strong coding foundation explicit chain-of-thought reasoning before it writes code.
|
| 23 |
+
|
| 24 |
+
## Model Details
|
| 25 |
+
|
| 26 |
+
| | |
|
| 27 |
+
|---|---|
|
| 28 |
+
| **Base model** | mistralai/Devstral-Small-2-24B-Instruct-2512 |
|
| 29 |
+
| **Fine-tune type** | QLoRA (4-bit NF4 base + BF16 LoRA adapters) |
|
| 30 |
+
| **LoRA rank** | r=16, alpha=16 |
|
| 31 |
+
| **Target modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
|
| 32 |
+
| **Training data** | nohurry/Opus-4.6-Reasoning-3000x-filtered (2,322 samples) |
|
| 33 |
+
| **Checkpoint used** | checkpoint-1200 (end of epoch 2 β best generalisation) |
|
| 34 |
+
| **Hardware** | RTX 3090 24GB VRAM |
|
| 35 |
+
| **Framework** | Unsloth 2026.3.10 + TRL SFTTrainer |
|
| 36 |
+
| **Sequence length** | 2048 |
|
| 37 |
+
|
| 38 |
+
## Files
|
| 39 |
+
|
| 40 |
+
| File | Description |
|
| 41 |
+
|---|---|
|
| 42 |
+
| `adapter_model.safetensors` | LoRA adapter weights (~400MB) |
|
| 43 |
+
| `adapter_config.json` | LoRA config (rank, target modules, base model path) |
|
| 44 |
+
| `Devstral-Small-2-24B-Opus-Reasoning.Q4_K_M.gguf` | Quantised GGUF β ready for llama.cpp / Ollama / llama-swap |
|
| 45 |
+
| `Devstral-Small-2-24B-Opus-Reasoning.Q5_K_M.gguf` | Higher quality GGUF β recommended for local use |
|
| 46 |
+
|
| 47 |
+
## Training Data
|
| 48 |
+
|
| 49 |
+
[nohurry/Opus-4.6-Reasoning-3000x-filtered](https://huggingface.co/datasets/nohurry/Opus-4.6-Reasoning-3000x-filtered) β 2,324 problems with Claude 4.6 Opus `<think>` reasoning traces and solutions, filtered to < 20,000 characters combined length.
|
| 50 |
+
|
| 51 |
+
Each sample was formatted as:
|
| 52 |
+
```
|
| 53 |
+
[INST] {problem} [/INST]<think>
|
| 54 |
+
{thinking}
|
| 55 |
+
</think>
|
| 56 |
+
|
| 57 |
+
{solution}
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Loss was computed on the assistant turn only (`train_on_responses_only`).
|
| 61 |
+
|
| 62 |
+
## Training Loss
|
| 63 |
+
|
| 64 |
+
| Step | Epoch | Loss |
|
| 65 |
+
|------|-------|------|
|
| 66 |
+
| 5 | 0.01 | 0.7949 |
|
| 67 |
+
| 100 | 0.17 | 0.5708 |
|
| 68 |
+
| 300 | 0.52 | 0.5800 |
|
| 69 |
+
| 600 | 1.03 | 0.3559 |
|
| 70 |
+
| 900 | 1.55 | 0.3858 |
|
| 71 |
+
| 1100 | 1.89 | 0.3469 |
|
| 72 |
+
| 1160 | 2.00 | 0.3752 |
|
| 73 |
+
| **1200** | **2.07** | **0.1493** |
|
| 74 |
+
|
| 75 |
+
Checkpoint 1200 (end of epoch 2) was selected over the full epoch 3 run β for reasoning distillation tasks, epoch 3 typically overfits to the trace style while epoch 2 gives the best generalisation.
|
| 76 |
+
|
| 77 |
+
## Usage
|
| 78 |
+
|
| 79 |
+
### GGUF (llama.cpp / Ollama / llama-swap)
|
| 80 |
+
|
| 81 |
+
Download `Devstral-Small-2-24B-Opus-Reasoning.Q5_K_M.gguf` for best quality, or `Devstral-Small-2-24B-Opus-Reasoning.Q4_K_M.gguf` if VRAM is tight.
|
| 82 |
+
|
| 83 |
+
```bash
|
| 84 |
+
# llama.cpp
|
| 85 |
+
./llama-cli -m unsloth.Q5_K_M.gguf \
|
| 86 |
+
--chat-template mistral \
|
| 87 |
+
-p "[INST] Write a Python function to find all prime numbers up to n using a sieve. [/INST]"
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### LoRA Adapter (Python)
|
| 91 |
+
|
| 92 |
+
Requires the base model. Because Devstral is a VLM (Pixtral vision encoder), the easiest path is the text-only extracted weights β see the technical notes below.
|
| 93 |
+
|
| 94 |
+
```python
|
| 95 |
+
import torch
|
| 96 |
+
from unsloth import FastLanguageModel
|
| 97 |
+
from peft import PeftModel
|
| 98 |
+
|
| 99 |
+
base_model_path = "path/to/Devstral-Small-2-24B-textonly" # see notes
|
| 100 |
+
adapter_path = "adamjen/Devstral-Small-2-24B-Opus-Reasoning"
|
| 101 |
+
|
| 102 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 103 |
+
model_name = base_model_path,
|
| 104 |
+
max_seq_length = 2048,
|
| 105 |
+
dtype = torch.bfloat16,
|
| 106 |
+
load_in_4bit = True,
|
| 107 |
+
)
|
| 108 |
+
model = PeftModel.from_pretrained(model, adapter_path)
|
| 109 |
+
|
| 110 |
+
messages = [{"role": "user", "content": "Write a binary search in Python."}]
|
| 111 |
+
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 112 |
+
inputs = tokenizer(text, return_tensors="pt").to("cuda")
|
| 113 |
+
|
| 114 |
+
outputs = model.generate(**inputs, max_new_tokens=2048, temperature=0.7)
|
| 115 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
### Chat Template
|
| 119 |
+
|
| 120 |
+
This model uses Mistral's `[INST]...[/INST]` format. The model will produce a `<think>...</think>` block before its response.
|
| 121 |
+
|
| 122 |
+
```
|
| 123 |
+
[INST] Your question here [/INST]<think>
|
| 124 |
+
... reasoning ...
|
| 125 |
+
</think>
|
| 126 |
+
|
| 127 |
+
... answer ...
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## Technical Notes: The Devstral Extraction Problem
|
| 131 |
+
|
| 132 |
+
Devstral-Small-2-24B ships as a `Mistral3ForConditionalGeneration` (VLM) with a Pixtral vision encoder. Training it as a text-only model on a single 24GB GPU hits several problems:
|
| 133 |
+
|
| 134 |
+
- **FP8 weights**: The official instruct release uses FP8 quantisation, which requires compute capability β₯ 8.9. RTX 3090 is 8.6 β incompatible. Requires dequantising to BF16 first.
|
| 135 |
+
- **Vision encoder VRAM**: The Pixtral encoder consumes ~4GB VRAM, leaving insufficient headroom for 4-bit QLoRA + gradients.
|
| 136 |
+
- **Device map splitting**: With a VLM loaded via `device_map="auto"`, accelerate splits layers across GPU/CPU, breaking distributed training mode.
|
| 137 |
+
- **transformers 5.x concurrent loader**: The async tensor loader materialises all BF16 tensors simultaneously before quantisation β OOM. Fix: `HF_DEACTIVATE_ASYNC_LOAD=1`.
|
| 138 |
+
|
| 139 |
+
**Solution**: Extract the `Ministral3ForCausalLM` language layers into a standalone text-only model directory (stripping `vision_tower.*` and `multi_modal_projector.*`, renaming `language_model.model.*` β `model.*`). This produces a clean 23B causal LM loadable by `FastLanguageModel`.
|
| 140 |
+
|
| 141 |
+
Full write-up with all fixes: [Fine-tuning Devstral on an RTX 3090](https://adamjenner.com.au)
|
| 142 |
+
|
| 143 |
+
## Hardware Requirements
|
| 144 |
+
|
| 145 |
+
| Format | Min VRAM |
|
| 146 |
+
|---|---|
|
| 147 |
+
| Q4_K_M GGUF | ~16GB |
|
| 148 |
+
| Q5_K_M GGUF | ~18GB |
|
| 149 |
+
| LoRA inference (4-bit) | ~20GB |
|
| 150 |
+
| LoRA training (QLoRA) | 24GB |
|
| 151 |
+
|
| 152 |
+
## Limitations
|
| 153 |
+
|
| 154 |
+
- Trained on 2,322 samples β a small dataset. Performance gains on reasoning are real but limited in breadth.
|
| 155 |
+
- Max sequence length 2048 tokens (training constraint). Longer contexts may degrade quality.
|
| 156 |
+
- The `<think>` block reasoning style is inherited from Claude Opus traces β the model may produce verbose reasoning.
|
| 157 |
+
- Not evaluated on formal benchmarks.
|
| 158 |
+
|
| 159 |
+
## Author
|
| 160 |
+
|
| 161 |
+
Adam Jenner β [adamjenner.com.au](https://adamjenner.com.au)
|