Mac
commited on
Commit
·
bf46039
1
Parent(s):
8046c68
Push full project updates including refactored code, data, and documentation
Browse files
train/output/qlora-codellama-bugfix/README.md
CHANGED
@@ -4,205 +4,171 @@ tags:
|
|
4 |
- linux
|
5 |
- bugfix
|
6 |
- codellama
|
|
|
|
|
|
|
7 |
model_type: causal-lm
|
8 |
library_name: transformers
|
9 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
|
12 |
-
#
|
13 |
|
14 |
-
|
15 |
|
|
|
16 |
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
- **Developed by:** [More Information Needed]
|
27 |
-
- **Funded by [optional]:** [More Information Needed]
|
28 |
-
- **Shared by [optional]:** [More Information Needed]
|
29 |
-
- **Model type:** [More Information Needed]
|
30 |
-
- **Language(s) (NLP):** [More Information Needed]
|
31 |
-
- **License:** [More Information Needed]
|
32 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
33 |
-
|
34 |
-
### Model Sources [optional]
|
35 |
-
|
36 |
-
<!-- Provide the basic links for the model. -->
|
37 |
-
|
38 |
-
- **Repository:** [More Information Needed]
|
39 |
-
- **Paper [optional]:** [More Information Needed]
|
40 |
-
- **Demo [optional]:** [More Information Needed]
|
41 |
|
42 |
## Uses
|
43 |
|
44 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
45 |
-
|
46 |
### Direct Use
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
|
52 |
-
### Downstream Use
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
|
58 |
### Out-of-Scope Use
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
|
64 |
## Bias, Risks, and Limitations
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
69 |
|
70 |
### Recommendations
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
|
76 |
## How to Get Started with the Model
|
77 |
|
78 |
-
|
|
|
79 |
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
|
86 |
-
|
|
|
87 |
|
88 |
-
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
|
92 |
-
|
93 |
|
94 |
-
|
|
|
|
|
|
|
95 |
|
96 |
-
|
97 |
|
|
|
|
|
|
|
|
|
98 |
|
99 |
#### Training Hyperparameters
|
100 |
-
|
101 |
-
- **
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
106 |
-
|
107 |
-
[More Information Needed]
|
108 |
|
109 |
## Evaluation
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
#### Testing Data
|
116 |
-
|
117 |
-
<!-- This should link to a Dataset Card if possible. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Factors
|
122 |
-
|
123 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
130 |
-
|
131 |
-
[More Information Needed]
|
132 |
|
133 |
### Results
|
|
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
#### Summary
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
## Model Examination [optional]
|
142 |
-
|
143 |
-
<!-- Relevant interpretability work for the model goes here -->
|
144 |
-
|
145 |
-
[More Information Needed]
|
146 |
-
|
147 |
-
## Environmental Impact
|
148 |
-
|
149 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
150 |
-
|
151 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
152 |
-
|
153 |
-
- **Hardware Type:** [More Information Needed]
|
154 |
-
- **Hours used:** [More Information Needed]
|
155 |
-
- **Cloud Provider:** [More Information Needed]
|
156 |
-
- **Compute Region:** [More Information Needed]
|
157 |
-
- **Carbon Emitted:** [More Information Needed]
|
158 |
-
|
159 |
-
## Technical Specifications [optional]
|
160 |
-
|
161 |
-
### Model Architecture and Objective
|
162 |
|
163 |
-
|
|
|
|
|
|
|
164 |
|
165 |
### Compute Infrastructure
|
|
|
|
|
|
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
#### Hardware
|
170 |
-
|
171 |
-
[More Information Needed]
|
172 |
-
|
173 |
-
#### Software
|
174 |
-
|
175 |
-
[More Information Needed]
|
176 |
-
|
177 |
-
## Citation [optional]
|
178 |
-
|
179 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
180 |
-
|
181 |
-
**BibTeX:**
|
182 |
-
|
183 |
-
[More Information Needed]
|
184 |
-
|
185 |
-
**APA:**
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## Glossary [optional]
|
190 |
-
|
191 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
192 |
-
|
193 |
-
[More Information Needed]
|
194 |
-
|
195 |
-
## More Information [optional]
|
196 |
|
197 |
-
|
198 |
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
-
|
202 |
|
203 |
-
|
|
|
204 |
|
205 |
-
|
206 |
-
### Framework versions
|
207 |
|
208 |
-
- PEFT 0.16.0
|
|
|
|
|
|
4 |
- linux
|
5 |
- bugfix
|
6 |
- codellama
|
7 |
+
- qlora
|
8 |
+
- transformers
|
9 |
+
- causal-lm
|
10 |
model_type: causal-lm
|
11 |
library_name: transformers
|
12 |
pipeline_tag: text-generation
|
13 |
+
base_model: codellama/CodeLLaMA-7b-Instruct-hf
|
14 |
+
language:
|
15 |
+
- en
|
16 |
+
- c
|
17 |
---
|
18 |
|
19 |
+
# CodeLLaMA-Linux-BugFix
|
20 |
|
21 |
+
A 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 Description
|
24 |
|
25 |
+
This 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:** Maaac
|
28 |
+
- **Model type:** Causal Language Model (QLoRA fine-tuned)
|
29 |
+
- **Language(s):** English, C
|
30 |
+
- **License:** MIT
|
31 |
+
- **Finetuned from model:** codellama/CodeLLaMA-7b-Instruct-hf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
## Uses
|
34 |
|
|
|
|
|
35 |
### Direct Use
|
36 |
|
37 |
+
This model is designed to:
|
38 |
+
- Generate Git diff patches for Linux kernel bug fixes
|
39 |
+
- Assist developers in fixing common kernel bugs
|
40 |
+
- Provide automated code review suggestions
|
41 |
+
- Help with learning Linux kernel development patterns
|
42 |
|
43 |
+
### Downstream Use
|
44 |
|
45 |
+
The model can be integrated into:
|
46 |
+
- Automated code review systems
|
47 |
+
- Development IDEs and editors
|
48 |
+
- Continuous integration pipelines
|
49 |
+
- Educational tools for kernel development
|
50 |
|
51 |
### Out-of-Scope Use
|
52 |
|
53 |
+
This model is not suitable for:
|
54 |
+
- Non-Linux kernel code
|
55 |
+
- Non-C programming languages
|
56 |
+
- Security-critical applications without human review
|
57 |
+
- Production systems without proper validation
|
58 |
|
59 |
## Bias, Risks, and Limitations
|
60 |
|
61 |
+
### Limitations
|
62 |
+
- Focused specifically on Linux kernel C code
|
63 |
+
- May not generalize to other codebases
|
64 |
+
- Generated fixes should be reviewed by human developers
|
65 |
+
- Limited to the patterns present in the training data
|
66 |
|
67 |
### Recommendations
|
68 |
|
69 |
+
Users should:
|
70 |
+
- Always review generated patches before applying
|
71 |
+
- Test fixes in a safe environment first
|
72 |
+
- Understand the context of the bug being fixed
|
73 |
+
- Use as a development aid, not a replacement for human expertise
|
74 |
|
75 |
## How to Get Started with the Model
|
76 |
|
77 |
+
```python
|
78 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
79 |
|
80 |
+
# Load the model
|
81 |
+
model = AutoModelForCausalLM.from_pretrained("Maaac/CodeLLaMA-Linux-BugFix")
|
82 |
+
tokenizer = AutoTokenizer.from_pretrained("Maaac/CodeLLaMA-Linux-BugFix")
|
83 |
|
84 |
+
# Example usage
|
85 |
+
prompt = """Given the following original C code:
|
86 |
+
int *ptr = kmalloc(sizeof(int), GFP_KERNEL);
|
87 |
+
if (!ptr) {
|
88 |
+
return -ENOMEM;
|
89 |
+
}
|
90 |
+
// ... use ptr ...
|
91 |
+
// Missing kfree(ptr)
|
92 |
|
93 |
+
Instruction: Fix memory leak by adding proper cleanup
|
94 |
|
95 |
+
Return the diff that fixes it:
|
96 |
+
"""
|
97 |
|
98 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
99 |
+
outputs = model.generate(**inputs, max_new_tokens=256)
|
100 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
101 |
+
```
|
102 |
|
103 |
+
## Training Details
|
104 |
|
105 |
+
### Training Data
|
106 |
|
107 |
+
- **Source:** Linux kernel Git repository
|
108 |
+
- **Size:** 100,000 bug-fix samples
|
109 |
+
- **Format:** JSONL with prompt-completion pairs
|
110 |
+
- **Extraction Method:** PyDriller analysis of commit history
|
111 |
|
112 |
+
### Training Procedure
|
113 |
|
114 |
+
#### Preprocessing
|
115 |
+
- Extracted bug-fix commits using keyword filtering
|
116 |
+
- Captured code context (10 lines before/after bug location)
|
117 |
+
- Converted to prompt-completion format for supervised learning
|
118 |
|
119 |
#### Training Hyperparameters
|
120 |
+
- **Base Model:** codellama/CodeLLaMA-7b-Instruct-hf
|
121 |
+
- **Method:** QLoRA with 4-bit quantization
|
122 |
+
- **LoRA Config:** r=64, alpha=16, dropout=0.1
|
123 |
+
- **Training:** 3 epochs, batch size 64, learning rate 2e-4
|
124 |
+
- **Hardware:** Optimized for H200 GPU with bfloat16
|
|
|
|
|
|
|
125 |
|
126 |
## Evaluation
|
127 |
|
128 |
+
### Testing Data
|
129 |
+
- Separate evaluation dataset with known bug-fix pairs
|
130 |
+
- Focused on common Linux kernel bug patterns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
+
### Metrics
|
133 |
+
- **BLEU Score:** Measures translation quality of generated diffs
|
134 |
+
- **ROUGE Score:** Evaluates overlap between predicted and actual fixes
|
135 |
+
- **Human Evaluation:** Qualitative assessment of fix quality
|
|
|
|
|
|
|
136 |
|
137 |
### Results
|
138 |
+
The 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 Specifications
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
+
### Model Architecture
|
143 |
+
- **Base:** CodeLLaMA-7B-Instruct (7 billion parameters)
|
144 |
+
- **Adapter:** LoRA layers for efficient fine-tuning
|
145 |
+
- **Output:** Generates Git diff format patches
|
146 |
|
147 |
### Compute Infrastructure
|
148 |
+
- **Hardware:** H200 GPU
|
149 |
+
- **Framework:** PyTorch with Transformers
|
150 |
+
- **Quantization:** 4-bit QLoRA for memory efficiency
|
151 |
|
152 |
+
## Citation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
+
If you use this model in your research, please cite:
|
155 |
|
156 |
+
```bibtex
|
157 |
+
@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 Authors
|
166 |
|
167 |
+
- **Author:** Maaac
|
168 |
+
- **Contact:** [Your contact information]
|
169 |
|
170 |
+
## Framework Versions
|
|
|
171 |
|
172 |
+
- PEFT 0.16.0
|
173 |
+
- Transformers 4.53.1
|
174 |
+
- PyTorch 2.7.1
|