CoolFace
Modelpublic

ronantakizawa/codereview-qwen32b-adapter

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
3likes22downloads
Model Card

CodeReview-Qwen32B

A fine-tuned Qwen2.5-Coder-32B-Instruct model specialized for code review. Trained on 48,460 human-written code review comments from the top GitHub repositories.

This is a QLoRA adapter (4-bit) trained with SFT.

Results

MetricBase Model (Zero-Shot)SFT Fine-TunedChange
BLEU-43.8216.91+343%
ROUGE-L F10.0810.216+167%
Sentence-BERT Cosine Sim0.4770.526+10%
Comment Type Accuracy0.000.640--
Comment Type Coverage0.001.00--

The fine-tuned model produces review comments with 4x more lexical overlap with real human reviews, nearly 3x longer matching subsequences, and correctly classifies its own comment type (suggestion, issue, refactoring, etc.) 64% of the time.

Model Details

Training

Dataset

The training data comes from ronantakizawa/github-codereview, containing 119K real inline code review triplets (code, review comment, revised code) extracted from merged pull requests across 504 top GitHub repositories.

Filtering: Quality score >= 0.5, minimum 50 char comments, deduplicated by (repo, PR, line), capped at 1000 examples per repo. 25 repos held out entirely for OOD evaluation.

Multi-Task SFT

The model was trained on four tasks simultaneously:

TaskMixDescription
Comment Generation50%Code + diff → [comment_type] review comment
Code Refinement20%Code + comment → revised code
Structured Review15%Multiple diffs → numbered multi-issue review
Negative Examples15%Clean code → "no issues found" (reduces false positives)

SFT Hyperparameters

ParameterValue
LoRA rank32
LoRA alpha32
LoRA dropout0
Target modulesq/k/v/oproj, gate/up/downproj
Learning rate2e-4 (cosine, 5% warmup)
Effective batch size16 (perdevice=2, gradaccum=8)
Epochs2
Max sequence length6,144 tokens
Precisionbf16
PackingEnabled
Gradient checkpointingUnsloth mode
Total steps3,029

Usage

With Unsloth (Recommended)

python
from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="ronantakizawa/codereview-qwen32b",
    max_seq_length=6144,
    dtype=None,
    load_in_4bit=True,
)
FastLanguageModel.for_inference(model)

messages = [
    {"role": "system", "content": (
        "You are an expert code reviewer for Python projects. "
        "Analyze the code and diff context, then provide a precise, "
        "actionable review comment identifying issues or suggesting improvements. "
        "If the code is well-written and has no issues, state that clearly."
    )},
    {"role": "user", "content": """**Pull Request:** Fix user authentication
**Repository:** example/app
**File:** auth/login.py
**Language:** Python

**Code under review (around line 42):**

def authenticate(username, password): user = db.query(f"SELECT * FROM users WHERE name='{username}'") if user and user.password == password: return create_session(user) return None


**Diff context:**

+def authenticate(username, password):

  • —user = db.query(f"SELECT * FROM users WHERE name='{username}'")
  • —if user and user.password == password:
  • —return create_session(user)
  • —return None

Review this code change and provide your comment."""},
]

input_text = tokenizer.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)

output = model.generate(**inputs, max_new_tokens=512, temperature=0.1)
print(tokenizer.decode(output[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))

With Transformers + PEFT

python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-32B-Instruct",
    device_map="auto",
    torch_dtype="auto",
    load_in_4bit=True,
)
model = PeftModel.from_pretrained(base_model, "ronantakizawa/codereview-qwen32b")
tokenizer = AutoTokenizer.from_pretrained("ronantakizawa/codereview-qwen32b")

Output Format

The model prefixes its output with a comment type tag:

[suggestion] Consider using parameterized queries instead of string formatting
to prevent SQL injection vulnerabilities. Replace the f-string with
db.query("SELECT * FROM users WHERE name=?", (username,))

Comment types: suggestion, issue, refactoring, style, performance, security, documentation, no_issues

Limitations

  • —Context window: Trained with 6,144 token sequences. Very large files are truncated around the review line.
  • —Single-comment focus: Primarily trained on individual inline comments, not full PR-level reviews (though 15% of training was structured multi-issue reviews).
  • —Language coverage: Best on Python, JavaScript, TypeScript, Java, Go, C++, Rust (the most represented languages in the training data). May underperform on less common languages.
  • —DPO regression: The DPO step did not improve over SFT with quality-score-based preference pairs. Model-generated pairs with an LLM judge may yield better results.

Citation

bibtex
@misc{codereview-qwen32b,
  title={CodeReview-Qwen32B: Fine-tuned Qwen2.5-Coder-32B for Automated Code Review},
  author={Ronan Takizawa},
  year={2026},
  url={https://huggingface.co/ronantakizawa/codereview-qwen32b}
}