|
| 1 | +# Mistral Small 3.1/3.2 Fine-tuning |
| 2 | + |
| 3 | +This guide covers fine-tuning [Mistral Small 3.1](mistralai/Mistral-Small-3.1-24B-Instruct-2503) and [Mistral Small 3.2](mistralai/Mistral-Small-3.2-24B-Instruct-2506) with vision capabilities using Axolotl. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before starting, ensure you have: |
| 8 | +- Installed Axolotl (see [Installation docs](https://docs.axolotl.ai/docs/installation.html)) |
| 9 | + |
| 10 | +## Getting Started |
| 11 | + |
| 12 | +1. Install the required vision lib: |
| 13 | + ```bash |
| 14 | + pip install 'mistral-common[opencv]==1.8.5' |
| 15 | + ``` |
| 16 | + |
| 17 | +2. Download the example dataset image: |
| 18 | + ```bash |
| 19 | + wget https://huggingface.co/datasets/Nanobit/text-vision-2k-test/resolve/main/African_elephant.jpg |
| 20 | + ``` |
| 21 | + |
| 22 | +3. Run the fine-tuning: |
| 23 | + ```bash |
| 24 | + axolotl train examples/mistral/mistral-small/mistral-small-3.1-24B-lora.yml |
| 25 | + ``` |
| 26 | + |
| 27 | +This config uses about 29.4 GiB VRAM. |
| 28 | + |
| 29 | +## Dataset Format |
| 30 | + |
| 31 | +The vision model requires multi-modal dataset format as documented [here](https://docs.axolotl.ai/docs/multimodal.html#dataset-format). |
| 32 | + |
| 33 | +One exception is that, passing `"image": PIL.Image` is not supported. MistralTokenizer only supports `path`, `url`, and `base64` for now. |
| 34 | + |
| 35 | +Example: |
| 36 | +```json |
| 37 | +{ |
| 38 | + "messages": [ |
| 39 | + {"role": "system", "content": [{ "type": "text", "text": "{SYSTEM_PROMPT}"}]}, |
| 40 | + {"role": "user", "content": [ |
| 41 | + { "type": "text", "text": "What's in this image?"}, |
| 42 | + {"type": "image", "path": "path/to/image.jpg" } |
| 43 | + ]}, |
| 44 | + {"role": "assistant", "content": [{ "type": "text", "text": "..." }]}, |
| 45 | + ], |
| 46 | +} |
| 47 | +``` |
| 48 | +
|
| 49 | +## Limitations |
| 50 | +
|
| 51 | +- Sample Packing is not supported for multi-modality training currently. |
0 commit comments