researchaudio commited on
Commit
3379b4e
Β·
verified Β·
1 Parent(s): 179288c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +278 -0
README.md ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-7B-Instruct
4
+ tags:
5
+ - code
6
+ - fine-tuned
7
+ - qwen
8
+ - python
9
+ - programming
10
+ - lora
11
+ - production-ready
12
+ language:
13
+ - en
14
+ pipeline_tag: text-generation
15
+ library_name: transformers
16
+ datasets:
17
+ - glaiveai/glaive-code-assistant-v2
18
+ ---
19
+
20
+ # Qwen2.5-Coder-7B-ResearchAudio-v2
21
+
22
+ **Production-Ready Code Generation Model**
23
+
24
+ Fine-tuned from [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) to produce **complete, clean, production-ready code**.
25
+
26
+ ## Why This Model?
27
+
28
+ | Base Model | This Model |
29
+ |------------|------------|
30
+ | Verbose explanations | Concise, to-the-point |
31
+ | Often truncates mid-function | **Complete implementations** |
32
+ | Theory-heavy for system design | **Working code** |
33
+ | Needs post-processing | Copy-paste ready |
34
+
35
+ ## Real-World Comparison
36
+
37
+ We tested both models on 10 coding problems. **This model won 9/10.**
38
+
39
+ ### Example: Rate Limiter
40
+
41
+ **Prompt:** "Design a rate limiter"
42
+
43
+ **Base Model Output:**
44
+ ```
45
+ Designing a rate limiter is crucial for maintaining performance...
46
+
47
+ ### 1. Define Requirements
48
+ - **Rate**: Maximum requests allowed per unit time
49
+ - **Time Window**: Duration over which rate limit applies
50
+ - **Concurrency**: How many clients can be processed...
51
+ ```
52
+ ❌ Theory only, no code
53
+
54
+ **This Model Output:**
55
+ ```python
56
+ import time
57
+
58
+ class RateLimiter:
59
+ def __init__(self, max_requests, period):
60
+ self.max_requests = max_requests
61
+ self.period = period
62
+ self.requests = []
63
+
64
+ def is_allowed(self):
65
+ current_time = int(time.time())
66
+ self.requests = [r for r in self.requests if current_time - r < self.period]
67
+ if len(self.requests) >= self.max_requests:
68
+ return False
69
+ self.requests.append(current_time)
70
+ return True
71
+ ```
72
+ βœ… Working implementation
73
+
74
+ ---
75
+
76
+ ### Example: Binary Search
77
+
78
+ **Base Model:** Long explanation, truncated code
79
+ ```
80
+ Sure! Binary search is an efficient algorithm for finding an item
81
+ from a sorted list of items. It works by repeatedly dividing...
82
+
83
+ def binary_search(arr, target):
84
+ """
85
+ Perform binary search on a sorted array to find the index...
86
+
87
+ Parameters:
88
+ arr (list): The sorted list of elements.
89
+ target (int/float): The value to search for...
90
+ ```
91
+ ❌ Verbose, truncated
92
+
93
+ **This Model:**
94
+ ```python
95
+ def binary_search(arr, x):
96
+ low = 0
97
+ high = len(arr) - 1
98
+
99
+ while low <= high:
100
+ mid = (low + high) // 2
101
+ if arr[mid] == x:
102
+ return mid
103
+ elif arr[mid] < x:
104
+ low = mid + 1
105
+ else:
106
+ high = mid - 1
107
+ return -1
108
+ ```
109
+ βœ… Clean, complete
110
+
111
+ ---
112
+
113
+ ### Example: Binary Tree Serialization
114
+
115
+ **Base Model:** Only showed TreeNode class definition, no actual serialization code
116
+
117
+ **This Model:**
118
+ ```python
119
+ class Node:
120
+ def __init__(self, val):
121
+ self.val = val
122
+ self.left = None
123
+ self.right = None
124
+
125
+ def serialize(root):
126
+ if root is None:
127
+ return '#'
128
+ left = serialize(root.left)
129
+ right = serialize(root.right)
130
+ return str(root.val) + ',' + left + ',' + right
131
+
132
+ def deserialize(data):
133
+ data_list = data.split(',')
134
+ index = [0]
135
+
136
+ def helper():
137
+ if data_list[index[0]] == '#':
138
+ index[0] += 1
139
+ return None
140
+ node = Node(int(data_list[index[0]]))
141
+ index[0] += 1
142
+ node.left = helper()
143
+ node.right = helper()
144
+ return node
145
+
146
+ return helper()
147
+ ```
148
+ βœ… Complete serialize AND deserialize
149
+
150
+ ---
151
+
152
+ ## Test Results Summary
153
+
154
+ | Problem | Base | v2 | Winner |
155
+ |---------|------|-----|--------|
156
+ | LRU Cache | Truncated | Complete | βœ… v2 |
157
+ | Binary Search | Verbose, truncated | Clean, complete | βœ… v2 |
158
+ | Rate Limiter | Theory only | Working code | βœ… v2 |
159
+ | Merge Sort | Truncated | More complete | βœ… v2 |
160
+ | Trie | Truncated at insert | Insert + search | βœ… v2 |
161
+ | Thread-safe Singleton | Complete | Complete | Tie |
162
+ | Dijkstra | Truncated | More complete | βœ… v2 |
163
+ | Retry Decorator | Verbose docstrings | Concise, working | βœ… v2 |
164
+ | Connection Pool | Truncated | Get + release | βœ… v2 |
165
+ | Binary Tree Serialize | TreeNode only | Full implementation | βœ… v2 |
166
+
167
+ **Score: 9/10 wins**
168
+
169
+ ---
170
+
171
+ ## Training Details
172
+
173
+ | Parameter | Value |
174
+ |-----------|-------|
175
+ | Base Model | Qwen2.5-Coder-7B-Instruct |
176
+ | Dataset | [glaive-code-assistant-v2](https://huggingface.co/datasets/glaiveai/glaive-code-assistant-v2) |
177
+ | Samples | 50,000 |
178
+ | Epochs | 2 |
179
+ | Method | LoRA (r=16, alpha=32) |
180
+ | Batch Size | 16 |
181
+ | Learning Rate | 2e-4 |
182
+ | Hardware | NVIDIA H200 |
183
+ | Training Time | ~4 hours |
184
+
185
+ ---
186
+
187
+ ## Benchmark Comparison
188
+
189
+ General benchmarks show slight decrease (expected when specializing for code):
190
+
191
+ | Benchmark | Base | v2 | Delta |
192
+ |-----------|------|-----|-------|
193
+ | MMLU | 64.6% | 62.8% | -1.8% |
194
+ | HellaSwag | 74.6% | 72.8% | -1.8% |
195
+ | Winogrande | 70.2% | 67.5% | -2.8% |
196
+ | ARC-Challenge | 48.5% | 48.4% | -0.1% |
197
+
198
+ **Trade-off:** Small general knowledge drop β†’ Much better code output quality
199
+
200
+ For a **code-focused model**, this is the right trade-off.
201
+
202
+ ---
203
+
204
+ ## Usage
205
+
206
+ ```python
207
+ from transformers import AutoModelForCausalLM, AutoTokenizer
208
+ import torch
209
+
210
+ model = AutoModelForCausalLM.from_pretrained(
211
+ "researchaudio/qwen2.5-coder-7b-researchaudio-v2",
212
+ torch_dtype=torch.bfloat16,
213
+ device_map="auto",
214
+ trust_remote_code=True
215
+ )
216
+ tokenizer = AutoTokenizer.from_pretrained(
217
+ "researchaudio/qwen2.5-coder-7b-researchaudio-v2",
218
+ trust_remote_code=True
219
+ )
220
+
221
+ prompt = "Implement a thread-safe queue in Python"
222
+ messages = [{"role": "user", "content": prompt}]
223
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
224
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
225
+
226
+ outputs = model.generate(**inputs, max_new_tokens=500, do_sample=False)
227
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Best For
233
+
234
+ βœ… Code generation APIs
235
+ βœ… IDE extensions / autocomplete
236
+ βœ… CI/CD automation
237
+ βœ… System design implementations
238
+ βœ… Prototyping
239
+ βœ… Learning algorithms (clear, complete examples)
240
+
241
+ ## Not Recommended For
242
+
243
+ ❌ General knowledge Q&A
244
+ ❌ Long explanations / tutorials
245
+ ❌ Non-code tasks
246
+
247
+ ---
248
+
249
+ ## Version History
250
+
251
+ | Version | Base | Dataset | Focus |
252
+ |---------|------|---------|-------|
253
+ | v1 | Qwen2.5-Coder-7B | 500K mixed (Magicoder, Nemotron, etc.) | General code |
254
+ | **v2** | v1 | 50K Glaive | **Production-ready output** |
255
+
256
+ ---
257
+
258
+ ## Citation
259
+
260
+ ```bibtex
261
+ @misc{qwen2.5-coder-researchaudio-v2,
262
+ author = {ResearchAudio},
263
+ title = {Qwen2.5-Coder-7B-ResearchAudio-v2: Production-Ready Code Generation},
264
+ year = {2024},
265
+ publisher = {HuggingFace},
266
+ url = {https://huggingface.co/researchaudio/qwen2.5-coder-7b-researchaudio-v2}
267
+ }
268
+ ```
269
+
270
+ ---
271
+
272
+ ## License
273
+
274
+ Apache 2.0
275
+
276
+ ---
277
+
278
+ **Built by [ResearchAudio](https://researchaudio.io)**