Team Ai
Modelpublic

Maaac/CodeLLaMA-Linux-BugFix

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes8downloads
1---2license: mit3tags:4  - linux5  - bugfix6  - codellama7  - qlora8  - transformers9  - causal-lm10model_type: causal-lm11library_name: transformers12pipeline_tag: text-generation13base_model: codellama/CodeLLaMA-7b-Instruct-hf14language:15  - en16  - c17---18 19# CodeLLaMA-Linux-BugFix20 21A fine-tuned CodeLLaMA-7B-Instruct model specifically designed for Linux kernel bug fixing. This model generates Git diff patches from buggy C code and commit messages.22 23## Model Description24 25This model is a QLoRA fine-tuned version of CodeLLaMA-7B-Instruct, trained on a dataset of Linux kernel bug fixes extracted from Git commits. It learns to generate appropriate Git diff patches that can fix bugs in C code.26 27- **Developed by:** Maaac28- **Model type:** Causal Language Model (QLoRA fine-tuned)29- **Language(s):** English, C30- **License:** MIT31- **Finetuned from model:** codellama/CodeLLaMA-7b-Instruct-hf32 33## Uses34 35### Direct Use36 37This model is designed to:38- Generate Git diff patches for Linux kernel bug fixes39- Assist developers in fixing common kernel bugs40- Provide automated code review suggestions41- Help with learning Linux kernel development patterns42 43### Downstream Use44 45The model can be integrated into:46- Automated code review systems47- Development IDEs and editors48- Continuous integration pipelines49- Educational tools for kernel development50 51### Out-of-Scope Use52 53This model is not suitable for:54- Non-Linux kernel code55- Non-C programming languages56- Security-critical applications without human review57- Production systems without proper validation58 59## Bias, Risks, and Limitations60 61### Limitations62- Focused specifically on Linux kernel C code63- May not generalize to other codebases64- Generated fixes should be reviewed by human developers65- Limited to the patterns present in the training data66 67### Recommendations68 69Users should:70- Always review generated patches before applying71- Test fixes in a safe environment first72- Understand the context of the bug being fixed73- Use as a development aid, not a replacement for human expertise74 75## How to Get Started with the Model76 77```python78from transformers import AutoModelForCausalLM, AutoTokenizer79 80# Load the model81model = AutoModelForCausalLM.from_pretrained("Maaac/CodeLLaMA-Linux-BugFix")82tokenizer = AutoTokenizer.from_pretrained("Maaac/CodeLLaMA-Linux-BugFix")83 84# Example usage85prompt = """Given the following original C code:86int *ptr = kmalloc(sizeof(int), GFP_KERNEL);87if (!ptr) {88    return -ENOMEM;89}90// ... use ptr ...91// Missing kfree(ptr)92 93Instruction: Fix memory leak by adding proper cleanup94 95Return the diff that fixes it:96"""97 98inputs = tokenizer(prompt, return_tensors="pt")99outputs = model.generate(**inputs, max_new_tokens=256)100print(tokenizer.decode(outputs[0], skip_special_tokens=True))101```102 103## Training Details104 105### Training Data106 107- **Source:** Linux kernel Git repository108- **Size:** 100,000 bug-fix samples109- **Format:** JSONL with prompt-completion pairs110- **Extraction Method:** PyDriller analysis of commit history111 112### Training Procedure113 114#### Preprocessing115- Extracted bug-fix commits using keyword filtering116- Captured code context (10 lines before/after bug location)117- Converted to prompt-completion format for supervised learning118 119#### Training Hyperparameters120- **Base Model:** codellama/CodeLLaMA-7b-Instruct-hf121- **Method:** QLoRA with 4-bit quantization122- **LoRA Config:** r=64, alpha=16, dropout=0.1123- **Training:** 3 epochs, batch size 64, learning rate 2e-4124- **Hardware:** Optimized for H200 GPU with bfloat16125 126## Evaluation127 128### Testing Data129- Separate evaluation dataset with known bug-fix pairs130- Focused on common Linux kernel bug patterns131 132### Metrics133- **BLEU Score:** Measures translation quality of generated diffs134- **ROUGE Score:** Evaluates overlap between predicted and actual fixes135- **Human Evaluation:** Qualitative assessment of fix quality136 137### Results138The model demonstrates the ability to generate contextually appropriate Git diff patches for Linux kernel bugs, though results should be validated by human developers.139 140## Technical Specifications141 142### Model Architecture143- **Base:** CodeLLaMA-7B-Instruct (7 billion parameters)144- **Adapter:** LoRA layers for efficient fine-tuning145- **Output:** Generates Git diff format patches146 147### Compute Infrastructure148- **Hardware:** H200 GPU149- **Framework:** PyTorch with Transformers150- **Quantization:** 4-bit QLoRA for memory efficiency151 152## Citation153 154If you use this model in your research, please cite:155 156```bibtex157@misc{CodeLLaMA-Linux-BugFix,158  author = {Maaac},159  title = {CodeLLaMA-Linux-BugFix: A Fine-tuned Model for Linux Kernel Bug Fixing},160  year = {2024},161  url = {https://huggingface.co/Maaac/CodeLLaMA-Linux-BugFix}162}163```164 165## Model Card Authors166 167- **Author:** Maaac168- **Contact:** [Your contact information]169 170## Framework Versions171 172- PEFT 0.16.0173- Transformers 4.53.1174- PyTorch 2.7.1