File size: 2,019 Bytes
4685d04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
license: mit
tags:
  - peft
  - lora
  - qwen2
  - code-review
  - safetensors
  - code-generation
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
---

# Code Autopsy

## Model Description
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.

## Model Architecture
- **Base Model**: `Qwen/Qwen2.5-Coder-7B-Instruct`
- **Fine-tuning Method**: QLoRA (Quantized Low-Rank Adaptation) via PEFT
- **Checkpoint**: `checkpoint-809` (best checkpoint)
- **Task**: Code Review / Code Analysis

## Training Details
- **Framework**: HuggingFace PEFT + Transformers + BitsAndBytes
- **Training Steps**: 809 (best checkpoint selected)
- **Dataset**: Curated code review dataset with paired code + review comment examples
- **Quantization**: 4-bit NF4 quantization during training

## Files
| File | Description |
|------|-------------|
| `adapter_model.safetensors` | LoRA adapter weights |
| `adapter_config.json` | PEFT adapter configuration |
| `tokenizer.json` | Tokenizer vocabulary |
| `tokenizer_config.json` | Tokenizer configuration |

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
from huggingface_hub import snapshot_download

# Download adapter
adapter_dir = snapshot_download(repo_id='devanshty/Code-Autopsy')

# Load base model with 4-bit quantization
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16)
base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-7B-Instruct",
    quantization_config=bnb_config,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(adapter_dir)

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, adapter_dir)
model.eval()

# Review code
code =