|
|
--- |
|
|
license: apache-2.0 |
|
|
language: c++ |
|
|
tags: |
|
|
- code-generation |
|
|
- codellama |
|
|
- peft |
|
|
- unit-tests |
|
|
- causal-lm |
|
|
- text-generation |
|
|
base_model: codellama/CodeLlama-7b-hf |
|
|
model_type: llama |
|
|
pipeline_tag: text-generation |
|
|
--- |
|
|
|
|
|
# 🧪 CodeLLaMA Unit Test Generator (Merged Model) |
|
|
|
|
|
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. |
|
|
|
|
|
It specializes in generating **comprehensive unit tests** for C/C++ code using frameworks like **GoogleTest** or **CppUTest**, focusing on: |
|
|
- Edge cases |
|
|
- Boundary conditions |
|
|
- Exception handling |
|
|
- MISRA C compliance (if applicable) |
|
|
|
|
|
--- |
|
|
|
|
|
## 📌 Example Usage |
|
|
|
|
|
```python |
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
import torch |
|
|
|
|
|
model = AutoModelForCausalLM.from_pretrained("Utkarsh524/codellama_utests_full") |
|
|
tokenizer = AutoTokenizer.from_pretrained("Utkarsh524/codellama_utests_full") |
|
|
|
|
|
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" |
|
|
|
|
|
inputs = tokenizer(prompt, return_tensors="pt").to("cuda") |
|
|
outputs = model.generate(**inputs, max_new_tokens=512) |
|
|
print(tokenizer.decode(outputs[0], skip_special_tokens=True)) |
|
|
|