Update
Nov 12, 2025
tracked by
Updatify
Logprobs
Ollama’s API and OpenAI-compatible API now support log probabilities. Log probabilities of output tokens indicate the likelihood of each token occurring in the sequence given the context. This is useful for different use cases:
-
Classification tasks
-
Retrieval (Q&A) evaluation
-
Autocomplete
-
Token highlighting and outputting bytes
-
Calculating perplexity
To enable Logprobs, provide "logprobs": true to Ollama’s API:
curl http://localhost:11434/api/generate -d '{
"model": "gemma3",
"prompt": "Why is the sky blue?",
"logprobs": true
}'
When log probabilities are requested, response chunks will now include a "logprobs" field with the token, log probability and raw bytes (for partial unicode).
{
"model": "gemma3",
"created_at": "2025-11-14T22:17:56.598562Z",
"response": "Okay",
"done": false,
"logprobs": [
{
"token": "Okay",
"logprob": -1.3434503078460693,
"bytes": [
79,
107,
97,
121
]
}
]
}
top_logprobs
When setting "top_logprobs", a number of most-likely tokens are also provided, making it possible to introspect alternative tokens. Below is an example request.
curl http://localhost:11434/api/generate -d '{
"model": "gemma3",
"prompt": "Why is the sky blue?",
"logprobs": true,
"top_logprobs": 3
}'