llama.cpp CLI Cheatsheet - llama-cli Local Inference Full Reference
llama.cpp is a lightweight inference engine in C/C++ that runs GGUF quantized models on CPU, Apple Silicon, and various GPUs. llama-cli is its built-in terminal chat frontend for quick local verification and offline inference. This sheet covers model loading, sampling, context, and performance flags so you can start a chat on a laptop.
Basic Inference 8
llama-cli -m model.gguf -p "hello"llama-cli -m model.gguf --interactivellama-cli -m model.gguf -ngl 35llama-cli -m model.gguf -c 4096llama-cli -m model.gguf -t 8llama-cli -m model.gguf --temp 0.7llama-cli -m model.gguf --top-p 0.9llama-cli -m model.gguf --colorSampling and Context 6
llama-cli -m model.gguf --repeat-penalty 1.1llama-cli -m model.gguf -s 42llama-cli -m model.gguf --system "you are a helper"llama-cli -m model.gguf -cnvllama-cli -m model.gguf -f prompt.txtllama-cli -m model.gguf --flash-attnPerformance and Advanced 6
llama-cli -m model.gguf -ngl 99llama-cli -m model.gguf -t 16llama-cli -m model.gguf -c 8192llama-cli -m model.gguf --mlockllama-cli -m model.gguf -b 512llama-cli --helpTips
- `-ngl` is the key performance knob: set it high (e.g. 99) to offload to GPU, or 0 for pure CPU.
- A larger -c costs more VRAM; set it to the model real length instead of maxing it out.
- GGUF quantized models with -ngl plus --flash-attn give the best experience on Apple Silicon or CUDA.
FAQ
How is llama-cli different from ollama?
llama-cli is the native llama.cpp inference frontend with fine-grained flags; ollama is a higher-level model manager and server with less tuning surface.
What if the GPU is not used?
Set -ngl to offload layers and ensure your build includes the backend (CUDA, Metal, or Vulkan); for pure CPU use -ngl 0.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Sep 10, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us