tatsu-lab/alpaca
Viewer • Updated • 52k • 84.6k • 1.36k
How to use tahasiddiqui7/Qwen2.5B with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
model = PeftModel.from_pretrained(base_model, "tahasiddiqui7/Qwen2.5B")This model is a fine-tuned version of Qwen/Qwen2.5-0.5B-Instruct trained on the Alpaca Dataset using Low-Rank Adaptation (LoRA) and Supervised Fine-Tuning (SFTTrainer).
This model is intended for general instruction-following, basic reasoning, text generation, and conversational Q&A.
Use the code below to load and run inference with this model:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model_id = "Qwen/Qwen2.5-0.5B-Instruct"
peft_model_id = "tahasiddiqui7/Qwen2.5B"
tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# Load fine-tuned LoRA adapter onto base model
model = PeftModel.from_pretrained(base_model, peft_model_id)
prompt = "### Instruction:\nExplain the concept of fine-tuning in machine learning.\n\n### Response:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))