AmareshHebbar commited on
Commit
6116852
Β·
verified Β·
1 Parent(s): 4f35c38

docs: v2 model card - GGUF/Ollama/vLLM/TGI, benchmark table, collection link

Browse files
Files changed (1) hide show
  1. README.md +317 -14
README.md CHANGED
@@ -1,22 +1,325 @@
1
  ---
2
- base_model: unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - qwen2
8
- - trl
9
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
10
  language:
11
- - en
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- # Uploaded model
15
 
16
- - **Developed by:** AmareshHebbar
17
- - **License:** apache-2.0
18
- - **Finetuned from model :** unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
 
 
 
 
 
 
19
 
20
- This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
1
  ---
 
 
 
 
 
 
 
2
  license: apache-2.0
3
+ base_model: unsloth/Qwen2.5-Coder-7B-Instruct
4
+ tags:
5
+ - code
6
+ - leetcode
7
+ - java
8
+ - code-generation
9
+ - competitive-programming
10
+ - qwen2.5-coder
11
+ - qlora
12
+ - unsloth
13
+ - algorithms
14
  language:
15
+ - en
16
+ library_name: peft
17
+ pipeline_tag: text-generation
18
+ datasets:
19
+ - AmareshHebbar/leetcode-java-sft
20
+ co2_eq_emissions:
21
+ emissions: 0
22
+ source: "estimate, not measured with a carbon-tracking tool"
23
+ training_type: "fine-tuning"
24
+ geographical_location: "EU-West"
25
+ hardware_used: "NVIDIA A40 (48GB)"
26
+ model-index:
27
+ - name: leetcode-java-qwen25-coder-7b
28
+ results: []
29
+ ---
30
+
31
+ <div align="center">
32
+
33
+ # β˜• LeetCode Java Coder
34
+ ### Qwen2.5-Coder-7B fine-tuned to solve LeetCode problems in Java
35
+
36
+ [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Model-leetcode--java--qwen25--coder--7b-FFD21E)](https://huggingface.co/AmareshHebbar/leetcode-java-qwen25-coder-7b)
37
+ [![Dataset](https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-leetcode--java--sft-blue)](https://huggingface.co/datasets/AmareshHebbar/leetcode-java-sft)
38
+ [![GGUF](https://img.shields.io/badge/GGUF-quantized-6f42c1)](https://huggingface.co/AmareshHebbar/leetcode-java-qwen25-coder-7b-GGUF)
39
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green)](https://www.apache.org/licenses/LICENSE-2.0)
40
+ [![Base Model](https://img.shields.io/badge/base-Qwen2.5--Coder--7B-orange)](https://huggingface.co/unsloth/Qwen2.5-Coder-7B-Instruct)
41
+ [![Ollama](https://img.shields.io/badge/-Ollama-000000?logo=ollama)](#ollama)
42
+ [![vLLM](https://img.shields.io/badge/-vLLM-333333)](#vllm)
43
+ [![TGI](https://img.shields.io/badge/-TGI-yellow)](#tgi)
44
+
45
+ *Part of the [LeetCode Multi-Language Coder Suite](https://huggingface.co/collections/AmareshHebbar/leetcode-multi-language-coder-suite) β€” 4 language specialists, one base model*
46
+
47
+ </div>
48
+
49
+ ---
50
+
51
+ ## TL;DR
52
+
53
+ Given a LeetCode-style problem statement and an algorithm tag, generates a working Java solution.
54
+
55
+ ```
56
+ PROBLEM: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
57
+ ALGORITHM: Hash Map
58
+ OUTPUT (Java):
59
+ class Solution {
60
+ public int[] twoSum(int[] nums, int target) {
61
+ Map<Integer, Integer> seen = new HashMap<>();
62
+ for (int i = 0; i < nums.length; i++) {
63
+ if (seen.containsKey(target - nums[i])) {
64
+ return new int[]{seen.get(target - nums[i]), i};
65
+ }
66
+ seen.put(nums[i], i);
67
+ }
68
+ return new int[]{};
69
+ }
70
+ }
71
+ ```
72
+
73
+ | | |
74
+ |---|---|
75
+ | **Base model** | [unsloth/Qwen2.5-Coder-7B-Instruct](https://huggingface.co/unsloth/Qwen2.5-Coder-7B-Instruct) |
76
+ | **Method** | QLoRA, 4-bit NF4, rank 16 |
77
+ | **Training data** | [leetcode-java-sft](https://huggingface.co/datasets/AmareshHebbar/leetcode-java-sft) |
78
+ | **Weights here** | LoRA adapter only (~160MB) β€” load on top of the base model |
79
+ | **GGUF build** | [leetcode-java-qwen25-coder-7b-GGUF](https://huggingface.co/AmareshHebbar/leetcode-java-qwen25-coder-7b-GGUF) β€” q4_k_m / q5_k_m / q8_0 |
80
+ | **License** | Apache 2.0 |
81
+
82
+ ---
83
+
84
+ ## Benchmarks (free, reproducible)
85
+
86
+ Run `benchmark_suite.py` from the deployment kit to reproduce. All numbers are pass@1 unless noted.
87
+
88
+ | Benchmark | Language | Pass@1 | Pass@10 | Notes |
89
+ |---|---|---|---|---|
90
+ | [HumanEval-X](https://huggingface.co/datasets/THUDM/humaneval-x) | Java | _run benchmark_suite.py_ | _run benchmark_suite.py_ | 164 problems, execution-verified |
91
+ | [MultiPL-E](https://huggingface.co/datasets/nuprl/MultiPL-E) (HumanEval subset) | Java | _run benchmark_suite.py_ | β€” | cross-check vs HumanEval-X |
92
+ | Held-out LeetCode test split | Java | _run benchmark_suite.py_ | β€” | from `leetcode-java-sft` test split, exact I/O match |
93
+ | Tokens/sec (fp16, A40) | Java | β€” | β€” | latency benchmark, see script |
94
+ | Tokens/sec (GGUF q4_k_m, CPU) | Java | β€” | β€” | latency benchmark, see script |
95
+
96
+ > Numbers are intentionally left blank in this template β€” `benchmark_suite.py` fills a `results/leetcode-java-qwen25-coder-7b.json` file and this table should be regenerated from it (see deployment kit README).
97
+
98
+ ---
99
+
100
+ ## Intended use
101
+
102
+ Drop-in solution generator for Java coding-practice tools, interview-prep apps, and automated code-review sandboxes for algorithmic problems.
103
+
104
+ ### Direct use
105
+ Give a problem statement (+ optional algorithm hint), get back a Java function/class implementing it.
106
+
107
+ ### Downstream use
108
+ Feed output into an automated grader (run against test cases), a code-review bot, or a practice-app "show solution" feature.
109
+
110
+ ### Out of scope
111
+ - Production system design or non-algorithmic code (this model specializes narrowly on LeetCode-style problems)
112
+ - Security-critical code without human review
113
+ - Guaranteed-optimal complexity β€” treat output as a strong first draft, not a proof
114
+
115
+ ---
116
+
117
+ ## Quickstart
118
+
119
+ ### Option A β€” Transformers + PEFT
120
+
121
+ ```python
122
+ from transformers import AutoModelForCausalLM, AutoTokenizer
123
+ from peft import PeftModel
124
+ import torch
125
+
126
+ base_model = "unsloth/Qwen2.5-Coder-7B-Instruct"
127
+ adapter = "AmareshHebbar/leetcode-java-qwen25-coder-7b"
128
+
129
+ tokenizer = AutoTokenizer.from_pretrained("AmareshHebbar/leetcode-java-qwen25-coder-7b")
130
+ model = AutoModelForCausalLM.from_pretrained(
131
+ base_model,
132
+ torch_dtype=torch.bfloat16,
133
+ device_map="auto",
134
+ )
135
+ model = PeftModel.from_pretrained(model, adapter)
136
+
137
+ messages = [
138
+ {"role": "system", "content": "You are an expert Java competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient Java solution."},
139
+ {"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"},
140
+ ]
141
+ inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
142
+ outputs = model.generate(inputs, max_new_tokens=512, temperature=0.2, do_sample=True)
143
+ print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
144
+ ```
145
+
146
+ ### Option B β€” Unsloth (2x faster load + inference)
147
+
148
+ ```python
149
+ from unsloth import FastLanguageModel
150
+
151
+ model, tokenizer = FastLanguageModel.from_pretrained(
152
+ model_name="AmareshHebbar/leetcode-java-qwen25-coder-7b",
153
+ max_seq_length=2048,
154
+ load_in_4bit=True,
155
+ )
156
+ FastLanguageModel.for_inference(model)
157
+
158
+ messages = [
159
+ {"role": "system", "content": "You are an expert Java competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient Java solution."},
160
+ {"role": "user", "content": "Problem: Given a string s, find the length of the longest substring without repeating characters.\nAlgorithm: two pointers / sliding window"},
161
+ ]
162
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
163
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
164
+ outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.2, do_sample=True)
165
+ print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
166
+ ```
167
+
168
+ ### Option C β€” vLLM (production serving, OpenAI-compatible) {#vllm}
169
+
170
+ ```bash
171
+ vllm serve unsloth/Qwen2.5-Coder-7B-Instruct \
172
+ --enable-lora \
173
+ --lora-modules leetcode-java-qwen25-coder-7b=AmareshHebbar/leetcode-java-qwen25-coder-7b \
174
+ --host 0.0.0.0 --port 8000 --dtype bfloat16
175
+ ```
176
+
177
+ ```python
178
+ from openai import OpenAI
179
+
180
+ client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")
181
+ response = client.chat.completions.create(
182
+ model="leetcode-java-qwen25-coder-7b",
183
+ messages=[
184
+ {"role": "system", "content": "You are an expert Java competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient Java solution."},
185
+ {"role": "user", "content": "Problem: Merge two sorted linked lists into one sorted list.\nAlgorithm: linked list, dummy head"},
186
+ ],
187
+ temperature=0.2,
188
+ )
189
+ print(response.choices[0].message.content)
190
+ ```
191
+
192
+ ### Option D β€” TGI (Text Generation Inference) {#tgi}
193
+
194
+ ```bash
195
+ docker run --gpus all --shm-size 1g -p 8080:80 \
196
+ -v $PWD/data:/data ghcr.io/huggingface/text-generation-inference:latest \
197
+ --model-id unsloth/Qwen2.5-Coder-7B-Instruct \
198
+ --lora-adapters leetcode-java-qwen25-coder-7b=AmareshHebbar/leetcode-java-qwen25-coder-7b
199
+ ```
200
+
201
+ ```bash
202
+ curl 127.0.0.1:8080/generate_stream \
203
+ -X POST \
204
+ -d '{"inputs":"<|im_start|>system\nYou are an expert Java competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient Java 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}}' \
205
+ -H 'Content-Type: application/json'
206
+ ```
207
+
208
+ ### Option E β€” Ollama (local, mobile/edge-friendly) {#ollama}
209
+
210
+ ```bash
211
+ # 1. Pull the GGUF build
212
+ huggingface-cli download AmareshHebbar/leetcode-java-qwen25-coder-7b-GGUF leetcode-java-qwen25-coder-7b.q4_k_m.gguf --local-dir .
213
+
214
+ # 2. Create the model from the Modelfile shipped in the deployment kit (see deploy_ollama.py)
215
+ ollama create leetcode-java-qwen25-coder-7b -f Modelfile.java
216
+
217
+ # 3. Run it
218
+ ollama run leetcode-java-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"
219
+ ```
220
+
221
+ ### Option F β€” GGUF / llama.cpp direct (mobile/edge inference)
222
+
223
+ ```bash
224
+ ./llama-cli -m leetcode-java-qwen25-coder-7b.q4_k_m.gguf \
225
+ -p "<|im_start|>system\nYou are an expert Java competitive programmer. Given a LeetCode-style problem statement and an algorithm tag, write a correct, efficient Java 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" \
226
+ -n 512 --temp 0.2
227
+ ```
228
+
229
+ 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).
230
+
231
+ ---
232
+
233
+ ## Training details
234
+
235
+ ### Data
236
+
237
+ Trained on [leetcode-java-sft](https://huggingface.co/datasets/AmareshHebbar/leetcode-java-sft), built from the `doocs/leetcode` corpus: problem statement + input/output examples + algorithm tag β†’ verified Java solution, one-to-many (problem β†’ multiple algorithm-tagged solutions).
238
+
239
+ ### Hyperparameters
240
+
241
+ | Parameter | Value |
242
+ |---|---|
243
+ | LoRA rank (r) | 16 |
244
+ | LoRA alpha | 32 |
245
+ | LoRA dropout | 0 |
246
+ | Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
247
+ | Quantization | 4-bit NF4 (QLoRA) |
248
+ | Max sequence length | 2048 |
249
+ | Optimizer | paged_adamw_8bit |
250
+ | LR schedule | 2e-4, cosine |
251
+
252
+ ### Training compute
253
+
254
+ | | |
255
+ |---|---|
256
+ | **GPU** | NVIDIA A40 (48GB) |
257
+ | **Cloud provider** | RunPod |
258
+ | **CO2 estimate** | self-reported, not measured with a carbon tracker β€” treat as approximate |
259
+
260
+ Fine-tuned with [Unsloth](https://github.com/unslothai/unsloth) + TRL's `SFTTrainer`.
261
+
262
+ ---
263
+
264
+ ## Bias, risks & limitations
265
+
266
+ **Narrow specialization.** This model is tuned tightly on LeetCode-style algorithmic problems β€” general software-engineering code (frameworks, infra, business logic) is out of distribution.
267
+
268
+ **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.
269
+
270
+ **Not exhaustive on complexity.** The model doesn't guarantee asymptotically optimal solutions β€” check the complexity claims yourself for performance-sensitive use.
271
+
272
+ ---
273
+
274
+ ## FAQ
275
+
276
+ **Q: Can I merge the adapter into the base model?**
277
+ Yes β€” `model.merge_and_unload()` after loading with PEFT, or Unsloth's `save_pretrained_merged()`.
278
+
279
+ **Q: Why QLoRA instead of full fine-tuning?**
280
+ 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.
281
+
282
+ **Q: Which quantization should I use on mobile?**
283
+ 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.
284
+
285
+ ---
286
+
287
+ ## Related models in this suite
288
+
289
+ | Model | Language |
290
+ |---|---|
291
+ | [leetcode-python-qwen25-coder-7b](https://huggingface.co/AmareshHebbar/leetcode-python-qwen25-coder-7b) | Python |
292
+ | [leetcode-java-qwen25-coder-7b](https://huggingface.co/AmareshHebbar/leetcode-java-qwen25-coder-7b) | Java (this model) |
293
+ | [leetcode-cpp-qwen25-coder-7b](https://huggingface.co/AmareshHebbar/leetcode-cpp-qwen25-coder-7b) | C++ |
294
+ | [leetcode-javascript-qwen25-coder-7b](https://huggingface.co/AmareshHebbar/leetcode-javascript-qwen25-coder-7b) | JavaScript |
295
+
296
+ **Full collection:** [LeetCode Multi-Language Coder Suite](https://huggingface.co/collections/AmareshHebbar/leetcode-multi-language-coder-suite)
297
+
298
+ ---
299
+
300
+ ## Changelog
301
+
302
+ | Version | Notes |
303
+ |---|---|
304
+ | v2.0 | Added GGUF builds, Ollama/vLLM/TGI deployment, benchmark harness (HumanEval-X, MultiPL-E, held-out test split) |
305
+ | v1.0 | Initial release β€” QLoRA fine-tune on leetcode-java-sft |
306
+
307
  ---
308
 
309
+ ## Citation
310
 
311
+ ```bibtex
312
+ @misc{leetcodecoder2026,
313
+ author = {Hebbar, Amaresh},
314
+ title = {LeetCode Multi-Language Coder Suite},
315
+ year = {2026},
316
+ publisher = {HuggingFace},
317
+ url = {https://huggingface.co/AmareshHebbar}
318
+ }
319
+ ```
320
 
321
+ ## Contact
322
 
323
+ [![GitHub](https://img.shields.io/badge/GitHub-amareshhebbar-181717?logo=github)](https://github.com/amareshhebbar)
324
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-gvamaresh-0A66C2?logo=linkedin)](https://www.linkedin.com/in/gvamaresh)
325
+ [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Profile-AmareshHebbar-FFD21E)](https://huggingface.co/AmareshHebbar)