-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Feat: Add voxtral, magistral small 1.1, and misc gemma3n fixes #2979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0a2e0e3
91235a4
6ef8777
ae2db89
27105f5
bdd75ff
51eb504
406b64d
a0c445c
f535ade
f6bbe7e
c0d1d5a
9e7b308
ce134c2
f2f1198
495077d
fd100ba
ccd974c
db3f527
dbbdbc0
94b9dcc
7cfbdbc
123e07c
6b1c4f0
309ef74
b6fab8e
3f2dbed
1dcce68
cd19495
2ff1ae7
f4af91f
e561301
8f2a5ac
6a2bd24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,65 @@ | ||
| # Gemma-3n | ||
| # Finetune Gemma-3n with Axolotl | ||
|
|
||
| ## Requirements | ||
| Gemma-3n is a family of multimodal models from Google found on [HuggingFace](https://huggingface.co/collections/google/gemma-3n-685065323f5984ef315c93f4). This guide shows how to fine-tune it with Axolotl. | ||
|
|
||
| In addition to Axolotl's requirements, Gemma-3n requires | ||
| ## Getting started | ||
|
|
||
| ``` | ||
| pip3 install timm | ||
| 1. Install Axolotl following the [installation guide](https://docs.axolotl.ai/docs/installation.html). You need to install from main as Gemma3n is only on nightly or use our latest [Docker images](https://docs.axolotl.ai/docs/docker.html). | ||
|
|
||
| Here is an example of how to install from main for pip: | ||
|
|
||
| ```bash | ||
| # Ensure you have Pytorch installed (Pytorch 2.6.0 min recommended) | ||
| git clone https://github.com/axolotl-ai-cloud/axolotl.git | ||
| cd axolotl | ||
|
|
||
| pip3 install packaging==23.2 setuptools==75.8.0 wheel ninja | ||
| pip3 install --no-build-isolation -e '.[flash-attn]' | ||
| ``` | ||
|
|
||
| If you will load audio datasets, please also install | ||
| 2. In addition to Axolotl's requirements, Gemma-3n requires: | ||
|
|
||
| ```bash | ||
| pip3 install timm==1.0.17 | ||
|
|
||
| # for loading audio data | ||
| pip3 install librosa==0.11.0 | ||
| ``` | ||
| pip3 install librosa | ||
|
|
||
| 3. Run the finetuning example: | ||
|
|
||
| ```bash | ||
| # text only | ||
| axolotl train examples/gemma3n/gemma-3n-e2b-qlora.yml | ||
|
|
||
| # text + vision | ||
| axolotl train examples/gemma3n/gemma-3n-e2b-vision-qlora.yml | ||
|
|
||
| # text + vision + audio | ||
| axolotl train examples/gemma3n/gemma-3n-e2b-vision-audio-qlora.yml | ||
| ``` | ||
|
|
||
| ## Usage | ||
| Let us know how it goes. Happy finetuning! 🚀 | ||
|
|
||
| WARNING: The loss and grad norm will be much higher than normal. We suspect this to be inherent to the model as of the moment. If anyone would like to submit a fix for this, we are happy to take a look. | ||
|
|
||
| ### TIPS | ||
|
|
||
| - You can run a full finetuning by removing the `adapter: qlora` and `load_in_4bit: true` from the config. | ||
| - Read more on how to load your own dataset at [docs](https://docs.axolotl.ai/docs/dataset_loading.html). | ||
| - The text dataset format follows the OpenAI Messages format as seen [here](https://docs.axolotl.ai/docs/dataset-formats/conversation.html#chat_template). | ||
| - The multimodal dataset format follows the OpenAI multi-content Messages format as seen [here](https://docs.axolotl.ai/docs/multimodal.html#dataset-format). | ||
|
|
||
| ## Optimization Guides | ||
|
|
||
| - [Multi-GPU Training](https://docs.axolotl.ai/docs/multi-gpu.html) | ||
| - [Multi-Node Training](https://docs.axolotl.ai/docs/multi-node.html) | ||
| - [LoRA Optimizations](https://docs.axolotl.ai/docs/lora_optims.html) | ||
|
|
||
| ## Related Resources | ||
|
|
||
| See example configs and the [multimodal doc](https://docs.axolotl.ai/docs/multimodal.html). | ||
| - [Gemma 3n Blog](https://ai.google.dev/gemma/docs/gemma-3n) | ||
| - [Axolotl Docs](https://docs.axolotl.ai) | ||
| - [Axolotl Website](https://axolotl.ai) | ||
| - [Axolotl GitHub](https://github.com/axolotl-ai-cloud/axolotl) | ||
| - [Axolotl Discord](https://discord.gg/7m9sfhzaf3) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| base_model: mistralai/Magistral-Small-2507 | ||
|
|
||
| # Enable to use mistral-common tokenizer | ||
| tokenizer_use_mistral_common: true | ||
|
|
||
| # Automatically upload checkpoint and final model to HF | ||
| # hub_model_id: username/custom_model_name | ||
|
|
||
| plugins: | ||
| - axolotl.integrations.cut_cross_entropy.CutCrossEntropyPlugin | ||
|
|
||
| load_in_8bit: false | ||
| load_in_4bit: true | ||
|
|
||
| datasets: | ||
| - path: Nanobit/text-think-2k-test | ||
| type: chat_template | ||
|
|
||
| dataset_prepared_path: last_run_prepared | ||
| val_set_size: 0 | ||
| output_dir: ./outputs/lora-out | ||
|
|
||
| adapter: qlora | ||
| lora_model_dir: | ||
|
|
||
| sequence_len: 2048 | ||
| sample_packing: true | ||
|
|
||
|
|
||
| lora_r: 32 | ||
| lora_alpha: 16 | ||
| lora_dropout: 0.05 | ||
| lora_target_linear: true | ||
| lora_target_modules: | ||
| - gate_proj | ||
| - down_proj | ||
| - up_proj | ||
| - q_proj | ||
| - v_proj | ||
| - k_proj | ||
| - o_proj | ||
|
|
||
| wandb_project: | ||
| wandb_entity: | ||
| wandb_watch: | ||
| wandb_name: | ||
| wandb_log_model: | ||
|
|
||
| gradient_accumulation_steps: 4 | ||
| micro_batch_size: 2 | ||
| num_epochs: 1 | ||
| optimizer: adamw_bnb_8bit | ||
| lr_scheduler: cosine | ||
| learning_rate: 0.0002 | ||
|
|
||
| bf16: auto | ||
| tf32: false | ||
|
|
||
| gradient_checkpointing: true | ||
| resume_from_checkpoint: | ||
| logging_steps: 1 | ||
| flash_attention: true | ||
|
|
||
| warmup_ratio: 0.1 | ||
| evals_per_epoch: 1 | ||
| saves_per_epoch: 1 | ||
|
|
||
| # save_first_step: true # uncomment this to validate checkpoint saving works with your config |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an aside, I wonder if these example-level READMEs should be propagated to our docs somewhere.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, we should have a "Model Guides" section which pulls the README for any existing models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Finetune Voxtral with Axolotl | ||
|
|
||
| Voxtral is a [3B](https://huggingface.co/mistralai/Voxtral-Mini-3B-2507)/[24B](https://huggingface.co/mistralai/Voxtral-Small-24B-2507) parameter opensource model from MistralAI found on HuggingFace. This guide shows how to fine-tune it with Axolotl. | ||
|
|
||
| Thanks to the team at MistralAI for giving us early access to prepare for this release. | ||
|
|
||
| ## Getting started | ||
|
|
||
| 1. Install Axolotl following the [installation guide](https://docs.axolotl.ai/docs/installation.html). You need to install from main as Voxtral is only on nightly or use our latest [Docker images](https://docs.axolotl.ai/docs/docker.html). | ||
|
|
||
| Here is an example of how to install from main for pip: | ||
|
|
||
| ```bash | ||
| # Ensure you have Pytorch installed (Pytorch 2.6.0 min) | ||
| git clone https://github.com/axolotl-ai-cloud/axolotl.git | ||
| cd axolotl | ||
|
|
||
| pip3 install packaging==23.2 setuptools==75.8.0 wheel ninja | ||
| pip3 install --no-build-isolation -e '.[flash-attn]' | ||
| ``` | ||
|
|
||
| 2. Please install the below. | ||
|
|
||
| ```bash | ||
| # audio | ||
| pip3 install librosa==0.11.0 | ||
| pip3 install 'mistral_common[audio]==1.8.3' | ||
| ``` | ||
|
|
||
| 3. Run the finetuning example: | ||
|
|
||
| ```bash | ||
| # text only | ||
| axolotl train examples/voxtral/voxtral-mini-qlora.yml | ||
|
|
||
| # text + audio | ||
| axolotl train examples/voxtral/voxtral-mini-audio-qlora.yml | ||
| ``` | ||
|
|
||
| These configs use about 4.8 GB VRAM. | ||
|
|
||
| Let us know how it goes. Happy finetuning! 🚀 | ||
|
|
||
| ### TIPS | ||
|
|
||
| - For inference, the official MistralAI team recommends `temperature: 0.2` and `top_p: 0.95` for audio understanding and `temperature: 0.0` for transcription. | ||
| - You can run a full finetuning by removing the `adapter: qlora` and `load_in_4bit: true` from the config. | ||
| - Read more on how to load your own dataset at [docs](https://docs.axolotl.ai/docs/dataset_loading.html). | ||
| - The text dataset format follows the OpenAI Messages format as seen [here](https://docs.axolotl.ai/docs/dataset-formats/conversation.html#chat_template). | ||
| - The multimodal dataset format follows the OpenAI multi-content Messages format as seen [here](https://docs.axolotl.ai/docs/multimodal.html#dataset-format). | ||
|
|
||
|
|
||
| ## Optimization Guides | ||
|
|
||
| - [Multi-GPU Training](https://docs.axolotl.ai/docs/multi-gpu.html) | ||
| - [Multi-Node Training](https://docs.axolotl.ai/docs/multi-node.html) | ||
| - [LoRA Optimizations](https://docs.axolotl.ai/docs/lora_optims.html) | ||
|
|
||
| ## Limitations | ||
|
|
||
| We only support the `mistral-common` tokenizer for Supervised Fine-tuning at the moment and for `type: chat_template` only. | ||
|
|
||
| In addition, we do not support overriding tokens yet. | ||
|
|
||
| ## Related Resources | ||
|
|
||
| - [MistralAI Magistral Blog](https://mistral.ai/news/magistral/) | ||
| - [Axolotl Docs](https://docs.axolotl.ai) | ||
| - [Axolotl Website](https://axolotl.ai) | ||
| - [Axolotl GitHub](https://github.com/axolotl-ai-cloud/axolotl) | ||
| - [Axolotl Discord](https://discord.gg/7m9sfhzaf3) | ||
|
|
||
| ## Future Work | ||
|
|
||
| - Add parity to Preference Tuning, RL, etc. | ||
| - Add parity to other tokenizer configs like overriding tokens. |
Uh oh!
There was an error while loading. Please reload this page.