CoolFace
Modelpublic

tkeskin/qwen-3.5-0.8b-code-translation

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes16downloads
Model Card

qwen-3.5-0.8b-code-translation

A fine-tuned version of Qwen/Qwen3.5-0.8B for translating code between C++, Java, and Python.

Training

  • —Base model: Qwen/Qwen3.5-0.8B
  • —Method: LoRA (Low-Rank Adaptation) via LLaMA-Factory
  • —Dataset: tkeskin/leetcode-solutions (instruct config) — directed C++/Java/Python translation pairs derived from LeetCode solutions
  • —Hardware: AMD MI210 (ROCm) / NVIDIA CUDA, flash_attn: sdpa
  • —Template: qwen3_5_nothink (non-thinking mode — direct code output, no chain-of-thought)
  • —LoRA target: all linear layers (lora_target: all)
  • —Precision: bf16

Evaluation

Evaluated with the same execution-based translation benchmark as the rest of this series: each held-out evaluation-config payload from tkeskin/leetcode-solutions is compiled and run against its input/output pairs. Held out from training (no leakage). Metric is pass@1, n-weighted over 3,336 payloads.

This fine-tune did not improve translation performance over the base model — pass@1 is essentially unchanged, fractionally lower (within noise):

Base (Qwen3.5-0.8B)This modelΔ
pass@116.2%15.7%−0.5
compile rate49.5%49.9%+0.4

For contrast, the same LoRA recipe and dataset lifted a larger code-pretrained base (Qwen2.5-Coder-1.5B) from 29.3% to 61.9% pass@1. The benefit appears to depend on model scale and code pre-training; at 0.8B, on this unusual architecture, the recipe did not transfer. We publish this result as-is rather than omit it.

pass@1 by language pair × difficulty (%):

sourcetargetdifficultybasethis model
cppjavaEasy11.713.8
cppjavaHard2.52.5
cppjavaMedium10.18.5
cpppythonEasy22.118.0
cpppythonHard11.59.2
cpppythonMedium18.818.5
javacppEasy14.317.7
javacppHard1.74.2
javacppMedium12.210.0
javapythonEasy36.634.9
javapythonHard16.010.7
javapythonMedium27.927.3
pythoncppEasy40.138.1
pythoncppHard7.610.1
pythoncppMedium20.724.1
pythonjavaEasy13.111.0
pythonjavaHard0.80.8
pythonjavaMedium5.44.3

Full methodology is in the llm-fine-tune repo (Stage 5).

Intended use

Given source code in one of C++, Java, or Python, the model generates a translation into the target language, following the same logic and structure.

Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "tkeskin/qwen-3.5-0.8b-code-translation"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

messages = [
    {
        "role": "user",
        "content": "Translate the following C++ code to Python:\n\nint add(int a, int b) { return a + b; }"
    }
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
outputs = model.generate(inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))