July-Mistral-2024

unslothai/unslothJuly-Mistral-2024Jul 19, 2024by danielhanchen

AI Summary

Adds Mistral NeMo support, Ollama export, and CSV support. Introduces RoPE scaling.

Key Highlights

  • Mistral NeMo support
  • Ollama export with automatic Modelfile creation
  • CSV/Excel training support
  • RoPE scaling for unlimited context lengths

New Features

  • Mistral NeMo support
  • Ollama export
  • CSV support
  • RoPE scaling

Full Release Notes

# Mistral NeMo, Ollama & CSV support
See https://unsloth.ai/blog/mistral-nemo for more details. 4 bit pre-quantized weights at https://huggingface.co/unsloth

2x faster 60% less VRAM Colab finetuning notebook [here](https://colab.research.google.com/drive/17d3U-CAIwzmbDRqbZ9NnpHxCkmXB6LZ0?usp=sharing) and also our Kaggle notebook is [here](https://www.kaggle.com/code/danielhanchen/kaggle-mistral-nemo-12b-unsloth-notebook)

![image](https://github.com/user-attachments/assets/808b6974-7dee-42ce-93df-001f68c1b02b)

# Export to Ollama & CSV Support
To use, create and customize your chat template with a dataset and Unsloth will automatically export the finetune to Ollama with automatic Modelfile creation. We also created a '[Step-by-Step Tutorial](https://docs.unsloth.ai/tutorials/how-to-finetune-llama-3-and-export-to-ollama) on How to Finetune Llama-3 and Deploy to Ollama'. Check out our [Ollama Llama-3 Alpaca](https://colab.research.google.com/drive/1WZDi7APtQ9VsvOrQSSC5DDtxq159j8iZ?usp=sharing) and [CSV/Excel Ollama Guide](https://colab.research.google.com/drive/1VYkncZMfGFkeCEgN2IzbZIKEDkyQuJAS?usp=sharing) notebooks.

Unlike regular chat templates that use 3 columns, Ollama simplifies the process with just 2 columns: instruction and output. And with Ollama, you can save, run, and deploy your finetuned models locally on your own device.
![image](https://github.com/user-attachments/assets/4cabf434-2eb7-4d2f-bf45-07dfabadf122)
![image](https://github.com/user-attachments/assets/28bab77e-e85e-41de-9a44-0715ce845224)


# Train on Completions / Inputs
We now support training only on the output tokens and not the inputs, which can increase accuracy. Try it with:
```python
from trl import SFTTrainer
from transformers import TrainingArguments, DataCollatorForSeq2Seq
trainer = SFTTrainer(
    model = model,
    tokenizer = tokenizer,
    train_dataset = dataset,
    data_collator = DataCollatorForSeq2Seq(tokenizer = tokenizer),
    ...
    args = TrainingArguments(
        ...
    ),
)
from unsloth.chat_templates import train_on_responses_only
trainer = train_on_responses_only(trainer)
```
# RoPE Scaling for all models
We now allow you to finetune Gemma 2, Mistral, Mistral NeMo, Qwen2 and more models with “unlimited” context lengths through RoPE linear scaling through Unsloth. Coupled with our 4x longer context support, Unsloth can do extremely long context support!

# New Docs!
Introducing our new Documentation site which has all the most important info about Unsloth in one place. If you'd like to contribute, please contact us! Docs: https://docs.unsloth.ai/
![image](https://github.com/user-attachments/assets/25b40993-4775-4203-a377-81089fdceba1)

# Update instructions
Please update Unsloth in local machines (Colab and Kaggle just refresh and reload notebooks) via:
```python
pip uninstall unsloth -y
pip install --upgrade --force-reinstall --no-cache-dir git+https://github.com/unslothai/unsloth.git
```