AmareshHebbar commited on
Commit
2d838b0
Β·
verified Β·
1 Parent(s): 948de8f

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

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