Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Phi 3.5 bug fix (#955)
Daniel Han353991f14ae6
diff --git a/README.md b/README.mdindex 5c4de1f586c..6cd1be13810 100644--- a/README.md+++ b/README.md@@ -32,12 +32,13 @@ All notebooks are **beginner friendly**! Add your dataset, click "Run All", and| **DPO Zephyr** | [▶️ Start for free](https://colab.research.google.com/drive/15vttTpzzVXv_tJwEk-hIcQ0S9FcEWvwP?usp=sharing) | 1.9x faster | 43% less |- **Kaggle Notebooks** for [Llama 3.1 (8B)](https://www.kaggle.com/danielhanchen/kaggle-llama-3-1-8b-unsloth-notebook), [Gemma 2 (9B)](https://www.kaggle.com/code/danielhanchen/kaggle-gemma-7b-unsloth-notebook/), [Mistral (7B)](https://www.kaggle.com/code/danielhanchen/kaggle-mistral-7b-unsloth-notebook)-- Run [Llama 3 conversational notebook](https://colab.research.google.com/drive/1XamvWYinY6FOSX9GLvnqSjjsNflxdhNc?usp=sharing) and [Mistral v0.3 ChatML](https://colab.research.google.com/drive/15F1xyn8497_dUbxZP4zWmPZ3PJx1Oymv?usp=sharing)+- Run [Llama 3.1 conversational notebook](https://colab.research.google.com/drive/15OyFkGoCImV9dSsewU1wa2JuKB4-mDE_?usp=sharing) and [Mistral v0.3 ChatML](https://colab.research.google.com/drive/15F1xyn8497_dUbxZP4zWmPZ3PJx1Oymv?usp=sharing)- This [text completion notebook](https://colab.research.google.com/drive/1ef-tab5bhkvWmBOObepl1WgJvfvSzn5Q?usp=sharing) is for continued pretraining / raw text- This [continued pretraining notebook](https://colab.research.google.com/drive/1tEd1FrOXWMnCU9UIvdYhs61tkxdMuKZu?usp=sharing) is for learning another language- Click [here](https://github.com/unslothai/unsloth/wiki) for detailed documentation for Unsloth.## 🦥 Unsloth.ai News+- 📣 NEW! [Llama 3.1 Conversational notebook](https://colab.research.google.com/drive/15OyFkGoCImV9dSsewU1wa2JuKB4-mDE_?usp=sharing) includes training only on completions / outputs (increase accuracy), ShareGPT standardization and more!- 📣 NEW! [Phi-3.5 (mini)](https://colab.research.google.com/drive/1lN6hPQveB_mHSnTOYifygFcrO8C1bxq4?usp=sharing) now supported- 📣 NEW! `pip install unsloth` now works! Head over to [pypi](https://pypi.org/project/unsloth/) to check it out! This allows non git pull installs. Use `pip install unsloth[colab-new]` for non dependency installs.- 📣 NEW! [Gemma-2-2b](https://colab.research.google.com/drive/1weTpKOjBZxZJ5PQ-Ql8i6ptAY2x-FWVA?usp=sharing) now supported! Try out [Chat interface](https://colab.research.google.com/drive/1i-8ESvtLRGNkkUQQr_-z_rcSAIo9c3lM?usp=sharing)!diff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex 376b4b4ebc2..f62f0f11653 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -61,6 +61,7 @@ from bitsandbytes.nn import Linear4bit as Bnb_Linear4bitfrom peft.tuners.lora import Linear4bit as Peft_Linear4bitfrom ..save import patch_saving_functionsimport re, os, inspect, math, sys+from huggingface_hub.utils._token import get_tokendef original_apply_qkv(self, X):@@ -1263,7 +1264,7 @@ class LongRopeRotaryEmbedding(torch.nn.Module):# in FP32. They are applied (multiplied) in FP32 as well.self.current_rope_size = seq_len- t = torch.arange(self.current_rope_size, device=self.inv_freq.device, dtype=torch.int64).float()+ t = torch.arange(self.current_rope_size, device=self.long_inv_freq.device, dtype=torch.int64).float()# Long sequencesfreqs = torch.outer(t, self.long_inv_freq)emb = torch.cat((freqs, freqs), dim=-1)@@ -1417,13 +1418,7 @@ class FastLlamaModel:"Are you certain you want to do remote code execution?")pass-- if token is None and "HF_TOKEN" in os.environ:- token = os.environ["HF_TOKEN"]-- if token is None and "HUGGINGFACE_TOKEN" in os.environ:- token = os.environ["HUGGINGFACE_TOKEN"]-+ if token is None: token = get_token()if model_patcher is None: model_patcher = FastLlamaModelSUPPORTS_BFLOAT16 = is_bfloat16_supported()gpu_stats = torch.cuda.get_device_properties(0)diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 02ed00f5cd1..e1f17aca04b 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -21,6 +21,7 @@ from transformers import __version__ as transformers_versionfrom peft import PeftConfig, PeftModelfrom .mapper import INT_TO_FLOAT_MAPPER, FLOAT_TO_INT_MAPPER, MAP_TO_UNSLOTH_16bitimport os+from huggingface_hub.utils._token import get_token# https://github.com/huggingface/transformers/pull/26037 allows 4 bit loading!from packaging.version import Version@@ -152,12 +153,8 @@ class FastLanguageModel(FastLlamaModel):revision = None,*args, **kwargs,):- if token is None and "HF_TOKEN" in os.environ:- token = os.environ["HF_TOKEN"]-- if token is None and "HUGGINGFACE_TOKEN" in os.environ:- token = os.environ["HUGGINGFACE_TOKEN"]-+ if token is None: token = get_token()+old_model_name = model_namemodel_name = get_model_name(model_name, load_in_4bit)diff --git a/unsloth/save.py b/unsloth/save.pyindex f45d8062add..66e2ec6bf0e 100644--- a/unsloth/save.py+++ b/unsloth/save.py@@ -29,6 +29,7 @@ import refrom transformers.models.llama.modeling_llama import loggerfrom .tokenizer_utils import fix_sentencepiece_gguffrom huggingface_hub import HfApi+from huggingface_hub.utils._token import get_token__all__ = ["print_quantization_methods",@@ -207,12 +208,7 @@ def unsloth_save_model(temporary_location : str = "_unsloth_temporary_saved_buffers",maximum_memory_usage : float = 0.9,):- if token is None and "HF_TOKEN" in os.environ:- token = os.environ["HF_TOKEN"]- elif token is None and "hf_token" in os.environ:- token = os.environ["hf_token"]- elif token is None and "HUGGINGFACE_TOKEN" in os.environ:- token = os.environ["HUGGINGFACE_TOKEN"]+ if token is None: token = get_token()if commit_message is None: commit_message = ""if "Unsloth" not in commit_message:@@ -1321,12 +1317,8 @@ def create_huggingface_repo(token = None,private = False,):- if token is None and "HF_TOKEN" in os.environ:- token = os.environ["HF_TOKEN"]- elif token is None and "hf_token" in os.environ:- token = os.environ["hf_token"]- elif token is None and "HUGGINGFACE_TOKEN" in os.environ:- token = os.environ["HUGGINGFACE_TOKEN"]+ if token is None :+ token = get_token()passsave_directory, username = _determine_username(save_directory, "", token)