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

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
Safetensors
Model size
0.5B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for sriram279/Leet-Reason-Qwen0.5

Finetuned
(1)
this model
Quantizations
1 model