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.).
Parameters
Architecture
Context
Precision
License
Overview
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.
Key Features
Specialized Focus: Trained exclusively on coding and math data for maximum performance in these domains
Efficient Size: 1.5B parameters — runs on consumer GPUs, fast inference
Extended Context: Supports up to 4096 tokens for longer code generation
Multi-Language: Handles Python, JavaScript, C++, Java, and more
Competitive Programming: Strong on algorithmic problems (LeetCode, Codeforces-style)
1from transformers import AutoModelForCausalLM, AutoTokenizer
23model_id ="uaytug/ucoder-mini"45tokenizer = AutoTokenizer.from_pretrained(model_id)6model = AutoModelForCausalLM.from_pretrained(7 model_id,8 torch_dtype="auto",9 device_map="auto"10)1112messages =[13{"role":"user","content":"Write a Python function to find the longest palindromic substring."}14]1516text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)17inputs = tokenizer(text, return_tensors="pt").to(model.device)1819outputs = model.generate(20**inputs,21 max_new_tokens=1024,22 temperature=0.6,23 top_p=0.95,24 do_sample=True25)2627response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)28print(response)
Recommended Generation Parameters
For best results on coding tasks:
python
1generation_config ={2"max_new_tokens":2048,3"temperature":0.6,# Use 0.6 for focused output, 1.0 for more exploration4"top_p":0.95,5"do_sample":True,6}
Chat Template
uCoder Mini uses the ChatML format:
<|im_start|>user
Your coding question here<|im_end|>
<|im_start|>assistant
Training Data
Trained on UCDS (uCoder Dataset) — a curated collection of 420K+ high-quality samples:
Source
Samples
Description
Codeforces
47K+
Competitive programming with solutions
Code-Contests-Plus
10K+
Algorithm challenges
CodeAlpaca
15K+
Instruction-following code
OpenMathInstruct
Various
Mathematical reasoning chains
Curated Sources
Various
Tool use, chain-of-thought, deduplication
Total: 420,686 deduplicated samples covering Python, JavaScript, C++, Java, and more.
Limitations
Domain-Specific: This model is trained only on code/math — it will perform poorly on general tasks
English Only: Best performance in English; other languages not supported
Knowledge Cutoff: May not know about recent libraries, frameworks, or API changes
No Verification: Always test generated code before use in production
Context Limit: 4096 tokens may not be enough for very large codebases
No Web Access: Cannot fetch documentation or search for solutions
Example Outputs
Algorithm Problem
Prompt: Implement a function to find the kth largest element in an unsorted array.
python
1import heapq
23deffind_kth_largest(nums, k):4# Use a min-heap of size k5# Time: O(n log k), Space: O(k)6 heap =[]7for num in nums:8 heapq.heappush(heap, num)9iflen(heap)> k:10 heapq.heappop(heap)11return heap[0]1213# Alternative: QuickSelect for O(n) average14defquickselect(nums, k):15 k =len(nums)- k # Convert to kth smallest1617defpartition(left, right, pivot_idx):18 pivot = nums[pivot_idx]19 nums[pivot_idx], nums[right]= nums[right], nums[pivot_idx]20 store_idx = left
21for i inrange(left, right):22if nums[i]< pivot:23 nums[store_idx], nums[i]= nums[i], nums[store_idx]24 store_idx +=125 nums[right], nums[store_idx]= nums[store_idx], nums[right]26return store_idx
2728 left, right =0,len(nums)-129whileTrue:30 pivot_idx = partition(left, right, right)31if pivot_idx == k:32return nums[k]33elif pivot_idx < k:34 left = pivot_idx +135else:36 right = pivot_idx -1
Mathematical Reasoning
Prompt: Prove that the sum of the first n odd numbers equals n².
Response:
Let's prove this by multiple methods:
Method 1: Direct Calculation
The first n odd numbers are: 1, 3, 5, ..., (2n-1)
Sum = 1 + 3 + 5 + ... + (2n-1)
This is an arithmetic sequence with:
First term a₁ = 1
Last term aₙ = 2n - 1
Number of terms = n
Sum = n × (first + last) / 2 = n × (1 + 2n - 1) / 2 = n × 2n / 2 = n²
Method 2: Induction
Base case: n=1 → Sum = 1 = 1² ✓
Assume true for k: 1 + 3 + ... + (2k-1) = k²
For k+1: k² + (2(k+1)-1) = k² + 2k + 1 = (k+1)² ✓
Debugging
Prompt: Why does this code give wrong results?
python
1defbinary_search(arr, target):2 left, right =0,len(arr)3while left < right:4 mid =(left + right)/25if arr[mid]== target:6return mid
7elif arr[mid]< target:8 left = mid
9else:10 right = mid
11return-1
Response: There are several bugs:
Integer division: mid = (left + right) / 2 returns a float. Use // for integer division.
Infinite loop: left = mid can cause infinite loop when mid == left. Should be left = mid + 1.
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.
Fixed version:
python
1defbinary_search(arr, target):2 left, right =0,len(arr)-13while left <= right:4 mid =(left + right)//25if arr[mid]== target:6return mid
7elif arr[mid]< target:8 left = mid +19else:10 right = mid -111return-1
Hardware Requirements
Setup
VRAM Required
Notes
FP16/BF16
~4 GB
Full precision inference
Citation
bibtex
1@misc{ucoder-mini,
2 author = {uaytug},
3 title = {uCoder Mini: A Compact Language Model for Code and Math},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/uaytug/ucoder-mini}
7}
Acknowledgments
Thanks to the open-source community and creators of the datasets that made UCDS possible.