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
| 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 = |