CoolFace
Modelpublic

lucifer0077/code-review-agent-grpo

sourceHugging Facemitupdated 2mo agoView on Hugging Face
1likes15downloads
Model Card

๐Ÿ” code-review-agent-grpo

A Qwen2.5-Coder-7B model fine-tuned with GRPO (Group Relative Policy Optimization) to review and fix real-world code bugs across 6 programming languages.

Built for the Meta ร— HuggingFace ร— PyTorch OpenEnv Grand Finale โ€” Bangalore 2026.


๐Ÿ† Key Result

A 7B parameter model, after GRPO training on CodeReviewEnv, outperformed a 70B parameter baseline by 46% on average.
TaskGroq llama-3.3-70B (baseline)Qwen2.5-Coder-7B (GRPO)Change
easy0.951.13โ†‘ +0.18
medium0.901.28โ†‘ +0.38
hard0.150.48โ†‘ +0.33 (3x!)
api_security0.901.20โ†‘ +0.30
auth_system0.001.13โ†‘ +1.13 (from zero!)
AVERAGE0.581.04โ†‘ +0.46

๐ŸŽฏ What This Model Does

This model acts as an AI code reviewer that can:

  1. 1.Find bugs โ€” structured comments with line numbers and severity levels
  2. 2.Fix bugs โ€” suggest correct code patches for each issue found
  3. 3.Issue verdicts โ€” approve or request changes with clear reasoning
  4. 4.Handle 6 languages โ€” Python, JavaScript, SQL, React/JSX, Django, Node.js

๐Ÿš€ Quick Start

python
from transformers import pipeline

reviewer = pipeline(
    "text-generation",
    model="lucifer0077/code-review-agent-grpo",
    device_map="auto"
)

code_to_review = """
def process_tasks(queue):
    while queue:
        task = queue.pop(0)  # multiple workers sharing this queue
        handle(task)
"""

prompt = f"""Review this code for bugs. For each bug found, provide:
- Line number
- Severity (critical/major/minor)
- Description
- Suggested fix

Code:
{code_to_review}
"""

output = reviewer(
    [{"role": "user", "content": prompt}],
    max_new_tokens=512,
    return_full_text=False
)[0]

print(output["generated_text"])

๐Ÿ—๏ธ Training Details

Environment โ€” CodeReviewEnv

This model was trained inside CodeReviewEnv, a custom OpenEnv-compliant RL environment with:

  • โ€”13 tasks across 6 languages
  • โ€”Curriculum learning โ€” automatically promotes agent from easy โ†’ medium โ†’ hard
  • โ€”Anti-reward hacking โ€” spam detection, duplicate detection, quality checks
  • โ€”Dense reward shaping โ€” rewards at every step, not just episode end

Reward Function

SignalReward
โœ… Critical bug found+0.20
โœ… Major bug found+0.12
โœ… Minor bug found+0.05
โŒ False positiveโˆ’0.08
โœ… Correct verdict+0.10
โŒ Wrong verdictโˆ’0.15
โœ… Correct fix (critical)+0.40
โœ… Correct fix (major)+0.35
โŒ Wrong fixโˆ’0.10
โฑ๏ธ Step penaltyโˆ’0.02/step

Hyperparameters

ParameterValue
Base ModelQwen2.5-Coder-7B-Instruct
GPUA100 (40GB)
Training Steps250
FrameworkUnsloth + TRL
LoRA Rank32
Learning Rate3e-6
Training Time2h 43min

Learning Curve

Reward increased from ~0.60 โ†’ ~1.15 over 250 training steps, surpassing the Groq llama-3.3-70B baseline (0.58) early in training.


๐ŸŒ Supported Tasks & Languages

LanguageTasksBug Types
Pythoneasy, medium, hard, apisecurity, authsystem, ormbugs, datapipelineZeroDivisionError, SQL injection, race conditions, JWT bypass, N+1 queries
JavaScriptjs_async, node-raceMissing await, callback hell, memory leaks
SQLsql-injectionORDER BY injection, LIMIT injection
React/JSXreact-securityXSS via dangerouslySetInnerHTML, token leaks
Djangodjango-authTiming attacks, plaintext comparison
Node.jsnode-raceInventory oversell, atomicity bugs

๐Ÿ”— Links

ResourceLink
๐ŸŒ Live Demohttps://lucifer0077-code-review-env.hf.space
๐Ÿ‹๏ธ Training Spacehttps://huggingface.co/spaces/lucifer0077/code-review-training
๐Ÿ“ Blog Posthttps://huggingface.co/blog/lucifer0077/codereviewenv-grpo-7b-vs-70b
๐Ÿ’ป GitHubhttps://github.com/Lucifer-cyber007/meta-hackathon-open-env

๐Ÿ“š Citation

If you use this model or environment, please cite:

bibtex
@misc{codereviewenv2026,
  title     = {CodeReviewEnv: A Self-Improving AI Code Review Agent via GRPO},
  author    = {Aditya Sharma},
  year      = {2026},
  publisher = {HuggingFace},
  url       = {https://huggingface.co/lucifer0077/code-review-agent-grpo}
}

Framework Citations

bibtex
@article{shao2024deepseekmath,
  title  = {DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models},
  author = {Zhihong Shao et al.},
  year   = {2024},
  eprint = {arXiv:2402.03300}
}

Built at Meta ร— HuggingFace ร— PyTorch OpenEnv Grand Finale โ€” April 2026, Bangalore

Theme 4: Self-Improving Agent | Theme 3.1: Professional Tasks