Instructions to use rishini/qwen2.5-coder-7b-programming-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use rishini/qwen2.5-coder-7b-programming-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct") model = PeftModel.from_pretrained(base_model, "rishini/qwen2.5-coder-7b-programming-lora") - Transformers
How to use rishini/qwen2.5-coder-7b-programming-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rishini/qwen2.5-coder-7b-programming-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("rishini/qwen2.5-coder-7b-programming-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rishini/qwen2.5-coder-7b-programming-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rishini/qwen2.5-coder-7b-programming-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rishini/qwen2.5-coder-7b-programming-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rishini/qwen2.5-coder-7b-programming-lora
- SGLang
How to use rishini/qwen2.5-coder-7b-programming-lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rishini/qwen2.5-coder-7b-programming-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rishini/qwen2.5-coder-7b-programming-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rishini/qwen2.5-coder-7b-programming-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rishini/qwen2.5-coder-7b-programming-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use rishini/qwen2.5-coder-7b-programming-lora with Docker Model Runner:
docker model run hf.co/rishini/qwen2.5-coder-7b-programming-lora
metadata
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
library_name: peft
pipeline_tag: text-generation
tags:
- base_model:adapter:Qwen/Qwen2.5-Coder-7B-Instruct
- lora
- transformers
- coding
- code-generation
- finetuned
Qwen2.5-Coder-7B-Programming-LoRA
A LoRA adapter fine-tuned on top of Qwen/Qwen2.5-Coder-7B-Instruct to produce clean, correct, efficient programming solutions with brief explanations.
Model Details
- Base model: Qwen/Qwen2.5-Coder-7B-Instruct
- Method: LoRA (rank 64, alpha 128, use_rslora=True)
- Trainable params: 161,480,704 (~2.08% of total)
- Data: 6,006 quality-filtered examples from
iamtarun/python_code_instructions_18k_alpaca+ curated expert-written seeds - Training: 3 epochs, effective batch size 32, max context 2048, completion-only label masking, cosine LR 2e-4, bf16 + 4-bit NF4 base, gradient checkpointing
- Final train loss: 0.326
Usage
Load with PEFT:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
base = "Qwen/Qwen2.5-Coder-7B-Instruct"
adapter = "rishini/qwen2.5-coder-7b-programming-lora"
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(
base, quantization_config=bnb, device_map="auto", torch_dtype=torch.bfloat16
)
model = PeftModel.from_pretrained(model, adapter)
tokenizer = AutoTokenizer.from_pretrained(base, trust_remote_code=True, use_fast=True)
prompt = "Write a Python function to check if a string is a valid palindrome ignoring case and non-alphanumeric characters."
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=512, temperature=0.2)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Evaluation
Held-out prompts (not in the training set) answered correctly, including: longest common prefix, min-heap from scratch, topological sort, palindromic substrings (DP), and sliding-window longest substring.
Files
adapter_config.json/adapter_model.safetensors— LoRA weightstokenizer.json/tokenizer_config.json/chat_template.jinja— tokenizer + chat template