hallucination-risk-meter
Estimate hallucination risk in LLM answers from uncertainty language, unsupported specifics, citations, and context coverage. Zero runtime dependencies.
Python port of @mukundakatta/hallucination-risk-meter. The JS sibling has the original API; this README sticks to the Python surface.
Install
pip install hallucination-risk-meter
Usage
from hallucination_risk_meter import score
answer = "The company earned $42 million in 2023."
ctx = "Acme Inc. reported revenue of $40-44 million for fiscal year 2023."
r = score(answer, context=ctx, citations=[{"id": "1"}])
r.score # float in [0.0, 1.0]
r.signals # list[str] -- triggered heuristics
r.severity # 'low' | 'medium' | 'high'
Signals
Each triggered signal contributes a fixed weight to the final score (clamped to [0, 1]):
| Signal | Weight | Triggers when... |
|---|---|---|
uncertainty_language |
0.10 | Hedge phrases like "I think", "may", "possibly", "not sure" appear. |
unsourced_specifics |
0.30 | Specific numbers, percentages, currency, years, or dates appear in an uncited sentence. |
confident_overreach |
0.20 | "definitely" / "guaranteed" / "always" appear without supporting context overlap. |
unsourced_named_entities |
0.20 | A capitalized multi-word entity appears uncited and absent from the context. |
length_disproportionate |
0.20 | The answer is roughly 3x longer than the supplied context. |
no_citations |
0.15 | The answer asserts something factual-looking but no citations were supplied. |
Severity buckets
score < 0.34->"low"0.34 - 0.66->"medium"score >= 0.67->"high"
Custom signals
Inject precomputed signals from your own classifier:
score("...", signals=["nli_contradiction", "self_consistency_drop"])
Names not in the built-in weight table contribute 0.0 but still appear in r.signals for downstream logging.
API differences from the JS sibling
- Returns a
RiskScoredataclass withscore,signals, andseverityinstead of the JS{risk, reasons, likelyHallucinated}object. - Adds the
signals=parameter for injecting upstream-detector signals. - Adds
severitybucketing (low/medium/high) for convenient guardrail thresholds.
See the JS sibling's README for the full design notes.
Metadata
Release files for hallucination-risk-meter 0.1.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 |
|---|---|---|---|---|
| hallucination_risk_meter-0.1.0.tar.gz | 7.8 kB | Without provenance | Details for hallucination_risk_meter-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hallucination_risk_meter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hallucination_risk_meter-0.1.0-py3-none-any.whl |
Total release size: 15.6 kB
Release files / hallucination_risk_meter-0.1.0.tar.gz
| Download URL | hallucination_risk_meter-0.1.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4d256146229612a0a13a92318088b5b67585ff509e8a047d76958c47232996d
|
|
BLAKE2b-256 checksum How to use checksums |
3f173c91eb0423e839f5d301eee35b98d2174d6ec428a120642a60067ab83c0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / hallucination_risk_meter-0.1.0-py3-none-any.whl
| Download URL | hallucination_risk_meter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d01f8c6f9c1dd0eca96c5b9d499b5cafdf0bc8756905bb0106b3065bf634cfa2
|
|
BLAKE2b-256 checksum How to use checksums |
745998fd671a4c19bbfd49d69a225e7acaa84a5c8f965938386e0c63e38587de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for hallucination-risk-meter 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.