Instructions to use devanshty/Code-Autopsy with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use devanshty/Code-Autopsy with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct") model = PeftModel.from_pretrained(base_model, "devanshty/Code-Autopsy") - Notebooks
- Google Colab
- Kaggle
Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- peft
|
| 5 |
+
- lora
|
| 6 |
+
- qwen2
|
| 7 |
+
- code-review
|
| 8 |
+
- safetensors
|
| 9 |
+
- code-generation
|
| 10 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Code Autopsy
|
| 14 |
+
|
| 15 |
+
## Model Description
|
| 16 |
+
Code Autopsy is a QLoRA adapter fine-tuned on top of Qwen2.5-Coder-7B-Instruct for automated code review. It analyzes code for bugs, security vulnerabilities, style issues, and best practice violations — providing detailed, actionable review comments similar to a senior engineer's review.
|
| 17 |
+
|
| 18 |
+
## Model Architecture
|
| 19 |
+
- **Base Model**: `Qwen/Qwen2.5-Coder-7B-Instruct`
|
| 20 |
+
- **Fine-tuning Method**: QLoRA (Quantized Low-Rank Adaptation) via PEFT
|
| 21 |
+
- **Checkpoint**: `checkpoint-809` (best checkpoint)
|
| 22 |
+
- **Task**: Code Review / Code Analysis
|
| 23 |
+
|
| 24 |
+
## Training Details
|
| 25 |
+
- **Framework**: HuggingFace PEFT + Transformers + BitsAndBytes
|
| 26 |
+
- **Training Steps**: 809 (best checkpoint selected)
|
| 27 |
+
- **Dataset**: Curated code review dataset with paired code + review comment examples
|
| 28 |
+
- **Quantization**: 4-bit NF4 quantization during training
|
| 29 |
+
|
| 30 |
+
## Files
|
| 31 |
+
| File | Description |
|
| 32 |
+
|------|-------------|
|
| 33 |
+
| `adapter_model.safetensors` | LoRA adapter weights |
|
| 34 |
+
| `adapter_config.json` | PEFT adapter configuration |
|
| 35 |
+
| `tokenizer.json` | Tokenizer vocabulary |
|
| 36 |
+
| `tokenizer_config.json` | Tokenizer configuration |
|
| 37 |
+
|
| 38 |
+
## Usage
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 42 |
+
from peft import PeftModel
|
| 43 |
+
import torch
|
| 44 |
+
from huggingface_hub import snapshot_download
|
| 45 |
+
|
| 46 |
+
# Download adapter
|
| 47 |
+
adapter_dir = snapshot_download(repo_id='devanshty/Code-Autopsy')
|
| 48 |
+
|
| 49 |
+
# Load base model with 4-bit quantization
|
| 50 |
+
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16)
|
| 51 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 52 |
+
"Qwen/Qwen2.5-Coder-7B-Instruct",
|
| 53 |
+
quantization_config=bnb_config,
|
| 54 |
+
device_map="auto"
|
| 55 |
+
)
|
| 56 |
+
tokenizer = AutoTokenizer.from_pretrained(adapter_dir)
|
| 57 |
+
|
| 58 |
+
# Load LoRA adapter
|
| 59 |
+
model = PeftModel.from_pretrained(base_model, adapter_dir)
|
| 60 |
+
model.eval()
|
| 61 |
+
|
| 62 |
+
# Review code
|
| 63 |
+
code =
|