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
support modelscope models and datasets (#1481)
tastelikefeet83421fd2b554
diff --git a/README.md b/README.mdindex 6bff98cbdaa..f658e6cebd5 100644--- a/README.md+++ b/README.md@@ -212,6 +212,9 @@ For **advanced installation instructions** or if you see weird errors during ins- Go to our official [Documentation](https://docs.unsloth.ai) for saving to GGUF, checkpointing, evaluation and more!- We support Huggingface's TRL, Trainer, Seq2SeqTrainer or even Pytorch code!- We're in 🤗Hugging Face's official docs! Check out the [SFT docs](https://huggingface.co/docs/trl/main/en/sft_trainer#accelerate-fine-tuning-2x-using-unsloth) and [DPO docs](https://huggingface.co/docs/trl/main/en/dpo_trainer#accelerate-dpo-fine-tuning-using-unsloth)!+- If you want to download models from the ModelScope community, please use an environment variable: `UNSLOTH_USE_MODELSCOPE=1`, and install the modelscope library by: `pip install modelscope -U`.++> unsloth_cli.py also supports `UNSLOTH_USE_MODELSCOPE=1` to download models and datasets. please remember to use the model and dataset id in the ModelScope community.```pythonfrom unsloth import FastLanguageModeldiff --git a/unsloth-cli.py b/unsloth-cli.pyindex ddb0ac8b7b6..b7613f92df7 100644--- a/unsloth-cli.py+++ b/unsloth-cli.py@@ -30,11 +30,14 @@ Happy fine-tuning!"""import argparse+import os+def run(args):import torchfrom unsloth import FastLanguageModelfrom datasets import load_dataset+ from transformers.utils import strtoboolfrom trl import SFTTrainerfrom transformers import TrainingArgumentsfrom unsloth import is_bfloat16_supported@@ -86,8 +89,13 @@ def run(args):texts.append(text)return {"text": texts}- # Load and format dataset- dataset = load_dataset(args.dataset, split="train")+ use_modelscope = strtobool(os.environ.get('UNSLOTH_USE_MODELSCOPE', 'False'))+ if use_modelscope:+ from modelscope import MsDataset+ dataset = MsDataset.load(args.dataset, split="train")+ else:+ # Load and format dataset+ dataset = load_dataset(args.dataset, split="train")dataset = dataset.map(formatting_prompts_func, batched=True)print("Data is formatted and ready!")diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 657072ab371..e9caad0e603 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -31,6 +31,15 @@ except:passfrom huggingface_hub import HfFileSystem+# [TODO] Move USE_MODELSCOPE to utils+USE_MODELSCOPE = os.environ.get("UNSLOTH_USE_MODELSCOPE", "0") == "1"+if USE_MODELSCOPE:+ import importlib+ if importlib.util.find_spec("modelscope") is None:+ raise ImportError(f'You are using the modelscope hub, please install modelscope by `pip install modelscope -U`')+ pass+pass+# https://github.com/huggingface/transformers/pull/26037 allows 4 bit loading!from unsloth_zoo.utils import Version, _get_dtypetransformers_version = Version(transformers_version)@@ -72,6 +81,11 @@ class FastLanguageModel(FastLlamaModel):if not use_exact_model_name:model_name = get_model_name(model_name, load_in_4bit)+ if USE_MODELSCOPE and not os.path.exists(model_name):+ from modelscope import snapshot_download+ model_name = snapshot_download(model_name)+ pass+# First check if it's a normal model via AutoConfigfrom huggingface_hub.utils import disable_progress_bars, enable_progress_bars, are_progress_bars_disabledwas_disabled = are_progress_bars_disabled()@@ -355,6 +369,11 @@ class FastVisionModel(FastBaseVisionModel):if not use_exact_model_name:model_name = get_model_name(model_name, load_in_4bit)+ if USE_MODELSCOPE and not os.path.exists(model_name):+ from modelscope import snapshot_download+ model_name = snapshot_download(model_name)+ pass+# First check if it's a normal model via AutoConfigfrom huggingface_hub.utils import disable_progress_bars, enable_progress_bars, are_progress_bars_disabledwas_disabled = are_progress_bars_disabled()