Add files using upload-large-folder tool
Browse files- .gitattributes +6 -0
- Devstral-Small-2505-Q4_K_M.gguf +3 -0
- Devstral-Small-2505-UD-IQ1_S.gguf +3 -0
- Devstral-Small-2505-UD-Q2_K_XL.gguf +3 -0
- Devstral-Small-2505-UD-Q3_K_XL.gguf +3 -0
- Devstral-Small-2505-UD-Q4_K_XL.gguf +3 -0
- Devstral-Small-2505-UD-Q5_K_XL.gguf +3 -0
- README.md +203 -85
- config.json +28 -0
.gitattributes
CHANGED
@@ -36,3 +36,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
36 |
mmproj-F16.gguf filter=lfs diff=lfs merge=lfs -text
|
37 |
mmproj-BF16.gguf filter=lfs diff=lfs merge=lfs -text
|
38 |
mmproj-F32.gguf filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
mmproj-F16.gguf filter=lfs diff=lfs merge=lfs -text
|
37 |
mmproj-BF16.gguf filter=lfs diff=lfs merge=lfs -text
|
38 |
mmproj-F32.gguf filter=lfs diff=lfs merge=lfs -text
|
39 |
+
Devstral-Small-2505-UD-IQ1_S.gguf filter=lfs diff=lfs merge=lfs -text
|
40 |
+
Devstral-Small-2505-UD-Q2_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
|
41 |
+
Devstral-Small-2505-UD-Q3_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
|
42 |
+
Devstral-Small-2505-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
43 |
+
Devstral-Small-2505-UD-Q4_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
|
44 |
+
Devstral-Small-2505-UD-Q5_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
|
Devstral-Small-2505-Q4_K_M.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d98d8300f6907baf284ac8d81c190bf9390cd9e55a0d8dee93693da1cd4e656b
|
3 |
+
size 14333916224
|
Devstral-Small-2505-UD-IQ1_S.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d12d88dbb1dce118496cc89a9375f846b3b764ddaa1fd882692d614f22892e19
|
3 |
+
size 5558563904
|
Devstral-Small-2505-UD-Q2_K_XL.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0412b56d9f657e34c3ef91d688270a4f1a1b982e96c3f93a6f350907c07622b7
|
3 |
+
size 9292149824
|
Devstral-Small-2505-UD-Q3_K_XL.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b916e3fa19f7d398461e8503f431dce47a9040e56acc922e32a65be67d586e3e
|
3 |
+
size 11850880064
|
Devstral-Small-2505-UD-Q4_K_XL.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d8d48447e4de4c6ffab551d77c48d0898b50ea5d2b7f71ebf48332a7cb58c9a6
|
3 |
+
size 14548874304
|
Devstral-Small-2505-UD-Q5_K_XL.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6a0bd5565982dfc837dced0dcab5d9f923b912eb5707bdc2bd441d94de9dbe02
|
3 |
+
size 16788116544
|
README.md
CHANGED
@@ -25,43 +25,17 @@ language:
|
|
25 |
- hi
|
26 |
- bn
|
27 |
license: apache-2.0
|
|
|
28 |
inference: false
|
29 |
base_model:
|
30 |
-
- mistralai/
|
31 |
extra_gated_description: >-
|
32 |
If you want to learn more about how we process your personal data, please read
|
33 |
our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
|
34 |
pipeline_tag: text2text-generation
|
35 |
---
|
36 |
-
|
37 |
-
|
38 |
-
<strong>See <a href="https://huggingface.co/collections/unsloth/mistral-small-3-all-versions-679fe9a4722f40d61cfe627c">our collection</a> for all versions of Mistral 3.1 including GGUF, 4-bit & 16-bit formats.</strong>
|
39 |
-
</p>
|
40 |
-
<p style="margin-bottom: 0;">
|
41 |
-
<em>Learn to run Devstral correctly - <a href="https://docs.unsloth.ai/basics/devstral">Read our Guide</a>.</em>
|
42 |
-
</p>
|
43 |
-
<p style="margin-top: 0;margin-bottom: 0;">
|
44 |
-
<em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
|
45 |
-
</p>
|
46 |
-
<div style="display: flex; gap: 5px; align-items: center; ">
|
47 |
-
<a href="https://github.com/unslothai/unsloth/">
|
48 |
-
<img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
|
49 |
-
</a>
|
50 |
-
<a href="https://discord.gg/unsloth">
|
51 |
-
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
52 |
-
</a>
|
53 |
-
<a href="https://docs.unsloth.ai/basics/devstral">
|
54 |
-
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
55 |
-
</a>
|
56 |
-
</div>
|
57 |
-
<h1 style="margin-top: 0rem;">✨ Run & Fine-tune Devstral with Unsloth!</h1>
|
58 |
-
</div>
|
59 |
-
|
60 |
-
- Fine-tune Mistral v0.3 (7B)) for free using our Google [Colab notebook here](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Mistral_v0.3_(7B)-Conversational.ipynb)!
|
61 |
-
- Read our Blog about Devstral support: [docs.unsloth.ai/basics/devstral](https://docs.unsloth.ai/basics/devstral)
|
62 |
-
- View the rest of our notebooks in our [docs here](https://docs.unsloth.ai/get-started/unsloth-notebooks).
|
63 |
-
|
64 |
-
# Devstrall-Small-2505
|
65 |
|
66 |
Devstral is an agentic LLM for software engineering tasks built under a collaboration between [Mistral AI](https://mistral.ai/) and [All Hands AI](https://www.all-hands.dev/) 🙌. Devstral excels at using tools to explore codebases, editing multiple files and power software engineering agents. The model achieves remarkable performance on SWE-bench which positionates it as the #1 open source model on this [benchmark](#benchmark-results).
|
67 |
|
@@ -80,6 +54,7 @@ Learn more about Devstral in our [blog post](https://mistral.ai/news/devstral).
|
|
80 |
- **Tokenizer**: Utilizes a Tekken tokenizer with a 131k vocabulary size.
|
81 |
|
82 |
|
|
|
83 |
## Benchmark Results
|
84 |
|
85 |
### SWE-Bench
|
@@ -96,7 +71,7 @@ Devstral achieves a score of 46.8% on SWE-Bench Verified, outperforming prior op
|
|
96 |
|
97 |
When evaluated under the same test scaffold (OpenHands, provided by All Hands AI 🙌), Devstral exceeds far larger models such as Deepseek-V3-0324 and Qwen3 232B-A22B.
|
98 |
|
99 |
-
: See [here](#mistral-inference)
|
133 |
- [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
|
134 |
-
- [`LMStudio`](https://lmstudio.ai/): See [here](#lmstudio)
|
135 |
-
- [`ollama`](https://github.com/ollama/ollama): See [here](#ollama)
|
136 |
-
|
137 |
|
138 |
### OpenHands (recommended)
|
139 |
|
@@ -221,6 +217,43 @@ Enjoy building with Devstral Small and OpenHands!
|
|
221 |
</details>
|
222 |
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
### vLLM (recommended)
|
225 |
|
226 |
We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
|
@@ -234,7 +267,7 @@ Make sure you install [`vLLM >= 0.8.5`](https://github.com/vllm-project/vllm/rel
|
|
234 |
pip install vllm --upgrade
|
235 |
```
|
236 |
|
237 |
-
Doing so should automatically install [`mistral_common >= 1.5.
|
238 |
|
239 |
To check:
|
240 |
```
|
@@ -282,7 +315,7 @@ messages = [
|
|
282 |
"content": [
|
283 |
{
|
284 |
"type": "text",
|
285 |
-
"text": "
|
286 |
},
|
287 |
],
|
288 |
},
|
@@ -294,6 +327,97 @@ response = requests.post(url, headers=headers, data=json.dumps(data))
|
|
294 |
print(response.json()["choices"][0]["message"]["content"])
|
295 |
```
|
296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
### Mistral-inference
|
298 |
|
299 |
We recommend using mistral-inference to quickly try out / "vibe-check" Devstral.
|
@@ -326,7 +450,47 @@ You can run the model using the following command:
|
|
326 |
mistral-chat $HOME/mistral_models/Devstral --instruct --max_tokens 300
|
327 |
```
|
328 |
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
### Transformers
|
332 |
|
@@ -368,7 +532,7 @@ tokenized = tokenizer.encode_chat_completion(
|
|
368 |
ChatCompletionRequest(
|
369 |
messages=[
|
370 |
SystemMessage(content=SYSTEM_PROMPT),
|
371 |
-
UserMessage(content="
|
372 |
],
|
373 |
)
|
374 |
)
|
@@ -381,49 +545,3 @@ output = model.generate(
|
|
381 |
decoded_output = tokenizer.decode(output[len(tokenized.tokens):])
|
382 |
print(decoded_output)
|
383 |
```
|
384 |
-
|
385 |
-
### LMStudio
|
386 |
-
Download the weights from huggingface:
|
387 |
-
|
388 |
-
```
|
389 |
-
pip install -U "huggingface_hub[cli]"
|
390 |
-
huggingface-cli download \
|
391 |
-
"mistralai/Devstral-Small-2505_gguf" \
|
392 |
-
--include "devstralQ4_K_M.gguf" \
|
393 |
-
--local-dir "mistralai/Devstral-Small-2505_gguf/"
|
394 |
-
```
|
395 |
-
|
396 |
-
You can serve the model locally with [LMStudio](https://lmstudio.ai/).
|
397 |
-
* Download [LM Studio](https://lmstudio.ai/) and install it
|
398 |
-
* Install `lms cli ~/.lmstudio/bin/lms bootstrap`
|
399 |
-
* In a bash terminal, run `lms import devstralQ4_K_M.gguf` in the directory where you've downloaded the model checkpoint (e.g. `mistralai/Devstral-Small-2505_gguf`)
|
400 |
-
* Open the LMStudio application, click the terminal icon to get into the developer tab. Click select a model to load and select Devstral Q4 K M. Toggle the status button to start the model, in setting oggle Serve on Local Network to be on.
|
401 |
-
* On the right tab, you will see an API identifier which should be devstralq4_k_m and an api address under API Usage. Keep note of this address, we will use it in the next step.
|
402 |
-
|
403 |
-
Launch Openhands
|
404 |
-
You can now interact with the model served from LM Studio with openhands. Start the openhands server with the docker
|
405 |
-
|
406 |
-
```bash
|
407 |
-
docker pull docker.all-hands.dev/all-hands-ai/runtime:0.38-nikolaik
|
408 |
-
docker run -it --rm --pull=always \
|
409 |
-
-e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.38-nikolaik \
|
410 |
-
-e LOG_ALL_EVENTS=true \
|
411 |
-
-v /var/run/docker.sock:/var/run/docker.sock \
|
412 |
-
-v ~/.openhands-state:/.openhands-state \
|
413 |
-
-p 3000:3000 \
|
414 |
-
--add-host host.docker.internal:host-gateway \
|
415 |
-
--name openhands-app \
|
416 |
-
docker.all-hands.dev/all-hands-ai/openhands:0.38
|
417 |
-
```
|
418 |
-
|
419 |
-
Click “see advanced setting” on the second line.
|
420 |
-
In the new tab, toggle advanced to on. Set the custom model to be mistral/devstralq4_k_m and Base URL the api address we get from the last step in LM Studio. Set API Key to dummy. Click save changes.
|
421 |
-
|
422 |
-
|
423 |
-
### Ollama
|
424 |
-
|
425 |
-
You can run Devstral using the [Ollama](https://ollama.ai/) CLI.
|
426 |
-
|
427 |
-
```bash
|
428 |
-
ollama run devstral
|
429 |
-
```
|
|
|
25 |
- hi
|
26 |
- bn
|
27 |
license: apache-2.0
|
28 |
+
library_name: vllm
|
29 |
inference: false
|
30 |
base_model:
|
31 |
+
- mistralai/Devstrall-Small-2505
|
32 |
extra_gated_description: >-
|
33 |
If you want to learn more about how we process your personal data, please read
|
34 |
our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
|
35 |
pipeline_tag: text2text-generation
|
36 |
---
|
37 |
+
|
38 |
+
# Model Card for mistralai/Devstrall-Small-2505
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
Devstral is an agentic LLM for software engineering tasks built under a collaboration between [Mistral AI](https://mistral.ai/) and [All Hands AI](https://www.all-hands.dev/) 🙌. Devstral excels at using tools to explore codebases, editing multiple files and power software engineering agents. The model achieves remarkable performance on SWE-bench which positionates it as the #1 open source model on this [benchmark](#benchmark-results).
|
41 |
|
|
|
54 |
- **Tokenizer**: Utilizes a Tekken tokenizer with a 131k vocabulary size.
|
55 |
|
56 |
|
57 |
+
|
58 |
## Benchmark Results
|
59 |
|
60 |
### SWE-Bench
|
|
|
71 |
|
72 |
When evaluated under the same test scaffold (OpenHands, provided by All Hands AI 🙌), Devstral exceeds far larger models such as Deepseek-V3-0324 and Qwen3 232B-A22B.
|
73 |
|
74 |
+

|
75 |
|
76 |
## Usage
|
77 |
|
|
|
102 |
|
103 |
### Local inference
|
104 |
|
105 |
+
You can also run the model locally. It can be done with LMStudio or other providers listed below.
|
106 |
+
|
107 |
+
Launch Openhands
|
108 |
+
You can now interact with the model served from LM Studio with openhands. Start the openhands server with the docker
|
109 |
+
|
110 |
+
```bash
|
111 |
+
docker pull docker.all-hands.dev/all-hands-ai/runtime:0.38-nikolaik
|
112 |
+
docker run -it --rm --pull=always \
|
113 |
+
-e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.38-nikolaik \
|
114 |
+
-e LOG_ALL_EVENTS=true \
|
115 |
+
-v /var/run/docker.sock:/var/run/docker.sock \
|
116 |
+
-v ~/.openhands-state:/.openhands-state \
|
117 |
+
-p 3000:3000 \
|
118 |
+
--add-host host.docker.internal:host-gateway \
|
119 |
+
--name openhands-app \
|
120 |
+
docker.all-hands.dev/all-hands-ai/openhands:0.38
|
121 |
+
```
|
122 |
+
|
123 |
+
The server will start at http://0.0.0.0:3000. Open it in your browser and you will see a tab AI Provider Configuration.
|
124 |
+
Now you can start a new conversation with the agent by clicking on the plus sign on the left bar.
|
125 |
+
|
126 |
+
|
127 |
The model can also be deployed with the following libraries:
|
128 |
+
- [`LMStudio (recommended for quantized model)`](https://lmstudio.ai/): See [here](#lmstudio)
|
129 |
+
- [`vllm (recommended)`](https://github.com/vllm-project/vllm): See [here](#vllm)
|
130 |
+
- [`ollama`](https://github.com/ollama/ollama): See [here](#ollama)
|
131 |
- [`mistral-inference`](https://github.com/mistralai/mistral-inference): See [here](#mistral-inference)
|
132 |
- [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
|
|
|
|
|
|
|
133 |
|
134 |
### OpenHands (recommended)
|
135 |
|
|
|
217 |
</details>
|
218 |
|
219 |
|
220 |
+
### LMStudio (recommended for quantized model)
|
221 |
+
Download the weights from huggingface:
|
222 |
+
|
223 |
+
```
|
224 |
+
pip install -U "huggingface_hub[cli]"
|
225 |
+
huggingface-cli download \
|
226 |
+
"mistralai/Devstral-Small-2505_gguf" \
|
227 |
+
--include "devstralQ4_K_M.gguf" \
|
228 |
+
--local-dir "mistralai/Devstral-Small-2505_gguf/"
|
229 |
+
```
|
230 |
+
|
231 |
+
You can serve the model locally with [LMStudio](https://lmstudio.ai/).
|
232 |
+
* Download [LM Studio](https://lmstudio.ai/) and install it
|
233 |
+
* Install `lms cli ~/.lmstudio/bin/lms bootstrap`
|
234 |
+
* In a bash terminal, run `lms import devstralQ4_K_M.ggu` in the directory where you've downloaded the model checkpoint (e.g. `mistralai/Devstral-Small-2505_gguf`)
|
235 |
+
* Open the LMStudio application, click the terminal icon to get into the developer tab. Click select a model to load and select Devstral Q4 K M. Toggle the status button to start the model, in setting oggle Serve on Local Network to be on.
|
236 |
+
* On the right tab, you will see an API identifier which should be devstralq4_k_m and an api address under API Usage. Keep note of this address, we will use it in the next step.
|
237 |
+
|
238 |
+
Launch Openhands
|
239 |
+
You can now interact with the model served from LM Studio with openhands. Start the openhands server with the docker
|
240 |
+
|
241 |
+
```bash
|
242 |
+
docker pull docker.all-hands.dev/all-hands-ai/runtime:0.38-nikolaik
|
243 |
+
docker run -it --rm --pull=always \
|
244 |
+
-e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.38-nikolaik \
|
245 |
+
-e LOG_ALL_EVENTS=true \
|
246 |
+
-v /var/run/docker.sock:/var/run/docker.sock \
|
247 |
+
-v ~/.openhands-state:/.openhands-state \
|
248 |
+
-p 3000:3000 \
|
249 |
+
--add-host host.docker.internal:host-gateway \
|
250 |
+
--name openhands-app \
|
251 |
+
docker.all-hands.dev/all-hands-ai/openhands:0.38
|
252 |
+
```
|
253 |
+
|
254 |
+
Click “see advanced setting” on the second line.
|
255 |
+
In the new tab, toggle advanced to on. Set the custom model to be mistral/devstralq4_k_m and Base URL the api address we get from the last step in LM Studio. Set API Key to dummy. Click save changes.
|
256 |
+
|
257 |
### vLLM (recommended)
|
258 |
|
259 |
We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
|
|
|
267 |
pip install vllm --upgrade
|
268 |
```
|
269 |
|
270 |
+
Doing so should automatically install [`mistral_common >= 1.5.4`](https://github.com/mistralai/mistral-common/releases/tag/v1.5.4).
|
271 |
|
272 |
To check:
|
273 |
```
|
|
|
315 |
"content": [
|
316 |
{
|
317 |
"type": "text",
|
318 |
+
"text": "Write a function that computes fibonacci in Python.",
|
319 |
},
|
320 |
],
|
321 |
},
|
|
|
327 |
print(response.json()["choices"][0]["message"]["content"])
|
328 |
```
|
329 |
|
330 |
+
<details>
|
331 |
+
<summary>Output</summary>
|
332 |
+
|
333 |
+
Certainly! The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. Here's a simple Python function to compute the Fibonacci sequence:
|
334 |
+
|
335 |
+
### Iterative Approach
|
336 |
+
This approach uses a loop to compute the Fibonacci number iteratively.
|
337 |
+
|
338 |
+
```python
|
339 |
+
def fibonacci(n):
|
340 |
+
if n <= 0:
|
341 |
+
return "Input should be a positive integer."
|
342 |
+
elif n == 1:
|
343 |
+
return 0
|
344 |
+
elif n == 2:
|
345 |
+
return 1
|
346 |
+
|
347 |
+
a, b = 0, 1
|
348 |
+
for _ in range(2, n):
|
349 |
+
a, b = b, a + b
|
350 |
+
return b
|
351 |
+
|
352 |
+
# Example usage:
|
353 |
+
print(fibonacci(10)) # Output: 34
|
354 |
+
```
|
355 |
+
|
356 |
+
### Recursive Approach
|
357 |
+
This approach uses recursion to compute the Fibonacci number. Note that this is less efficient for large `n` due to repeated calculations.
|
358 |
+
|
359 |
+
```python
|
360 |
+
def fibonacci_recursive(n):
|
361 |
+
if n <= 0:
|
362 |
+
return "Input should be a positive integer."
|
363 |
+
elif n == 1:
|
364 |
+
return 0
|
365 |
+
elif n == 2:
|
366 |
+
return 1
|
367 |
+
else:
|
368 |
+
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
|
369 |
+
|
370 |
+
# Example usage:
|
371 |
+
print(fibonacci_recursive(10)) # Output: 34
|
372 |
+
```
|
373 |
+
|
374 |
+
\### Memoization Approach
|
375 |
+
This approach uses memoization to store previously computed Fibonacci numbers, making it more efficient than the simple recursive approach.
|
376 |
+
|
377 |
+
```python
|
378 |
+
def fibonacci_memo(n, memo={}):
|
379 |
+
if n <= 0:
|
380 |
+
return "Input should be a positive integer."
|
381 |
+
elif n == 1:
|
382 |
+
return 0
|
383 |
+
elif n == 2:
|
384 |
+
return 1
|
385 |
+
elif n in memo:
|
386 |
+
return memo[n]
|
387 |
+
|
388 |
+
memo[n] = fibonacci_memo(n - 1, memo) + fibonacci_memo(n - 2, memo)
|
389 |
+
return memo[n]
|
390 |
+
|
391 |
+
# Example usage:
|
392 |
+
print(fibonacci_memo(10)) # Output: 34
|
393 |
+
```
|
394 |
+
|
395 |
+
\### Dynamic Programming Approach
|
396 |
+
This approach uses an array to store the Fibonacci numbers up to `n`.
|
397 |
+
|
398 |
+
```python
|
399 |
+
def fibonacci_dp(n):
|
400 |
+
if n <= 0:
|
401 |
+
return "Input should be a positive integer."
|
402 |
+
elif n == 1:
|
403 |
+
return 0
|
404 |
+
elif n == 2:
|
405 |
+
return 1
|
406 |
+
|
407 |
+
fib = [0, 1] + [0] * (n - 2)
|
408 |
+
for i in range(2, n):
|
409 |
+
fib[i] = fib[i - 1] + fib[i - 2]
|
410 |
+
return fib[n - 1]
|
411 |
+
|
412 |
+
# Example usage:
|
413 |
+
print(fibonacci_dp(10)) # Output: 34
|
414 |
+
```
|
415 |
+
|
416 |
+
You can choose any of these approaches based on your needs. The iterative and dynamic programming approaches are generally more efficient for larger values of `n`.
|
417 |
+
|
418 |
+
</details>
|
419 |
+
|
420 |
+
|
421 |
### Mistral-inference
|
422 |
|
423 |
We recommend using mistral-inference to quickly try out / "vibe-check" Devstral.
|
|
|
450 |
mistral-chat $HOME/mistral_models/Devstral --instruct --max_tokens 300
|
451 |
```
|
452 |
|
453 |
+
If you prompt it with "Write me a unique and efficient function that computes fibonacci in Python", the model should generate something along the following lines:
|
454 |
+
|
455 |
+
<details>
|
456 |
+
<summary>Output</summary>
|
457 |
+
|
458 |
+
Certainly! A common and efficient way to compute Fibonacci numbers is by using memoization to store previously computed values. This avoids redundant calculations and significantly improves performance. Below is a Python function that uses memoization to compute Fibonacci numbers efficiently:
|
459 |
+
|
460 |
+
```python
|
461 |
+
def fibonacci(n, memo=None):
|
462 |
+
if memo is None:
|
463 |
+
memo = {}
|
464 |
+
|
465 |
+
if n in memo:
|
466 |
+
return memo[n]
|
467 |
+
|
468 |
+
if n <= 1:
|
469 |
+
return n
|
470 |
+
|
471 |
+
memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo)
|
472 |
+
return memo[n]
|
473 |
+
|
474 |
+
# Example usage:
|
475 |
+
n = 10
|
476 |
+
print(f"Fibonacci number at position {n} is {fibonacci(n)}")
|
477 |
+
```
|
478 |
+
|
479 |
+
### Explanation:
|
480 |
+
|
481 |
+
1. **Base Case**: If `n` is 0 or 1, the function returns `n` because the Fibonacci sequence starts with 0 and 1.
|
482 |
+
2. **Memoization**: The function uses a dictionary `memo` to store the results of previously computed Fibonacci numbers.
|
483 |
+
3. **Recursive Case**: For other values of `n`, the function recursively computes the Fibonacci number by summing the results of `fibonacci(n - 1)` and `fibonacci(n)`
|
484 |
+
|
485 |
+
</details>
|
486 |
+
|
487 |
+
### Ollama
|
488 |
+
|
489 |
+
You can run Devstral using the [Ollama](https://ollama.ai/) CLI.
|
490 |
+
|
491 |
+
```bash
|
492 |
+
ollama run devstral
|
493 |
+
```
|
494 |
|
495 |
### Transformers
|
496 |
|
|
|
532 |
ChatCompletionRequest(
|
533 |
messages=[
|
534 |
SystemMessage(content=SYSTEM_PROMPT),
|
535 |
+
UserMessage(content="Write me a function that computes fibonacci in Python."),
|
536 |
],
|
537 |
)
|
538 |
)
|
|
|
545 |
decoded_output = tokenizer.decode(output[len(tokenized.tokens):])
|
546 |
print(decoded_output)
|
547 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"MistralForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_dropout": 0.0,
|
6 |
+
"bos_token_id": 1,
|
7 |
+
"eos_token_id": 2,
|
8 |
+
"head_dim": 128,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 5120,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 32768,
|
13 |
+
"max_position_embeddings": 131072,
|
14 |
+
"model_type": "mistral",
|
15 |
+
"num_attention_heads": 32,
|
16 |
+
"num_hidden_layers": 40,
|
17 |
+
"num_key_value_heads": 8,
|
18 |
+
"pad_token_id": 11,
|
19 |
+
"rms_norm_eps": 1e-05,
|
20 |
+
"rope_theta": 1000000000.0,
|
21 |
+
"sliding_window": null,
|
22 |
+
"tie_word_embeddings": false,
|
23 |
+
"torch_dtype": "bfloat16",
|
24 |
+
"transformers_version": "4.52.1",
|
25 |
+
"unsloth_fixed": true,
|
26 |
+
"use_cache": true,
|
27 |
+
"vocab_size": 131072
|
28 |
+
}
|