Rhea-Coder-0.5B: A compact Python coding assistant fine-tuned on a CPU
3 min readupdated
Rhea-Coder-0.5B is a lightweight language model with 0.49 billion parameters designed to generate Python code based on English instructions. The author roskosmos19 fine-tuned the base model Qwen/Qwen2.5-Coder-0.5B-Instruct using LoRA (a small set of trainable parameters added on top of frozen weights) on 1,008 examples from the Magicoder-OSS-Instruct-75K dataset. Unlike the original version, the model achieves a modest accuracy boost on the HumanEval task subset while retaining a minimal footprint and full compatibility with the transformers library. It is well-suited for developers looking to quickly generate short functions on low-end hardware or serve as a clear demonstration of efficient fine-tuning without a GPU entirely.
Key features
- Two formats in one repository: the root directory contains ready-made merged weights in
bf16 safetensorsformat, while theadapter/folder holds a standalone LoRA adapter for loading via PEFT. - CPU-only training: the entire training process took 119 minutes on two ARM cores (Neoverse-V2) using approximately 7 GB of RAM without any GPU usage.
- Benchmark leakage removal: examples overlapping in n-grams or function names with all 164 HumanEval tasks were excluded from the training set beforehand.
- Open Apache-2.0 license: the model inherits its permissive license from the base Qwen2.5-Coder-0.5B-Instruct and permits commercial use.
What you can do
- Generate short Python functions: integrate the model into a local script or chatbot to solve typical algorithmic problems (such as writing iterative functions) and receive code explanations.
- Run on a CPU or low-end machines: due to its 0.49B parameter size, the model can be deployed where a discrete graphics card with ample VRAM is unavailable.
- Study a budget LoRA tuning pipeline: use the parameters from the card as a reference for independently fine-tuning compact Qwen2.5 models on a processor.
Example
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "roskosmos19/Rhea-Coder-0.5B"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto")
messages = [{"role": "user", "content": "Write a Python function that returns the n-th Fibonacci number iteratively."}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Read more
DetailsBenchmark (subset of 40 HumanEval tasks, pass@1, greedy): 52.5% (21/40) versus 45.0% (18/40) for the base Qwen2.5-Coder-0.5B-Instruct (the author notes the small sample size: 1 task = 2.5%).
LoRA parameters: r = 16, alpha = 32, dropout = 0.05; trained 8.8 million parameters (1.75% of 503 million) across all linear projections for 1 epoch (63 steps).
Limitations: designed for English Python prompts and short functions; weak on long or multi-file code and can confidently output errors, so generated code must be tested.










Comments