Instructions to use sriram279/Leet-Reason-Qwen0.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sriram279/Leet-Reason-Qwen0.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sriram279/Leet-Reason-Qwen0.5") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("sriram279/Leet-Reason-Qwen0.5") model = AutoModelForMultimodalLM.from_pretrained("sriram279/Leet-Reason-Qwen0.5") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sriram279/Leet-Reason-Qwen0.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sriram279/Leet-Reason-Qwen0.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sriram279/Leet-Reason-Qwen0.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sriram279/Leet-Reason-Qwen0.5
- SGLang
How to use sriram279/Leet-Reason-Qwen0.5 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 "sriram279/Leet-Reason-Qwen0.5" \ --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": "sriram279/Leet-Reason-Qwen0.5", "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 "sriram279/Leet-Reason-Qwen0.5" \ --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": "sriram279/Leet-Reason-Qwen0.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sriram279/Leet-Reason-Qwen0.5 with Docker Model Runner:
docker model run hf.co/sriram279/Leet-Reason-Qwen0.5
Leet-Reason-Qwen0.5
This model is a merged, fine-tuned version of AdithyaSK/Qwen-0.5b-Code-Reasoning-v1 on the greengerong/leetcode dataset. It is optimized to generate clean, correct Python code solutions and corresponding explanations for algorithmic programming problems.
Model Details
- Base Model: AdithyaSK/Qwen-0.5b-Code-Reasoning-v1 (0.5B parameters)
- Finetuning Dataset: greengerong/leetcode (2,360 programming problems and solutions)
- Task: Code generation and reasoning (Python solution mapping)
- Precision: 16-bit Float (Merged LoRA weights)
- License: MIT
Training Configuration & Hyperparameters
The model was fine-tuned using Hugging Face's TRL SFTTrainer and PEFT (LoRA) on Windows. The following hyperparameters were used:
LoRA Configurations
- LoRA Rank (r): 16
- LoRA Alpha (alpha): 32
- LoRA Dropout: 0.05
- Target Modules:
gate_proj,down_proj,k_proj,q_proj,v_proj,up_proj,o_proj
Training Hyperparameters
- Epochs: 3.0
- Batch Size (per device): 2
- Gradient Accumulation Steps: 4
- Learning Rate: 2e-4
- Warmup Steps: 5
- Optimizer: 8-bit AdamW (
adamw_8bit) - LR Scheduler: Linear
- Sequence Length (max_seq_length): 2048
Dataset Format
The training pipeline extracted the problem description (content) and mapped it to the Python solution (python) under the Alpaca instruction format:
### Instruction:
[LeetCode Problem Description]
### Response:
[Python Code Solution and Explanation]
Quickstart / Inference
You can load and query this model directly using Hugging Face Transformers:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the merged model
model_id = "sriram279/Leet-Reason-Qwen0.5"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# Format your prompt
prompt = "solve Two sum problem in Python"
inputs = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}],
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
# Generate
outputs = model.generate(
inputs,
max_new_tokens=512,
temperature=0.7,
do_sample=True
)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
Framework Versions
- PEFT 0.19.1
- TRL 0.24.0
- Transformers 4.47.0 (or newer)
- PyTorch 2.5.1+cu124
- Datasets 3.3.0
- Downloads last month
- 33