Instructions to use HashTag766/QwenAssistant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HashTag766/QwenAssistant with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("HashTag766/QwenAssistant", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- Unsloth Studio new
How to use HashTag766/QwenAssistant with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for HashTag766/QwenAssistant to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for HashTag766/QwenAssistant to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for HashTag766/QwenAssistant to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="HashTag766/QwenAssistant", max_seq_length=2048, )
| base_model: SaintHoney/PersonalManV1.0 | |
| tags: | |
| - text-generation-inference | |
| - transformers | |
| - unsloth | |
| - qwen2 | |
| - trl | |
| - sft | |
| license: apache-2.0 | |
| language: | |
| - en | |
| datasets: | |
| - diabolic6045/open-ocra-alpaca-cleaned | |
| - HashTag766/SMART-Goals-Validation | |
| # Overview | |
| #### Finetuned Qwen2.5-3B | |
| #### the training was for increasing the model capabilities on Instruction following and specific data. | |
| #### Training Time : 14.5h | |
| ### Datasets | |
| #### SMART-Goals-Validation------[https://huggingface.co/datasets/HashTag766/SMART-Goals-Validation] | |
| #### open-ocra-alpaca-cleaned----[https://huggingface.co/datasets/diabolic6045/open-ocra-alpaca-cleaned] only on 120000k examples | |
| # Uploaded model | |
| - **Developed by:** HashTag766 | |
| - **License:** apache-2.0 | |
| - **Finetuned from model :** SaintHoney/PersonalManV1.0 | |
| ## The code used for finetuning | |
| ```python | |
| %%capture | |
| !pip install pip3-autoremove | |
| !pip-autoremove torch torchvision torchaudio -y | |
| !pip install torch torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu121 | |
| !pip install unsloth | |
| --------------------------------------------------------------------------------------------- | |
| from kaggle_secrets import UserSecretsClient | |
| user_secrets = UserSecretsClient() # from kaggle_secrets import UserSecretsClient | |
| hugging_face_token = user_secrets.get_secret("HF-Token") | |
| # Login to Hugging Face | |
| from huggingface_hub import login # Lets you login to API | |
| login(hugging_face_token) # from huggingface_hub import login | |
| --------------------------------------------------------------------------------------------- | |
| from unsloth import FastLanguageModel | |
| import torch | |
| max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally! | |
| dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+ | |
| load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False. | |
| model, tokenizer = FastLanguageModel.from_pretrained( | |
| model_name = "SaintHoney/PersonalManV1.0", | |
| max_seq_length = max_seq_length, | |
| dtype = dtype, | |
| load_in_4bit = load_in_4bit, | |
| ) | |
| --------------------------------------------------------------------------------------------- | |
| model = FastLanguageModel.get_peft_model( | |
| model, | |
| r = 16, # Choose any number > 0 ! Suggested 8, 16, 32, 64, 128 | |
| target_modules = ["q_proj", "k_proj", "v_proj", "o_proj", | |
| "gate_proj", "up_proj", "down_proj",], | |
| lora_alpha = 16, | |
| lora_dropout = 0, # Supports any, but = 0 is optimized | |
| bias = "none", # Supports any, but = "none" is optimized | |
| # [NEW] "unsloth" uses 30% less VRAM, fits 2x larger batch sizes! | |
| use_gradient_checkpointing = "unsloth", # True or "unsloth" for very long context | |
| random_state = 3407, | |
| use_rslora = False, # We support rank stabilized LoRA | |
| loftq_config = None, # And LoftQ | |
| ) | |
| --------------------------------------------------------------------------------------------- | |
| alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. | |
| ### Instruction: | |
| {} | |
| ### Input: | |
| {} | |
| ### Response: | |
| {}""" | |
| EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN | |
| def formatting_prompts_func(examples): | |
| instructions = examples["instruction"] | |
| inputs = examples["input"] | |
| outputs = examples["output"] | |
| texts = [] | |
| for instruction, input, output in zip(instructions, inputs, outputs): | |
| # Must add EOS_TOKEN, otherwise your generation will go on forever! | |
| text = alpaca_prompt.format(instruction, input, output) + EOS_TOKEN | |
| texts.append(text) | |
| return { "text" : texts, } | |
| pass | |
| from datasets import load_dataset | |
| dataset = load_dataset("HashTag766/SMART-Goals-Validation", split = "train") # specify here the number of examples from dataset | |
| dataset = dataset.map(formatting_prompts_func, batched = True,) | |
| --------------------------------------------------------------------------------------------- | |
| from trl import SFTTrainer | |
| from transformers import TrainingArguments, DataCollatorForSeq2Seq | |
| from unsloth import is_bfloat16_supported | |
| trainer = SFTTrainer( | |
| model = model, | |
| tokenizer = tokenizer, | |
| train_dataset = dataset, | |
| dataset_text_field = "text", | |
| max_seq_length = max_seq_length, | |
| data_collator = DataCollatorForSeq2Seq(tokenizer = tokenizer), | |
| dataset_num_proc = 2, | |
| packing = False, # Can make training 5x faster for short sequences. | |
| args = TrainingArguments( | |
| per_device_train_batch_size = 2, | |
| gradient_accumulation_steps = 4, | |
| warmup_steps = 5, | |
| num_train_epochs = 3, # Set this for 1 full training run. | |
| # max_steps = 60, | |
| learning_rate = 2e-4, | |
| fp16 = not is_bfloat16_supported(), | |
| bf16 = is_bfloat16_supported(), | |
| logging_steps = 1, | |
| optim = "adamw_8bit", | |
| weight_decay = 0.01, | |
| lr_scheduler_type = "linear", | |
| seed = 3407, | |
| output_dir = "outputs", | |
| report_to = "none", # Use this for WandB etc | |
| ), | |
| ) | |
| trainer_stats = trainer.train() | |
| --------------------------------------------------------------------------------------------- | |
| model.push_to_hub("hf/model...", token = "...") # Online saving | |
| tokenizer.push_to_hub("hf/model...", token = "...") # Online saving | |
| ``` | |
| This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library. | |
| [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth) |