proprioceptive-confidence
See how sure a language model was about every word.
Models sound equally sure whether they're right or guessing. Their own token probabilities tell the difference.
proprioceptive-confidence turns those probabilities into a plain report: which words were shaky, how shaky,
and whether a short answer still holds when the model is asked again in full.
$ pip install proprioceptive-confidence
$ proprioconf "In what year was Albert Einstein born? Answer with just the year." --double-check
1904
shaky: 1 word(s) below 80%: "190" at 66%
double-check: 'Albert Einstein was born in 1879.' (answers disagree)
(Output from a small local model; your numbers will vary by model.)
- No dependencies. Standard library only.
- Works with what you already run: Ollama 0.12+ (native API), and any OpenAI-compatible server that returns
logprobs(OpenAI, vLLM, llama.cpp, LM Studio, Ollama's/v1). - Plugs into frameworks: a LangChain callback, a LiteLLM logger and an Inspect scorer.
- Nothing leaves your machine when you point it at a local model.
Python
from proprioceptive_confidence import ConfidenceClient
client = ConfidenceClient(model="llama3.2", threshold=0.8) # Ollama at 127.0.0.1:11434
ans = client.ask("What is the capital of Australia?", double_check=True)
print(ans.text) # the answer
print(ans.report.summary()) # 'confident: ...' or 'shaky: ... "Sydney" at 41%'
print(ans.report.is_confident) # False if any word was below the threshold
print(ans.report.to_dict()) # min / mean probability, shaky tokens, alternatives
Already have a response? Analyse it directly:
from proprioceptive_confidence import analyze
report = analyze(openai_response) # OpenAI-style dict or object requested with logprobs=True
report = analyze(ollama_response) # Ollama /api/chat response requested with "logprobs": true
OpenAI-compatible servers:
client = ConfidenceClient(api="openai", base_url="http://127.0.0.1:8000/v1", model="my-model")
LangChain
from langchain_openai import ChatOpenAI
from proprioceptive_confidence.integrations.langchain import ConfidenceCallbackHandler
conf = ConfidenceCallbackHandler(threshold=0.8)
llm = ChatOpenAI(model="gpt-4o-mini", logprobs=True, callbacks=[conf])
llm.invoke("In what year was Albert Einstein born?")
print(conf.last_report.summary())
pip install "proprioceptive-confidence[langchain]". Pass raise_on_low=True to stop a chain when an answer is shaky.
LiteLLM
import litellm
from proprioceptive_confidence.integrations.litellm import ConfidenceLogger
conf = ConfidenceLogger(threshold=0.8, on_report=lambda r: print(r.summary()))
litellm.callbacks = [conf]
litellm.completion(model="ollama_chat/llama3.2", messages=[{"role": "user", "content": "..."}], logprobs=True)
pip install "proprioceptive-confidence[litellm]". LiteLLM runs loggers after the call returns, so use
on_report (or read conf.reports) rather than relying on an exception.
Inspect
Score every sample of an Inspect eval by whether the model was sure of its answer:
from inspect_ai import Task, task
from inspect_ai.dataset import Sample
from inspect_ai.model import GenerateConfig
from inspect_ai.scorer import match
from inspect_ai.solver import generate
from proprioceptive_confidence.integrations.inspect import confidence
@task
def capitals():
return Task(
dataset=[Sample(input="Capital of France? One word.", target="Paris")],
solver=generate(),
scorer=[match(), confidence(threshold=0.8)],
config=GenerateConfig(logprobs=True, top_logprobs=3),
)
pip install "proprioceptive-confidence[inspect]". Each sample scores C (every word at or above the threshold),
I (a shaky word) or N (no logprobs returned); metadata has min_prob, mean_prob and the shaky words with their
alternatives. Pairing it with match() shows which wrong answers the model was unsure of.
Testing without a model
proprioceptive_confidence.testing.FakeModelServer speaks Ollama's and OpenAI's chat APIs with scripted token
probabilities, so you can test confidence handling in CI without a GPU.
What it can't do
A model can be wrong and certain. Token probabilities catch shaky answers, not confident mistakes.
Related
- pytest-llm-confidence: fail a test when the model wasn't sure of its answer.
- proprioceptive-mcp: let Claude Code, Cursor and other agents ask your local model and see how sure it was.
- Proprioceptive Lens: the full local app, with live confidence colouring, double-check, private memory and
internal-state behaviour readings:
pip install proprioceptive-lens.
MIT licensed. From Proprioceptive AI.
Metadata
Release files for proprioceptive-confidence 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| proprioceptive_confidence-0.2.0.tar.gz | 19.4 kB | With provenance | Details for proprioceptive_confidence-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| proprioceptive_confidence-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for proprioceptive_confidence-0.2.0-py3-none-any.whl |
Total release size: 38.8 kB
Release files / proprioceptive_confidence-0.2.0.tar.gz
| Download URL | proprioceptive_confidence-0.2.0.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
978298678d1104b0ec8bd391cb7e389b2f5fea8742f02422dfc8b443f9060aab
|
|
BLAKE2b-256 checksum How to use checksums |
73f5310d5ede93275f201b9b6739289090925b6df40f85d4c549babc84179bc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / proprioceptive_confidence-0.2.0-py3-none-any.whl
| Download URL | proprioceptive_confidence-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e81b65280f620bbbc9196d854bad9302a6cc1a4d8a9f7ad2f7d9500d33a541f3
|
|
BLAKE2b-256 checksum How to use checksums |
94540651974260a7767a902a16cc81e5e225d235aba2f812481ab34db66568b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for proprioceptive-confidence 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for proprioceptive_confidence-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.