Run ollama run llama3.1:8b --verbose, send a prompt, and read eval rate in the timing summary after the reply. That is the model’s generation speed in tokens per second. In an open Ollama terminal chat, type /set verbose before your next prompt.
How to show Ollama tokens per second
Start a terminal chat with timings enabled, or pass a prompt on the same command line for a single reply. Use --verbose for timings. The top-level ollama -v command displays the version. Ollama run command
ollama run llama3.1:8b --verbose "What limits the speed of a local language model?"
ollama run llama3.1:8b --verbose
In an existing terminal chat, enter /set verbose at the Ollama prompt. The session prints Set 'verbose' mode. and shows timings after the next reply. Enter /set quiet to turn them off. Ollama interactive commands
Ollama prints its timing summary to standard error. These lines separate generation, prompt processing and loading. Ollama timing summary
| Timing line | What to compare |
|---|---|
eval rate | Output tokens generated per second during decoding. |
prompt eval rate | Uncached input tokens processed per second during prefill. |
prompt eval cached | Prompt tokens reused from the cache. This line appears when the count is positive. |
load duration | Time spent loading the model. Track it separately when comparing cold starts. |
Calculate tokens per second from the Ollama API
Both /api/chat and /api/generate return eval_count in tokens and eval_duration in nanoseconds. Divide the token count by the duration in seconds to calculate the generation rate. Chat API · Generate API
generation tokens/s = eval_count × 1,000,000,000 ÷ eval_duration
The Generate reference example gives 18 tokens in 52,479,709 nanoseconds, which works out to about 343.0 tokens/s for that example. Use eval_duration for decode speed and keep total_duration as a separate request timing.
With Ollama running locally, paste this into a Bash or Zsh terminal with curl and Python 3. The "stream": false option returns a single JSON response. Keep the function in that terminal for the examples below.
ollama_rate() {
python3 -c '
import json
import sys
try:
reply = json.load(sys.stdin)
except ValueError:
sys.exit("No JSON response from Ollama.")
count = reply.get("eval_count")
duration = reply.get("eval_duration")
if not count or not duration:
sys.exit(reply.get("error") or "No generation timing in the response.")
print(f"{count * 1_000_000_000 / duration:.2f} tokens/s")
'
}
curl http://localhost:11434/api/chat -d '{
"model": "llama3.1:8b",
"messages": [{"role": "user", "content": "Explain memory bandwidth in one paragraph."}],
"stream": false
}' | ollama_rate
For a single text prompt, send prompt in place of messages and use the same calculation.
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1:8b",
"prompt": "Explain memory bandwidth in one paragraph.",
"stream": false
}' | ollama_rate
Read timings from a streamed reply
Ollama streams newline-delimited JSON by default for these endpoints. To calculate generation speed, read the timing fields from the completed response object with "done": true. Generate API · Ollama streaming guide · Ollama API handlers
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1:8b",
"prompt": "Explain memory bandwidth in one paragraph."
}' | python3 -c '
import json
import sys
for line in sys.stdin:
if not line.strip():
continue
event = json.loads(line)
if event.get("error"):
sys.exit(event["error"])
if event.get("done") is True:
print(line, end="")
break
' | ollama_rate
See Ollama API examples for more ways to handle streamed responses.
What sets Ollama generation speed
Prefill processes the input prompt and can work on many tokens in parallel. Ordinary autoregressive decoding produces tokens sequentially and can be limited by how fast the hardware reads model weights and attention data from memory. All About Transformer Inference
Estimate a bandwidth ceiling
For one request with a dense model that fits entirely on the GPU, divide peak memory bandwidth by the weight bytes read per token for a rough, weights-only ceiling. A fuller estimate accounts for traffic from the key-value (KV) cache as well. Theoretical LLM throughput
Use eval rate to find the speed on your setup.
Check quantization, context and GPU placement
- Model size and quantization. More weight bytes to read lower the bandwidth ceiling. For the same Llama 3.1 8B model, Ollama lists a 4.9 GB Q4_K_M download and an 8.5 GB Q8_0 download. Q4_K_M model listing · Q8_0 model listing
- Context. A larger context allocation needs more memory. For standard full attention, a longer sequence also gives decoding more cached keys and values to read. Ollama context length · Transformer inference
- GPU placement. Run
ollama pswhile the model is loaded. UnderPROCESSOR,100% GPUindicates full GPU placement. A CPU/GPU split means some of the model is in system memory. Ollama recommends full GPU placement for performance. CheckCONTEXTfor the allocated context. Ollama local FAQ · Ollama context length
If you expected full GPU placement, see Ollama not using GPU. Use the VRAM calculator to estimate capacity for a model and its context before using bandwidth to compare hardware.
Compare runs on the same workload
Keep the model tag, prompt, context and generation settings fixed while changing one thing at a time. Fix num_ctx, num_predict, temperature and seed in options, and set keep_alive to keep the model loaded between runs. Modelfile reference · Generate API
This example sends one warm-up request and then prints the generation rate from each of five requests. Use the ollama_rate function above and substitute a prompt representative of the workload you want to compare.
(
payload='{
"model": "llama3.1:8b",
"prompt": "Explain five ways to reduce the memory used by a local language model.",
"stream": false,
"keep_alive": "10m",
"options": {"num_ctx": 4096, "num_predict": 128, "temperature": 0, "seed": 42}
}'
generate_rate() {
reply=$(curl http://localhost:11434/api/generate -d "$payload") || return 1
printf '%s\n' "$reply" | ollama_rate
}
generate_rate >/dev/null || exit 1
for run in 1 2 3 4 5; do
rate=$(generate_rate) || exit 1
printf 'Run %s: %s\n' "$run" "$rate"
done
)
Repeated prompts can reuse cached input, so use this loop for warm decode comparisons. To include startup or fresh prompt processing in a comparison, record load duration and prompt eval duration separately and check prompt eval cached. Transformer inference on prefix caching
When comparing published rates, match the model and quantization, prompt length, allocated context, GPU placement and whether the rate measures decode or prefill. For batched serving, compare aggregate throughput across requests. More on multi-user serving is covered at llmops.report.
The commands and timing fields are described in Ollama’s documentation and v0.40.16 source. No hands-on testing was performed for this guide.