Exporting to GGUF / Ollama and serving in Agent
Merge adapter, quantize to GGUF, and register with Ollama
After benchmarking passes, merge your LoRA adapter into the base weights and quantize to GGUF (Q4_K_M for maximum speed/RAM savings, Q8_0 for near-lossless precision). praisonai train serve packages and registers the model with Ollama in one step.
Example
# Export merged GGUF and register as a local Ollama model
praisonai train serve --checkpoint ./checkpoints/support-router --name my-support-router --quant Q4_K_M
# Smoke-test directly in Ollama
ollama run my-support-router "Charged twice on invoice 88"Example explained
- –quant Q4_K_M — 4-bit quantization cuts model RAM by ~70% with minimal accuracy drop on 3B–8B models.
- –name my-support-router — Creates a local Ollama model tag ready for any PraisonAI Agent.
Plug your private model straight into a PraisonAI Agent
Once served via Ollama, your fine-tuned model works identically to GPT or Claude — just pass model='ollama/my-support-router' with zero external API keys or data leaving your network.
Example
from pydantic import BaseModel
from praisonai import Agent
class TicketClass(BaseModel):
queue: str
priority: str
# Once exported to Ollama, swap model='ollama/my-support-router':
router = Agent(instructions='Classify the support ticket into queue and priority.')
res = router.chat('Charged twice on invoice 88', output_pydantic=TicketClass)
print(res.model_dump())Example explained
- model='ollama/my-support-router' — Switches any existing PraisonAI Agent to your private fine-tuned model with a 1-line change.
- PrivateRouter — Demonstrates the exact JSON classification contract your tuned model returns.
Common pitfall: forgetting to re-benchmark after quantization
Always re-run your validation suite on the quantized Q4_K_M GGUF artifact — rare JSON edge cases occasionally degrade at 4-bit and recover cleanly at Q8_0.
Reference: documentation