Self-Host LLM Guide: Benchmarks & Numbers
Self-Host LLM Guide: Benchmarks & Numbers
Deploying your own large language model (LLM) locally can dramatically speed up workflows, enhance privacy, and reduce costs for repeated tasks. This guide offers a practical path to self-hosting with real-world benchmarks.
Getting Started
We'll use `mlx` and `llama.cpp` to run a 7B parameter model on an M2 Mac:
git clone https://github.com/ml-explore/mlx-examples.git cd mlx-examples/llms/llama pip install -e . python generate.py --model llama3-8b --prompt "Explain quantum computing in simple terms"
For a 7B model, this runs at ~120 tokens/second on an M2 Mac. With the Local-LLM Builder Bundle (Playbook + Prompt Pack), you get pre-tuned prompts and deployment instructions.
Performance Numbers
| Hardware | Model Size | Tokens/sec | Latency |
|----------|------------|------------|---------|
| M2 Mac | 7B | 120 | 8.3ms |
| RTX 4090 | 7B | 500 | 2ms |
| M2 Mac | 13B | 60 | 16.7ms |
These numbers are from running `llama.cpp` with `--n_threads=8`. The 13B model, while more capable, consumes more memory and runs slower than its 7B counterpart.
Deployment Steps
1. **Install dependencies**:
pip install -e .
2. **Download model weights**:
python download.py --model-id meta-llama/Llama-3.2-1B
3. **Run inference**:
python generate.py --model Llama-3.2-1B --prompt "What is the capital of France?"
The Playbook provides optimized `mlx` configurations, and the Prompt Pack includes tuned prompts for code generation, summarization, and more.
FAQ
Q: How does self-hosting compare to cloud APIs in terms of cost?
A: For frequent use (1000+ requests/day), local deployment can reduce costs by 80–90%. With a $0.03/token API fee, 10,000 tokens/day costs $300/month, while local hosting is ~$5/month for hardware and power.
Q: What's the memory requirement for 7B models?
A: A 7B model needs ~14GB RAM when quantized to 4-bit. On an M2 Mac, this leaves room for other apps, but a GPU with 24GB+ is better for heavy usage.
Q: Can I use this with existing workflows like LangChain or LlamaIndex?
A: Yes, both `mlx` and `llama.cpp` support standard API endpoints. You can wrap local models in Python services that integrate with your existing toolchains using simple HTTP calls.
Get it
Ready to deploy faster, privately, and at scale? Get the Local-LLM Builder Bundle — a playbook and prompt pack for building once, running anywhere. Save 21% today.