uaytug commited on
Commit
47e99e0
·
verified ·
1 Parent(s): 5be0473

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +188 -57
README.md CHANGED
@@ -9,6 +9,7 @@ tags:
9
  - reasoning
10
  - text-generation
11
  - conversational
 
12
  pipeline_tag: text-generation
13
  library_name: transformers
14
  datasets:
@@ -20,23 +21,51 @@ model-index:
20
 
21
  # uCoder Mini
22
 
23
- <div align="center">
24
- <img src="https://img.shields.io/badge/Parameters-1.5B-blue" alt="Parameters"> <img src="https://img.shields.io/badge/Context-4096-green" alt="Context Length"> <img src="https://img.shields.io/badge/License-Apache%202.0-orange" alt="License">
25
- </div>
26
 
27
  ## Overview
28
 
29
- **uCoder Mini** is a compact 1.5B parameter language model fine-tuned for code generation and mathematical reasoning. Despite its small size, it delivers strong performance on programming tasks across multiple languages and competitive programming challenges.
 
 
 
 
 
 
 
 
30
 
31
- Trained on the [UCDS (uCoder Dataset)](https://huggingface.co/datasets/uaytug/UCDS) — a curated collection of 420K+ high-quality coding and mathematics samples.
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  ## Intended Use
34
 
35
- - **Code generation** across Python, JavaScript, C++, Java, and more
36
- - **Competitive programming** problem solving
37
- - **Mathematical reasoning** and problem breakdown
38
- - **Code explanation** and debugging assistance
39
- - **Learning companion** for programming concepts
 
 
 
 
 
 
 
 
40
 
41
  ## Quick Start
42
 
@@ -61,9 +90,9 @@ inputs = tokenizer(text, return_tensors="pt").to(model.device)
61
 
62
  outputs = model.generate(
63
  **inputs,
64
- max_new_tokens=512,
65
- temperature=0.7,
66
- top_p=0.9,
67
  do_sample=True
68
  )
69
 
@@ -71,89 +100,191 @@ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_spec
71
  print(response)
72
  ```
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  ## Chat Template
75
 
76
  uCoder Mini uses the ChatML format:
77
 
78
  ```
79
  <|im_start|>user
80
- Your question here<|im_end|>
81
  <|im_start|>assistant
82
  ```
83
 
84
- ## Training Details
85
 
86
- | Attribute | Value |
87
- |-----------|-------|
88
- | **Training Dataset** | [uaytug/UCDS](https://huggingface.co/datasets/uaytug/UCDS) |
89
- | **Dataset Size** | 420,686 samples |
90
- | **Training Method** | Supervised Fine-Tuning (SFT) |
91
- | **Precision** | bfloat16 |
92
- | **Context Length** | 4096 tokens |
93
-
94
- ### Dataset Composition
95
 
96
- The UCDS dataset combines high-quality sources:
 
 
 
 
 
 
97
 
98
- | Source | Description |
99
- |--------|-------------|
100
- | CodeForces | Competitive programming problems |
101
- | Code-Contests-Plus | Algorithm challenges with solutions |
102
- | CodeAlpaca | Instruction-following code samples |
103
- | OpenMathInstruct | Mathematical reasoning chains |
104
- | Additional curated sources | Tool use, chain-of-thought examples |
105
 
106
  ## Limitations
107
 
108
- - **Model size**: As a 1.5B model, it may struggle with highly complex multi-file projects
109
- - **Knowledge cutoff**: Training data has a knowledge cutoff; recent libraries/APIs may not be covered
110
- - **Verification needed**: Always review and test generated code before production use
111
- - **Language coverage**: Strongest in Python; other languages may have reduced quality
 
 
112
 
113
  ## Example Outputs
114
 
115
  <details>
116
- <summary><b>Competitive Programming</b></summary>
117
 
118
- **Prompt:** Solve the two-sum problem efficiently.
119
 
120
- **Response:**
121
  ```python
122
- def two_sum(nums, target):
123
- seen = {}
124
- for i, num in enumerate(nums):
125
- complement = target - num
126
- if complement in seen:
127
- return [seen[complement], i]
128
- seen[num] = i
129
- return []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  ```
131
 
132
  </details>
133
 
134
  <details>
135
- <summary><b>Mathematical Reasoning</b></summary>
136
 
137
- **Prompt:** Find the time complexity of merge sort and explain why.
 
 
138
 
139
- **Response:** Merge sort has O(n log n) time complexity. Here's why:
140
 
141
- 1. **Divide step**: The array is split in half recursively, creating log(n) levels
142
- 2. **Merge step**: At each level, we process all n elements exactly once
143
- 3. **Total**: n elements × log(n) levels = O(n log n)
144
 
145
- This holds for best, average, and worst cases, making merge sort consistently efficient.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  </details>
148
 
 
 
 
 
 
 
 
 
149
  ## Citation
150
 
151
  ```bibtex
152
- @misc{ucoder-mini,
153
  author = {uaytug},
154
- title = {uCoder Mini: A Compact Code and Math Language Model},
155
  year = {2025},
156
  publisher = {Hugging Face},
157
  url = {https://huggingface.co/uaytug/ucoder-mini}
158
  }
159
- ```
 
 
 
 
 
9
  - reasoning
10
  - text-generation
11
  - conversational
12
+ - qwen2
13
  pipeline_tag: text-generation
14
  library_name: transformers
15
  datasets:
 
21
 
22
  # uCoder Mini
23
 
24
+ > **Important:** The model is unable to produce accurate and high-quality answers to general knowledge, creative writing, or non-coding tasks, and to questions asked in languages other than English. The answers to your questions in these areas may not be satisfactory because this model was specifically trained for **coding and mathematical reasoning tasks** (competitive programming, LeetCode, algorithm problems, etc.).
25
+
26
+ ![Parameters](https://img.shields.io/badge/Parameters-1.5B-blue) ![Architecture](https://img.shields.io/badge/Architecture-Qwen2-purple) ![Context](https://img.shields.io/badge/Context-4096-green) ![Precision](https://img.shields.io/badge/Precision-bfloat16-red) ![License](https://img.shields.io/badge/License-Apache%202.0-orange)
27
 
28
  ## Overview
29
 
30
+ **uCoder Mini** is a 1.5B parameter dense language model fine-tuned specifically for code generation and mathematical reasoning. Built on the Qwen2 architecture, this model demonstrates that small, focused models can achieve strong performance on programming tasks when trained on high-quality, curated data.
31
+
32
+ ### Key Features
33
+
34
+ - **Specialized Focus**: Trained exclusively on coding and math data for maximum performance in these domains
35
+ - **Efficient Size**: 1.5B parameters — runs on consumer GPUs, fast inference
36
+ - **Extended Context**: Supports up to 4096 tokens for longer code generation
37
+ - **Multi-Language**: Handles Python, JavaScript, C++, Java, and more
38
+ - **Competitive Programming**: Strong on algorithmic problems (LeetCode, Codeforces-style)
39
 
40
+ ## Model Details
41
+
42
+ | Attribute | Value |
43
+ |-----------|-------|
44
+ | **Architecture** | Qwen2 (Dense Transformer) |
45
+ | **Parameters** | ~1.5B |
46
+ | **Hidden Size** | 1536 |
47
+ | **Layers** | 28 |
48
+ | **Attention Heads** | 12 |
49
+ | **Context Length** | 4096 tokens |
50
+ | **Vocabulary Size** | 151,936 |
51
+ | **Training Precision** | bfloat16 |
52
+ | **Training Method** | Supervised Fine-Tuning (SFT) |
53
 
54
  ## Intended Use
55
 
56
+ **Recommended for:**
57
+ - Competitive programming (LeetCode, Codeforces, HackerRank)
58
+ - Algorithm implementation and optimization
59
+ - Mathematical problem solving with code
60
+ - Code debugging and explanation
61
+ - Learning programming concepts
62
+
63
+ **Not recommended for:**
64
+ - General conversation or chat
65
+ - Creative writing or storytelling
66
+ - Factual Q&A or knowledge retrieval
67
+ - Non-English tasks
68
+ - Production systems without human review
69
 
70
  ## Quick Start
71
 
 
90
 
91
  outputs = model.generate(
92
  **inputs,
93
+ max_new_tokens=1024,
94
+ temperature=0.6,
95
+ top_p=0.95,
96
  do_sample=True
97
  )
98
 
 
100
  print(response)
101
  ```
102
 
103
+ ### Recommended Generation Parameters
104
+
105
+ For best results on coding tasks:
106
+
107
+ ```python
108
+ generation_config = {
109
+ "max_new_tokens": 2048,
110
+ "temperature": 0.6, # Use 0.6 for focused output, 1.0 for more exploration
111
+ "top_p": 0.95,
112
+ "do_sample": True,
113
+ }
114
+ ```
115
+
116
  ## Chat Template
117
 
118
  uCoder Mini uses the ChatML format:
119
 
120
  ```
121
  <|im_start|>user
122
+ Your coding question here<|im_end|>
123
  <|im_start|>assistant
124
  ```
125
 
126
+ ## Training Data
127
 
128
+ Trained on [UCDS (uCoder Dataset)](https://huggingface.co/datasets/uaytug/UCDS) — a curated collection of 420K+ high-quality samples:
 
 
 
 
 
 
 
 
129
 
130
+ | Source | Samples | Description |
131
+ |--------|---------|-------------|
132
+ | Codeforces | 47K+ | Competitive programming with solutions |
133
+ | Code-Contests-Plus | 10K+ | Algorithm challenges |
134
+ | CodeAlpaca | 15K+ | Instruction-following code |
135
+ | OpenMathInstruct | Various | Mathematical reasoning chains |
136
+ | Curated Sources | Various | Tool use, chain-of-thought, deduplication |
137
 
138
+ **Total**: 420,686 deduplicated samples covering Python, JavaScript, C++, Java, and more.
 
 
 
 
 
 
139
 
140
  ## Limitations
141
 
142
+ - **Domain-Specific**: This model is trained only on code/math — it will perform poorly on general tasks
143
+ - **English Only**: Best performance in English; other languages not supported
144
+ - **Knowledge Cutoff**: May not know about recent libraries, frameworks, or API changes
145
+ - **No Verification**: Always test generated code before use in production
146
+ - **Context Limit**: 4096 tokens may not be enough for very large codebases
147
+ - **No Web Access**: Cannot fetch documentation or search for solutions
148
 
149
  ## Example Outputs
150
 
151
  <details>
152
+ <summary><b>Algorithm Problem</b></summary>
153
 
154
+ **Prompt:** Implement a function to find the kth largest element in an unsorted array.
155
 
 
156
  ```python
157
+ import heapq
158
+
159
+ def find_kth_largest(nums, k):
160
+ # Use a min-heap of size k
161
+ # Time: O(n log k), Space: O(k)
162
+ heap = []
163
+ for num in nums:
164
+ heapq.heappush(heap, num)
165
+ if len(heap) > k:
166
+ heapq.heappop(heap)
167
+ return heap[0]
168
+
169
+ # Alternative: QuickSelect for O(n) average
170
+ def quickselect(nums, k):
171
+ k = len(nums) - k # Convert to kth smallest
172
+
173
+ def partition(left, right, pivot_idx):
174
+ pivot = nums[pivot_idx]
175
+ nums[pivot_idx], nums[right] = nums[right], nums[pivot_idx]
176
+ store_idx = left
177
+ for i in range(left, right):
178
+ if nums[i] < pivot:
179
+ nums[store_idx], nums[i] = nums[i], nums[store_idx]
180
+ store_idx += 1
181
+ nums[right], nums[store_idx] = nums[store_idx], nums[right]
182
+ return store_idx
183
+
184
+ left, right = 0, len(nums) - 1
185
+ while True:
186
+ pivot_idx = partition(left, right, right)
187
+ if pivot_idx == k:
188
+ return nums[k]
189
+ elif pivot_idx < k:
190
+ left = pivot_idx + 1
191
+ else:
192
+ right = pivot_idx - 1
193
  ```
194
 
195
  </details>
196
 
197
  <details>
198
+ <summary><b>📐 Mathematical Reasoning</b></summary>
199
 
200
+ **Prompt:** Prove that the sum of the first n odd numbers equals n².
201
+
202
+ **Response:**
203
 
204
+ Let's prove this by multiple methods:
205
 
206
+ **Method 1: Direct Calculation**
207
+ The first n odd numbers are: 1, 3, 5, ..., (2n-1)
 
208
 
209
+ Sum = 1 + 3 + 5 + ... + (2n-1)
210
+
211
+ This is an arithmetic sequence with:
212
+ - First term a₁ = 1
213
+ - Last term aₙ = 2n - 1
214
+ - Number of terms = n
215
+
216
+ Sum = n × (first + last) / 2 = n × (1 + 2n - 1) / 2 = n × 2n / 2 = n²
217
+
218
+ **Method 2: Induction**
219
+ - Base case: n=1 → Sum = 1 = 1² ✓
220
+ - Assume true for k: 1 + 3 + ... + (2k-1) = k²
221
+ - For k+1: k² + (2(k+1)-1) = k² + 2k + 1 = (k+1)² ✓
222
+
223
+ </details>
224
+
225
+ <details>
226
+ <summary><b>🐛 Debugging</b></summary>
227
+
228
+ **Prompt:** Why does this code give wrong results?
229
+ ```python
230
+ def binary_search(arr, target):
231
+ left, right = 0, len(arr)
232
+ while left < right:
233
+ mid = (left + right) / 2
234
+ if arr[mid] == target:
235
+ return mid
236
+ elif arr[mid] < target:
237
+ left = mid
238
+ else:
239
+ right = mid
240
+ return -1
241
+ ```
242
+
243
+ **Response:** There are several bugs:
244
+
245
+ 1. **Integer division**: `mid = (left + right) / 2` returns a float. Use `//` for integer division.
246
+
247
+ 2. **Infinite loop**: `left = mid` can cause infinite loop when `mid == left`. Should be `left = mid + 1`.
248
+
249
+ 3. **Off-by-one**: With `right = len(arr)`, using `right = mid` is correct, but the initial range setup suggests you want `right = len(arr) - 1` with `left <= right`.
250
+
251
+ **Fixed version:**
252
+ ```python
253
+ def binary_search(arr, target):
254
+ left, right = 0, len(arr) - 1
255
+ while left <= right:
256
+ mid = (left + right) // 2
257
+ if arr[mid] == target:
258
+ return mid
259
+ elif arr[mid] < target:
260
+ left = mid + 1
261
+ else:
262
+ right = mid - 1
263
+ return -1
264
+ ```
265
 
266
  </details>
267
 
268
+ ## Hardware Requirements
269
+
270
+ | Setup | VRAM Required | Notes |
271
+ |-------|---------------|-------|
272
+ | FP16/BF16 | ~4 GB | Full precision inference |
273
+ | INT8 | ~2 GB | Quantized, minimal quality loss |
274
+ | INT4 | ~1.5 GB | For very constrained environments |
275
+
276
  ## Citation
277
 
278
  ```bibtex
279
+ @misc{ucoder-mini-2025,
280
  author = {uaytug},
281
+ title = {uCoder Mini: A Compact Language Model for Code and Math},
282
  year = {2025},
283
  publisher = {Hugging Face},
284
  url = {https://huggingface.co/uaytug/ucoder-mini}
285
  }
286
+ ```
287
+
288
+ ## Acknowledgments
289
+
290
+ Thanks to the open-source community and creators of the datasets that made UCDS possible.