Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language: c++
|
| 4 |
+
tags:
|
| 5 |
+
- code-generation
|
| 6 |
+
- codellama
|
| 7 |
+
- peft
|
| 8 |
+
- unit-tests
|
| 9 |
+
- causal-lm
|
| 10 |
+
- text-generation
|
| 11 |
+
base_model: codellama/CodeLlama-7b-hf
|
| 12 |
+
model_type: llama
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# 🧪 CodeLLaMA Unit Test Generator (Merged Model)
|
| 17 |
+
|
| 18 |
+
This is a merged model that combines [`codellama/CodeLlama-7b-hf`](https://huggingface.co/codellama/CodeLlama-7b-hf) with LoRA fine-tuning trained on a dataset of embedded C/C++ functions and corresponding unit tests.
|
| 19 |
+
|
| 20 |
+
It specializes in generating **comprehensive unit tests** for C/C++ code using frameworks like **GoogleTest** or **CppUTest**, focusing on:
|
| 21 |
+
- Edge cases
|
| 22 |
+
- Boundary conditions
|
| 23 |
+
- Exception handling
|
| 24 |
+
- MISRA C compliance (if applicable)
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
## 📌 Example Usage
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 32 |
+
import torch
|
| 33 |
+
|
| 34 |
+
model = AutoModelForCausalLM.from_pretrained("Utkarsh524/codellama_utests_full")
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained("Utkarsh524/codellama_utests_full")
|
| 36 |
+
|
| 37 |
+
prompt = "<|system|>\nGenerate comprehensive unit tests for C/C++ code. Cover all edge cases, boundary conditions, and error scenarios.\nOutput Constraints:\n1. ONLY include test code (no explanations, headers, or main functions)\n2. Start directly with TEST(...)\n3. End after last test case\n4. Never include framework boilerplate\n<|user|>\nCreate tests for:\nint add(int a, int b) { return a + b; }\n<|assistant|>\n"
|
| 38 |
+
|
| 39 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 40 |
+
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 41 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|