Code benchmarks
Every model went through the same harness: the task goes in the chat template, the answer's code block is run against
the official tests, greedy decoding, pass@1, HumanEval (164 tasks) and MBPP sanitized test (257 tasks).
Qwen2.5-Coder-0.5B is a larger code-specialised model trained on trillions of tokens; it is a reference point, not a peer.
Table with columns: General benchmarks (0-shot, full set), acc_norm, (raw acc)| General benchmarks (0-shot, full set) | acc_norm | (raw acc) |
|---|
| HellaSwag | 41.08 | 34.85 |
| ARC-Easy | 60.02 | 63.13 |
| ARC-Challenge | 35.49 | 32.94 |
| PIQA | 68.61 | 68.01 |
| ArithMark-3 | 52.80 | 52.80 |
| Open SLM Leaderboard Intelligence Index | 30.98 | 28.48 |
Unedited answers, including the wrong ones, are in code_samples.md and
think_samples.md.
Think mode
Add the system prompt Think step by step before answering. and the model writes a short numbered plan inside
<think> ... </think> before the code. Without that system prompt it answers directly.
<think>To implement the function `fib_to_num`, we need to understand what the Fibonacci sequence is and how to compute it. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence goes: 0, 1, 1, 2, 3, 5, 8, 13, ... The steps to implement this function are as follows:1. **Understand the Input**: The input is an integer `n` which represents the position in the Fibonacci sequence.2. **Initialization**: Start with the first two numbers (0 and 1).3. **Iteration**: Use a loop to generate the next numbers in the sequence.4. **Accumulation**: Add the current two numbers together and store the result in a variable.5. **Return the Result**: Return the accumulated value as the n-th Fibonacci number. By following these steps, we can ensure that the function correctly computes the n-th Fibonacci number.</think>```pythondef fib_to_num(n): if n <= 0: return 0 elif n == 1: return 1 else: prev, curr = 0, 1 for _ in range(2, n + 1): prev, curr = curr, prev + curr return curr```
Thinking does not make it more accurate: think mode scores 12.8 on HumanEval (direct: 12.8) and 17.9 on MBPP
(direct: 24.9). It is there because the plan can be useful to read, not because it helps the score. In the
benchmark run every one of the 421 tasks produced a think block, and 3 of them did not finish it within 3,000 tokens.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizerrepo = "nkthebass/tinybrainbot-360m-a75m-v6-coder"tok = AutoTokenizer.from_pretrained(repo)model = AutoModelForCausalLM.from_pretrained(repo)msgs = [ # {"role": "system", "content": "Think step by step before answering."}, # uncomment for think mode {"role": "user", "content": "Write a function is_prime(n) that returns True if n is prime."},]ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt")out = model.generate(ids, max_new_tokens=600) # defaults from generation_config.jsontext = tok.decode(out[0], skip_special_tokens=False) # decode WITH the prompt, then cut it off (see below)print(text[len(tok.decode(ids[0], skip_special_tokens=False)):].split("<|end|>")[0].strip())
Decode the answer together with the prompt and cut the prompt off, as above. The tokenizer's decoder drops one leading
space from whatever it decodes, so decoding only the new tokens can turn a first 4-space indent into 3.
GGUF (llama.cpp, LM Studio, Jan, Ollama): Q8_0 (409 MB), Q4_K_M (239 MB) or F16 (768 MB). The chat template
is embedded and the context is 4,096 tokens. Checked against transformers: prompts with indented code and with the think
system prompt tokenize identically (4 of 4 prompts), and greedy F16 output was identical on 3 of 4 prompts; on the
fourth, a think-mode answer, the two diverged after 12 tokens.
llama-cli -m tinybrainbot-360m-a75m-v6-coder-Q8_0.gguf -cnv -c 4096 --temp 0.4 --top-p 0.9 --repeat-penalty 1.15 --logit-bias 241-inf --logit-bias 255-inf
Recommended sampling: temperature 0.4, top-p 0.9, repetition penalty 1.15 (the generation_config.json defaults).
Without a repetition penalty it can get stuck repeating a line, especially outside Python.
How it was made
Table with columns: Stage, Tokens, What| Stage | Tokens | What |
|---|
| 1. v6 base | see its card | general pretraining, 2,048 context |
| 2. Instruct tune | 393M | every weight, the v6 instruct mix (chat, instructions, math) |
| 3. Expert code anneal | 1.26B | 12 of the 24 experts per layer, context raised to 4,096 |
| 4. Code tune | 328M | every weight, code instructions with short reasoning traces |
Stage 3, code on half the experts. The 12 experts per layer that code text already used most were trained at the
full learning rate, attention, norms and routers at a tenth of it, and the other 12 experts were frozen (checked
bit-for-bit at every checkpoint). That kept the general scores almost flat while the model learned code: the Index
went from 32.62 to 32.38 over this stage. Data: 37% GitHub code (22 languages, about a fifth of it Python), 20%
codeparrot-clean Python, 24% OpenCoder annealing corpus, 19% replay of the earlier stages. The longer context needs
no new weights (positions are rotary), but the model had to see long inputs to use them.
Stage 4, code instructions. Shares of the training tokens:
Table with columns: Share, Data| Share | Data |
|---|
| 28% | Python, direct answers: OpenCoder SFT stage 2, self-oss-instruct-sc2, Tested-143k-Python-Alpaca, Magicoder OSS-Instruct, and the v5.1 Python model's test-passing answers on KodCode problems |
| 27% | Many languages, direct answers: CodeFeedback, Code-Feedback multi-turn, Glaive code assistant v3, Magicoder Evol-Instruct and OSS-Instruct, OpenCoder, CodeAlpaca |
| 20% | Short reasoning traces, at most 700 tokens of reasoning: Python function plans (notbadai), short DeepSeek-R1 traces on easy function tasks (allenai rlvr), debugging steps (CodeDebug-Instruct) |
| 25% | Replay of the instruct mix |
Table with columns: Step, HumanEval, MBPP| Step | HumanEval | MBPP |
|---|
| After stage 2 (instruct) | 0.0 | 1.2 |
| After stage 3 (code anneal) | 3.7 | 15.6 |
| After stage 4 (this model) | 12.8 | 24.9 |
Long traces hurt, short ones don't. A first version of stage 4 used long DeepSeek-R1 traces (a median of about
1,500 tokens of reasoning, 30% of the mix). Its think mode scored 9.2 on HumanEval and 13.2 on MBPP against 12.8 and
24.5 direct, and a fifth of its answers never finished thinking. The model copied the look of the reasoning, including
"tests" that checked nothing. With the short traces used here, think mode is level with direct on HumanEval and the
gap on MBPP is smaller.
Indentation. Each run of 4 spaces is one token (" ", id 24) and tabs become 4 spaces, so Python indentation
survives training and generation. Two or more spaces inside a line (not at the start) still collapse into one.
Contamination. Every instruction example that shares a 13-word sequence with HumanEval (prompts, solutions, tests)
or any MBPP split was dropped. No benchmark data was trained on.
Licences. The model is released under Apache-2.0. KodCode-V1 is CC BY-NC 4.0, the allenai rlvr trace set states no
licence on its card, and the code corpora carry their own source licences. Check those terms before any commercial use.
Limitations
- Short Python functions are its range. String and list processing, simple loops and recursion usually work.
Multi-step tasks often come out wrong.
- Other languages are unreliable. In the samples, the C++ factorial is right and the SQL query works (it returns customer ids, not names), the JavaScript
duplicate filter has its condition inverted, the Go "reverse" does not reverse, the batch file came out as Python, and
the Rust and PowerShell answers repeat one line until they run out of tokens.
- It explains code badly. Asked what a two-line function does, it described something else. Asked to fix a small
bug, its rewrite happened to remove the bug, but the explanation blamed something unrelated.
- Follow-ups lose the thread. "Now make it ignore spaces" dropped the reversal it had just written.
- Thinking is not checking. The plan reads well and the code can still be wrong.
- English only. It makes things up like any model this size. Run the code before you trust it.