|
|
--- |
|
|
language: |
|
|
- en |
|
|
license: apache-2.0 |
|
|
base_model: codellama/CodeLlama-7b-hf |
|
|
tags: |
|
|
- code |
|
|
- python |
|
|
- codellama |
|
|
- qlora |
|
|
- unsloth |
|
|
datasets: |
|
|
- custom |
|
|
pipeline_tag: text-generation |
|
|
--- |
|
|
|
|
|
# CodeLlama 7B Python AI Assistant (QLoRA) |
|
|
|
|
|
Fine-tuned CodeLlama-7B model specialized for Python programming assistance using QLoRA (Quantized Low-Rank Adaptation). |
|
|
|
|
|
## Model Description |
|
|
|
|
|
- **Base Model:** [codellama/CodeLlama-7b-hf](https://huggingface.co/codellama/CodeLlama-7b-hf) |
|
|
- **Fine-tuning Method:** QLoRA (4-bit quantization with LoRA adapters) |
|
|
- **Framework:** Unsloth + Transformers |
|
|
- **Training Data:** Custom Python programming examples |
|
|
|
|
|
## Usage |
|
|
|
|
|
This repository contains **LoRA adapters only**. To use, merge the adapters with the base model. |
|
|
|
|
|
from unsloth import FastLanguageModel |
|
|
|
|
|
model, tokenizer = FastLanguageModel.from_pretrained( |
|
|
model_name="pranav-pvnn/codellama-7b-python-ai-assistant", |
|
|
max_seq_length=2048, |
|
|
load_in_4bit=True, |
|
|
) |
|
|
|
|
|
prompt = "### Instruction:\nWrite a Python function to calculate factorial.\n### Response:\n" |
|
|
inputs = tokenizer(prompt, return_tensors="pt").to("cuda") |
|
|
outputs = model.generate(**inputs, max_new_tokens=256) |
|
|
print(tokenizer.decode(outputs, skip_special_tokens=True)) |
|
|
|
|
|
## Training Details |
|
|
|
|
|
- **Quantization:** 4-bit |
|
|
- **LoRA Rank:** 64 |
|
|
- **Learning Rate:** 2e-4 |
|
|
- **Epochs:** 4 |
|
|
- **Max Seq Length:** 2048 |
|
|
- **GPU:** NVIDIA Tesla T4 |
|
|
|
|
|
## Limitations |
|
|
|
|
|
- Requires base model for inference. |
|
|
- Optimized for Python code generation. |
|
|
- Trained on custom dataset (~2,000 examples). |
|
|
|
|
|
## Citation |
|
|
|
|
|
@misc{codellama-7b-python-assistant, |
|
|
author = {pranav-pvnn}, |
|
|
title = {CodeLlama 7B Python AI Assistant}, |
|
|
year = {2025}, |
|
|
publisher = {HuggingFace}, |
|
|
howpublished = {\url{https://huggingface.co/pranav-pvnn/codellama-7b-python-ai-assistant}} |
|
|
} |
|
|
|
|
|
## Acknowledgements |
|
|
|
|
|
- Base Model: [Meta's CodeLlama](https://huggingface.co/codellama/CodeLlama-7b-hf) |
|
|
- Training Framework: [Unsloth](https://github.com/unslothai/unsloth) |
|
|
- Quantization: [bitsandbytes](https://github.com/TimDettmers/bitsandbytes) |
|
|
- LoRA: [PEFT](https://github.com/huggingface/peft) |