Instructions to use Omarrran/llama3_2_3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Adapters
How to use Omarrran/llama3_2_3B with Adapters:
from adapters import AutoAdapterModel model = AutoAdapterModel.from_pretrained("undefined") model.load_adapter("Omarrran/llama3_2_3B", set_active=True) - llama-cpp-python
How to use Omarrran/llama3_2_3B with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Omarrran/llama3_2_3B", filename="unsloth.Q4_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use Omarrran/llama3_2_3B with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Omarrran/llama3_2_3B:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Omarrran/llama3_2_3B:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Omarrran/llama3_2_3B:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Omarrran/llama3_2_3B:Q4_K_M
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 Omarrran/llama3_2_3B:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Omarrran/llama3_2_3B:Q4_K_M
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 Omarrran/llama3_2_3B:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Omarrran/llama3_2_3B:Q4_K_M
Use Docker
docker model run hf.co/Omarrran/llama3_2_3B:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Omarrran/llama3_2_3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Omarrran/llama3_2_3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Omarrran/llama3_2_3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Omarrran/llama3_2_3B:Q4_K_M
- Ollama
How to use Omarrran/llama3_2_3B with Ollama:
ollama run hf.co/Omarrran/llama3_2_3B:Q4_K_M
- Unsloth Studio new
How to use Omarrran/llama3_2_3B 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 Omarrran/llama3_2_3B 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 Omarrran/llama3_2_3B to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Omarrran/llama3_2_3B to start chatting
- Pi new
How to use Omarrran/llama3_2_3B with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Omarrran/llama3_2_3B:Q4_K_M
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": "Omarrran/llama3_2_3B:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Omarrran/llama3_2_3B with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Omarrran/llama3_2_3B:Q4_K_M
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 Omarrran/llama3_2_3B:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use Omarrran/llama3_2_3B with Docker Model Runner:
docker model run hf.co/Omarrran/llama3_2_3B:Q4_K_M
- Lemonade
How to use Omarrran/llama3_2_3B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Omarrran/llama3_2_3B:Q4_K_M
Run and chat with the model
lemonade run user.llama3_2_3B-Q4_K_M
List all available models
lemonade list
Install from WinGet (Windows)
winget install llama.cpp
# Start a local OpenAI-compatible server with a web UI:
llama-server -hf Omarrran/llama3_2_3B:Q4_K_M# Run inference directly in the terminal:
llama-cli -hf Omarrran/llama3_2_3B:Q4_K_MUse 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 Omarrran/llama3_2_3B:Q4_K_M# Run inference directly in the terminal:
./llama-cli -hf Omarrran/llama3_2_3B:Q4_K_MBuild 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 Omarrran/llama3_2_3B:Q4_K_M# Run inference directly in the terminal:
./build/bin/llama-cli -hf Omarrran/llama3_2_3B:Q4_K_MUse Docker
docker model run hf.co/Omarrran/llama3_2_3B:Q4_K_MLlama-3.2-3B-
This repository contains code to fine-tune the Llama-3.2-3B-Instruct model using Unsloth for efficient training. The model is optimized for conversational tasks and supports 4-bit quantization, LoRA adapters, and GGUF export.
Model Overview
- Base Model:
Llama-3.2-3B-Instruct - Fine-Tuning Dataset: FineTome-100k (converted to Llama-3.1 chat format)
- Features:
- 4-bit quantization for reduced memory usage
- LoRA adapters (1-10% parameter updates)
- Sequence length: 2048 (RoPE scaling supported)
- Optimized for Tesla T4 GPUs
🚀 Quick Start
Load this model as:
from llama_cpp import Llama
from huggingface_hub import hf_hub_download
# Download model from Hugging Face Hub
model_path = hf_hub_download(
repo_id="Omarrran/llama3_2_3B",
filename="unsloth.Q4_K_M.gguf",
cache_dir="./models" # Save to models directory
)
# Initialize LLM with proper configuration
llm = Llama(
model_path=model_path,
n_ctx=2048, # Context window size
n_threads=8, # CPU threads to use
n_gpu_layers=35 # GPU layers for acceleration (if available)
)
# Create a generation function
def generate_text(prompt, max_tokens=200):
output = llm.create_chat_completion(
messages=[{"role": "user", "content": prompt}],
max_tokens=max_tokens,
temperature=0.7,
stop=["\n"]
)
return output['choices'][0]['message']['content']
# Example usage
if __name__ == "__main__":
prompt = "Explain quantum computing in simple terms:"
response = generate_text(prompt)
print(f"Prompt: {prompt}\nResponse: {response}")
Installation
pip install unsloth
pip install --force-reinstall --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git
Load Model
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/Llama-3.2-3B-Instruct",
max_seq_length=2048,
dtype=None, # Auto-detect (bf16 for Ampere+ GPUs)
load_in_4bit=True,
)
Run Inference
messages = [{"role": "user", "content": "Continue the Fibonacci sequence: 1, 1, 2, 3, 5, 8,"}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
outputs = model.generate(
inputs,
max_new_tokens=64,
temperature=1.5,
min_p=0.1,
)
print(tokenizer.decode(outputs[0]))
🛠️ Training
Data Preparation
The dataset is standardized to Llama-3.1 chat format:
from unsloth.chat_templates import get_chat_template, standardize_sharegpt
tokenizer = get_chat_template(tokenizer, "llama-3.1") # Adds system prompts
dataset = load_dataset("mlabonne/FineTome-100k", split="train")
dataset = standardize_sharegpt(dataset) # Converts to role/content format
LoRA Configuration
model = FastLanguageModel.get_peft_model(
model,
r=16, # LoRA rank
target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
lora_alpha=16,
use_gradient_checkpointing="unsloth", # 30% less VRAM
)
Training Arguments
from trl import SFTTrainer
trainer = SFTTrainer(
model=model,
train_dataset=dataset,
dataset_text_field="text",
max_seq_length=2048,
args=TrainingArguments(
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
learning_rate=2e-4,
max_steps=60, # Demo: set to 60 steps. For full training, use num_train_epochs=1
fp16=not is_bfloat16_supported(),
bf16=is_bfloat16_supported(),
optim="adamw_8bit",
),
)
💾 Saving & Deployment
Save LoRA Adapters
model.save_pretrained("llama3_2_3B")
tokenizer.save_pretrained("llama3_2_3B")
Export to GGUF (for llama.cpp)
model.save_pretrained_gguf(
"model",
tokenizer,
quantization_method="q4_k_m", # Recommended quantization
)
Upload to Hugging Face Hub
model.push_to_hub_gguf(
"your-username/llama3_2_3B",
tokenizer,
quantization_method=["q4_k_m", "q8_0"], # Multiple formats
token="hf_your_token_here",
)
📊 Performance
| Metric | Value |
|---|---|
| Training Time (60 steps) | ~7.5 minutes |
| Peak VRAM Usage | 6.5 GB |
| Quantized Size (Q4_K_M) | ~1.9 GB |
📜 Notes
- Knowledge Cutoff: December 2023 (updated to July 2024 via fine-tuning)
- Use
temperature=1.5andmin_p=0.1for best results (reference) - For 2x faster inference, enable
FastLanguageModel.for_inference(model)
🤝 Contributing
- Report issues
- Star the repo if you find this useful! ⭐
License
Apache 2.0. See [LICENSE on top of Model Card]
Key Fixes Added:
- Model Download: Uses
huggingface_hubto properly download the GGUF file - Correct Initialization: Uses
Llama()constructor instead of non-existentfrom_pretrained() - GPU Support: Added
n_gpu_layersfor GPU acceleration (set to 0 if using CPU-only) - Chat Completion: Uses the recommended
create_chat_completionmethod
Requirements:
pip install llama-cpp-python huggingface_hub
For Better Performance:
- Set
n_gpu_layersbased on your VRAM (40+ for large models) - Add
verbose=Falseto constructor to suppress logs - Use
llama.cppoptimizations:Llama( model_path=model_path, n_batch=512, use_mmap=True, use_mlock=True )
Common Errors to Handle:
try:
llm = Llama(model_path=model_path)
except Exception as e:
print(f"Error loading model: {str(e)}")
# Check if file exists: os.path.exists(model_path)
# Verify file integrity: check file size matches original
- Downloads last month
- 24
4-bit
Install from brew
# Start a local OpenAI-compatible server with a web UI: llama-server -hf Omarrran/llama3_2_3B:Q4_K_M# Run inference directly in the terminal: llama-cli -hf Omarrran/llama3_2_3B:Q4_K_M