Instructions to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-3B-Instruct") model = PeftModel.from_pretrained(base_model, "demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation") - llama-cpp-python
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation", filename="Llama-3.2-3B-Instruct-PEFT-code-generation.Q8_0.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0 # Run inference directly in the terminal: llama-cli -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0 # Run inference directly in the terminal: llama-cli -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Use Docker
docker model run hf.co/demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
- LM Studio
- Jan
- Ollama
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with Ollama:
ollama run hf.co/demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
- Unsloth Studio
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation to start chatting
- Pi
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Run Hermes
hermes
- Docker Model Runner
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with Docker Model Runner:
docker model run hf.co/demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
- Lemonade
How to use demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation:Q8_0
Run and chat with the model
lemonade run user.Llama-3.2-3B-Instruct-PEFT-code-generation-Q8_0
List all available models
lemonade list
llm.create_chat_completion(
messages = "No input example has been defined for this model task."
)See axolotl config
axolotl version: 0.10.0
base_model: meta-llama/Llama-3.2-3B-Instruct
load_in_8bit: true
load_in_4bit: false
datasets:
- path: ./data/train_openai_response_transformed.jsonl
type: chat_template
field_messages: messages
message_property_mappings:
role: role
content: content
val_file: ./data/val_openai_response_transformed.jsonl
val_set_size: 0.0
output_dir: ./outputs/cf-llm-finetune-llama-3.2-3b-lora
adapter: lora
lora_model_dir:
sequence_len: 4096
sample_packing: false
eval_sample_packing: true
pad_to_sequence_len: true
lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_linear: true
wandb_project:
wandb_entity:
wandb_watch:
wandb_name:
wandb_log_model:
gradient_accumulation_steps: 4
micro_batch_size: 2
num_epochs: 4
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002
bf16: auto
tf32: false
gradient_checkpointing: true
resume_from_checkpoint:
logging_steps: 1
flash_attention: false
warmup_steps: 10
evals_per_epoch: 4
saves_per_epoch: 1
weight_decay: 0.0
special_tokens:
pad_token: "<|end_of_text|>"
Llama-3.2-3B-Instruct-PEFT-code-generation
This model is a fine tuned meta-llama/Llama-3.2-3B-Instruct on a synthetic dataset of C++ → Python code translations from Codeforces.
📦 GitHub repo: DemoVersion/cf-llm-finetune
📑 Dataset Creation DATASET.md
📑 Training TRAIN.md
📚 Dataset on Hugging Face: demoversion/cf-cpp-to-python-code-generation
For dataset generation, training, and inference check the Github repo.
📚 Main medium article: Toward fine-tuning Llama 3.2 using PEFT for Code Generation
📚 Medium article for inference with GGUF format: How to inference with GGUF format
Model description
A lightweight LLaMA 3.2 model fine-tuned for competitive programming code translation, from ICPC-style C++ to Python using LoRA adapters.
Intended uses & limitations
Use for:
- Translating competitive programming C++ solutions to Python
- Code understanding in educational or automation tools
Limitations:
- Not general-purpose code translation
- Python outputs are synthetically generated using GPT-4.1
- Focused only on ICPC-style problems
Training and evaluation data
Training and Evaluation data:
🧾 demoversion/cf-cpp-to-python-code-generation
Built from:
C++ submissions were filtered and paired with GPT-4.1-generated Python translations. Dataset split: 1,400 train / 300 val / 300 test. To underestand how the dataset was created check DATASET.md
Training procedure
- Adapter: LoRA (
r=32,alpha=16,dropout=0.05) - Optimizer:
adamw_bnb_8bit - LR:
2e-4, scheduler:cosine - Batch size: 2 × 4 (grad accumulation) = total 8
- Training steps: 688
Full config: TRAIN.md
Framework versions
- PEFT 0.15.2
- Transformers 4.52.3
- PyTorch 2.6.0+cu124
- Datasets 3.6.0
- Tokenizers 0.21.2
- Downloads last month
- 8
8-bit
Model tree for demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation
Base model
meta-llama/Llama-3.2-3B-Instruct
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="demoversion/Llama-3.2-3B-Instruct-PEFT-code-generation", filename="Llama-3.2-3B-Instruct-PEFT-code-generation.Q8_0.gguf", )