Instructions to use AmareshHebbar/leetcode-cpp-qwen25-coder-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use AmareshHebbar/leetcode-cpp-qwen25-coder-7b with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit") model = PeftModel.from_pretrained(base_model, "AmareshHebbar/leetcode-cpp-qwen25-coder-7b") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use AmareshHebbar/leetcode-cpp-qwen25-coder-7b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for AmareshHebbar/leetcode-cpp-qwen25-coder-7b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for AmareshHebbar/leetcode-cpp-qwen25-coder-7b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for AmareshHebbar/leetcode-cpp-qwen25-coder-7b to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="AmareshHebbar/leetcode-cpp-qwen25-coder-7b", max_seq_length=2048, )
- โ๏ธ LeetCode C++ Coder
- TL;DR
- Benchmarks (free, reproducible)
- Intended use
- Quickstart
- Option A โ Transformers + PEFT
- Option B โ Unsloth (2x faster load + inference)
- Option C โ vLLM (production serving, OpenAI-compatible) {#vllm}
- Option D โ TGI (Text Generation Inference) {#tgi}
- Option E โ Ollama (local, mobile/edge-friendly) {#ollama}
- Option F โ GGUF / llama.cpp direct (mobile/edge inference)
- Training details
- Bias, risks & limitations
- FAQ
- Related models in this suite
- Changelog
- Citation
- Contact
- TL;DR
โ๏ธ LeetCode C++ Coder
Qwen2.5-Coder-7B fine-tuned to solve LeetCode problems in C++
Part of the LeetCode Multi-Language Coder Suite โ 4 language specialists, one base model
TL;DR
Given a LeetCode-style problem statement and an algorithm tag, generates a working C++ solution.
PROBLEM: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
ALGORITHM: Hash Map
OUTPUT (C++):
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
unordered_map<int,int> seen;
for (int i = 0; i < nums.size(); i++) {
if (seen.count(target - nums[i])) return {seen[target - nums[i]], i};
seen[nums[i]] = i;
}
return {};
}
};
| Base model | unsloth/Qwen2.5-Coder-7B-Instruct |
| Method | QLoRA, 4-bit NF4, rank 16 |
| Training data | leetcode-cpp-sft |
| Weights here | LoRA adapter only (~160MB) โ load on top of the base model |
| GGUF build | leetcode-cpp-qwen25-coder-7b-GGUF โ q4_k_m / q5_k_m / q8_0 |
| License | Apache 2.0 |
Benchmarks (free, reproducible)
Run benchmark_suite.py from the deployment kit to reproduce. All numbers are pass@1 unless noted.
| Benchmark | Language | Pass@1 | Pass@10 | Notes |
|---|---|---|---|---|
| HumanEval-X | C++ | run benchmark_suite.py | run benchmark_suite.py | 164 problems, execution-verified |
| MultiPL-E (HumanEval subset) | C++ | run benchmark_suite.py | โ | cross-check vs HumanEval-X |
| Held-out LeetCode test split | C++ | run benchmark_suite.py | โ | from leetcode-cpp-sft test split, exact I/O match |
| Tokens/sec (fp16, A40) | C++ | โ | โ | latency benchmark, see script |
| Tokens/sec (GGUF q4_k_m, CPU) | C++ | โ | โ | latency benchmark, see script |
Numbers are intentionally left blank in this template โ
benchmark_suite.pyfills aresults/leetcode-cpp-qwen25-coder-7b.jsonfile and this table should be regenerated from it (see deployment kit README).
Intended use
Drop-in solution generator for C++ coding-practice tools, interview-prep apps, and automated code-review sandboxes for algorithmic problems.
Direct use
Give a problem statement (+ optional algorithm hint), get back a C++ function/class implementing it.
Downstream use
Feed output into an automated grader (run against test cases), a code-review bot, or a practice-app "show solution" feature.
Out of scope
- Production system design or non-algorithmic code (this model specializes narrowly on LeetCode-style problems)
- Security-critical code without human review
- Guaranteed-optimal complexity โ treat output as a strong first draft, not a proof
Quickstart
Option A โ Transformers + PEFT
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model = "unsloth/Qwen2.5-Coder-7B-Instruct"
adapter = "AmareshHebbar/leetcode-cpp-qwen25-coder-7b"
tokenizer = AutoTokenizer.from_pretrained("AmareshHebbar/leetcode-cpp-qwen25-coder-7b")
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(model, adapter)
messages = [
{"role": "system", "content": "You are an expert C++ competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient C++ solution."},
{"role": "user", "content": "Problem: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\nAlgorithm: Hash Map"},
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
outputs = model.generate(inputs, max_new_tokens=512, temperature=0.2, do_sample=True)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
Option B โ Unsloth (2x faster load + inference)
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="AmareshHebbar/leetcode-cpp-qwen25-coder-7b",
max_seq_length=2048,
load_in_4bit=True,
)
FastLanguageModel.for_inference(model)
messages = [
{"role": "system", "content": "You are an expert C++ competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient C++ solution."},
{"role": "user", "content": "Problem: Given a string s, find the length of the longest substring without repeating characters.\nAlgorithm: two pointers / sliding window"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.2, do_sample=True)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Option C โ vLLM (production serving, OpenAI-compatible) {#vllm}
vllm serve unsloth/Qwen2.5-Coder-7B-Instruct \
--enable-lora \
--lora-modules leetcode-cpp-qwen25-coder-7b=AmareshHebbar/leetcode-cpp-qwen25-coder-7b \
--host 0.0.0.0 --port 8000 --dtype bfloat16
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")
response = client.chat.completions.create(
model="leetcode-cpp-qwen25-coder-7b",
messages=[
{"role": "system", "content": "You are an expert C++ competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient C++ solution."},
{"role": "user", "content": "Problem: Merge two sorted linked lists into one sorted list.\nAlgorithm: linked list, dummy head"},
],
temperature=0.2,
)
print(response.choices[0].message.content)
Option D โ TGI (Text Generation Inference) {#tgi}
docker run --gpus all --shm-size 1g -p 8080:80 \
-v $PWD/data:/data ghcr.io/huggingface/text-generation-inference:latest \
--model-id unsloth/Qwen2.5-Coder-7B-Instruct \
--lora-adapters leetcode-cpp-qwen25-coder-7b=AmareshHebbar/leetcode-cpp-qwen25-coder-7b
curl 127.0.0.1:8080/generate_stream \
-X POST \
-d '{"inputs":"<|im_start|>system\nYou are an expert C++ competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient C++ solution.<|im_end|>\n<|im_start|>user\nProblem: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\nAlgorithm: Hash Map<|im_end|>\n<|im_start|>assistant\n","parameters":{"max_new_tokens":512}}' \
-H 'Content-Type: application/json'
Option E โ Ollama (local, mobile/edge-friendly) {#ollama}
# 1. Pull the GGUF build
huggingface-cli download AmareshHebbar/leetcode-cpp-qwen25-coder-7b-GGUF leetcode-cpp-qwen25-coder-7b.q4_k_m.gguf --local-dir .
# 2. Create the model from the Modelfile shipped in the deployment kit (see deploy_ollama.py)
ollama create leetcode-cpp-qwen25-coder-7b -f Modelfile.cpp
# 3. Run it
ollama run leetcode-cpp-qwen25-coder-7b "Problem: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\nAlgorithm: Hash Map"
Option F โ GGUF / llama.cpp direct (mobile/edge inference)
./llama-cli -m leetcode-cpp-qwen25-coder-7b.q4_k_m.gguf \
-p "<|im_start|>system\nYou are an expert C++ competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient C++ solution.<|im_end|>\n<|im_start|>user\nProblem: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.<|im_end|>\n<|im_start|>assistant\n" \
-n 512 --temp 0.2
See export_gguf.py in the deployment kit for building q4_k_m / q5_k_m / q8_0 variants, and the mobile integration notes there for Android (llama.cpp JNI) and iOS (llama.cpp via Swift bindings).
Training details
Data
Trained on leetcode-cpp-sft, built from the doocs/leetcode corpus: problem statement + input/output examples + algorithm tag โ verified C++ solution, one-to-many (problem โ multiple algorithm-tagged solutions).
Hyperparameters
| Parameter | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Quantization | 4-bit NF4 (QLoRA) |
| Max sequence length | 2048 |
| Optimizer | paged_adamw_8bit |
| LR schedule | 2e-4, cosine |
Training compute
| GPU | NVIDIA A40 (48GB) |
| Cloud provider | RunPod |
| CO2 estimate | self-reported, not measured with a carbon tracker โ treat as approximate |
Fine-tuned with Unsloth + TRL's SFTTrainer.
Bias, risks & limitations
Narrow specialization. This model is tuned tightly on LeetCode-style algorithmic problems โ general software-engineering code (frameworks, infra, business logic) is out of distribution.
Verify before trusting. Like any LLM, generated solutions can look plausible and still fail an edge case (empty input, integer overflow, off-by-one). Always run against test cases before use.
Not exhaustive on complexity. The model doesn't guarantee asymptotically optimal solutions โ check the complexity claims yourself for performance-sensitive use.
FAQ
Q: Can I merge the adapter into the base model?
Yes โ model.merge_and_unload() after loading with PEFT, or Unsloth's save_pretrained_merged().
Q: Why QLoRA instead of full fine-tuning? Qwen2.5-Coder-7B already has strong code priors from pretraining; QLoRA specializes the output format and LeetCode-specific patterns without the cost of full fine-tuning.
Q: Which quantization should I use on mobile? q4_k_m is the best size/quality tradeoff for phones; q5_k_m if you have RAM headroom; avoid q2/q3 for code generation โ correctness drops sharply below 4-bit.
Related models in this suite
| Model | Language |
|---|---|
| leetcode-python-qwen25-coder-7b | Python |
| leetcode-java-qwen25-coder-7b | Java |
| leetcode-cpp-qwen25-coder-7b | C++ (this model) |
| leetcode-javascript-qwen25-coder-7b | JavaScript |
Full collection: LeetCode Multi-Language Coder Suite
Changelog
| Version | Notes |
|---|---|
| v2.0 | Added GGUF builds, Ollama/vLLM/TGI deployment, benchmark harness (HumanEval-X, MultiPL-E, held-out test split) |
| v1.0 | Initial release โ QLoRA fine-tune on leetcode-cpp-sft |
Citation
@misc{leetcodecoder2026,
author = {Hebbar, Amaresh},
title = {LeetCode Multi-Language Coder Suite},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/AmareshHebbar}
}
Contact
- Downloads last month
- -
Model tree for AmareshHebbar/leetcode-cpp-qwen25-coder-7b
Base model
Qwen/Qwen2.5-7B