Downloads · 30 days
0
salikahmad702/qwen2.5-0.5b-codealpaca-lora
qwen2.5-0.5b-codealpaca-lora is a machine learning model from salikahmad702. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
This is a LoRA (Low-Rank Adaptation) fine-tuned adapter for Qwen2.5-0.5B-Instruct, trained on a subset of the CodeAlpaca-20k dataset to improve Python code generation from natural language instructions.
Downloads · 30 days
0
Access
Public
Updated Jul 24, 2026
Repo size
13.6 MB
Likes
0
Public
Click a slice to open those files.
.json11.4 MB · 84%
From the Hugging Face model README
This is a LoRA (Low-Rank Adaptation) fine-tuned adapter for Qwen2.5-0.5B-Instruct, trained on a subset of the CodeAlpaca-20k dataset to improve Python code generation from natural language instructions.
This adapter is intended for generating short Python functions and code snippets from natural language instructions. It was built as a learning project to understand the fine-tuning pipeline (dataset prep, LoRA, training loop) rather than for production use.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-0.5B-Instruct", dtype=torch.float32
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
model = PeftModel.from_pretrained(base_model, "salik702/qwen2.5-0.5b-codealpaca-lora")
prompt = "### Instruction:\nWrite a Python function to check if a number is prime\n\n### Response:\n"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=150)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Fine-tuned using Hugging Face transformers + peft on a CPU-only machine, using a custom training script with LoRA adapters applied to attention projection layers.
MIT