hallx
Lightweight hallucination-risk scoring for production LLM pipelines
What Is Hallx
Hallx is a practical guardrail layer that evaluates LLM responses before they are trusted in downstream systems.
It scores responses using:
schemavalidityconsistencyacross repeated generationsgroundingagainst provided context
It returns:
confidencerisk_levelissuesrecommendation
For agentic and retrieval flows, hallx adds three deeper guards:
- Claim-level grounding — splits the response into individual claims and verifies each one against its best evidence snippet, surfacing exactly which sentences are supported, weak, or unsupported.
- Pluggable verifiers — swap in local NLI (
LocalNLIChecker,hallx[nli]) or an LLM-as-judge (GroundingJudge) to score claim–evidence entailment. - Tool-call validation — catch hallucinated tool names and malformed arguments in agentic LLM output before a handler executes them.
Quick Start
pip install hallx
from hallx import Hallx
checker = Hallx(profile="balanced")
result = checker.check(prompt="p", response="r", context=["c"])
print(result.confidence, result.risk_level, result.recommendation)
Claim-Level Grounding
Detect which sentence in the response has evidence, and which is invented:
from hallx.attribution import check_claim_grounding
response = "The Eiffel Tower is in Paris. The Eiffel Tower is also in Berlin."
context = ["The Eiffel Tower is located in Paris, France."]
result = check_claim_grounding(response, context)
for claim in result.claims:
if claim.status != "filtered":
print(f"[{claim.status}] {claim.text}")
[supported] The Eiffel Tower is in Paris.
[unsupported] The Eiffel Tower is also in Berlin.
The result exposes score, supported_count, weak_count, unsupported_count, and per-claim similarity, evidence_index, and evidence_snippet. Use hallx.extract_claims alone to get the typed Claim spans.
Semantically grounded with a verifier
By default clashes are scored with fuzzy text similarity — fast and dependency-free. For real NLI, pass a FaithfulnessVerifier:
from hallx.faithfulness import LocalNLIChecker # needs: pip install 'hallx[nli]'
verifier = LocalNLIChecker()
result = check_claim_grounding(response, context, verifier=verifier)
Or use any hallx LLM adapter as an LLM-as-judge (no extra dependency):
from hallx import OpenAIAdapter
from hallx.judge import GroundingJudge
judge = GroundingJudge(llm_adapter=OpenAIAdapter("gpt-4o-mini", api_key="..."))
result = check_claim_grounding(response, context, verifier=judge)
Claim checks inside the main check
Enable claim-level evidence on every Hallx.check call and the verdict lands on result.evidence:
from hallx import Hallx, OpenAIAdapter
from hallx.judge import GroundingJudge
checker = Hallx()
judge = GroundingJudge(llm_adapter=OpenAIAdapter("gpt-4o-mini", api_key="..."))
result = checker.check(
prompt="Summarize the refund policy",
response="Refunds are allowed within 30 days.",
context=["Refunds are allowed within 30 days of purchase."],
claims=True,
verifier=judge,
)
print(result.claim_grounding_score) # mean claim grounding
print(result.claims_supported) # count of supported claims
print(result.unsupported_claims) # the hallucinated bits, if any
Both check and check_async accept claims=True and verifier=.... Embedding-backed scoring works too: pass embedding_callable and optionally context_embeddings.
Tool-Call Validation
Guard agentic pipelines against hallucinated tool calls before execution:
from hallx import Hallx
tools = {
"get_weather": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
"additionalProperties": False,
},
"send_email": {"parameters": {"type": "object", "properties": {"to": {"type": "string"}}, "required": ["to"]}},
}
checker = Hallx()
agent_output = [
{"function": {"name": "get_weather", "arguments": '{"city": "Paris"}'}},
{"name": "rm -rf", "arguments": "{}"}, # hallucinated tool name
]
result = checker.check_tool_call(agent_output, tools)
print(result.score) # 0.25
print(result.verdicts) # ok / unknown_tool
if result.recommendation["action"] == "block":
print("Regenerate before invoking any tool.")
Accepts raw (name, arguments) pairs, dicts, OpenAI-style {function: ...} payloads, and typed ToolCall instances. The standalone check_tool_call / score_tool_calls helpers are exported too. Verdict statuses: ok, invalid_arguments, malformed, invalid_definition, unknown_tool.
Workflow
Essential Links
Languages
Community
Metadata
Release files for hallx 1.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 | |
|---|---|---|---|---|
| hallx-1.1.0.tar.gz | 37.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hallx-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.6 kB
Release files / hallx-1.1.0.tar.gz
| Download URL | hallx-1.1.0.tar.gz |
|---|---|
| Size | 37.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b5e13241e4100f92fac07c32b3c04ad99d6ac18526383d85ed816824ab8b1cc
|
|
BLAKE2b-256 checksum How to use checksums |
ff9e7961b9ec8913b50e3ebb8b5e7bbd8517228fa04c20f2490fa234f2d68026
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 8, 2026.
Transparency logRelease files / hallx-1.1.0-py3-none-any.whl
| Download URL | hallx-1.1.0-py3-none-any.whl |
|---|---|
| Size | 38.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dffc13afce680ad3b0c8ebd985096e86b7a780817429ca28cb81700e1e5eb4cc
|
|
BLAKE2b-256 checksum How to use checksums |
a1d3533504ef2178060a1b2f4370551cca1f45f92f4181cd65047cf562cd1408
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 8, 2026.
Transparency logSecurity for hallx 1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for hallx-1.1.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 Aug 8, 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.