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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hallx-1.1.0.tar.gz.
File metadata
- Download URL: hallx-1.1.0.tar.gz
- Upload date:
- Size: 37.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b5e13241e4100f92fac07c32b3c04ad99d6ac18526383d85ed816824ab8b1cc
|
|
| MD5 |
3dbcbeb92b3b0d6fff480d8d8c505357
|
|
| BLAKE2b-256 |
ff9e7961b9ec8913b50e3ebb8b5e7bbd8517228fa04c20f2490fa234f2d68026
|
Provenance
The following attestation bundles were made for hallx-1.1.0.tar.gz:
Publisher:
release.yml on dhanushk-offl/hallx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hallx-1.1.0.tar.gz -
Subject digest:
5b5e13241e4100f92fac07c32b3c04ad99d6ac18526383d85ed816824ab8b1cc - Sigstore transparency entry: 2386935573
- Sigstore integration time:
-
Permalink:
dhanushk-offl/hallx@e73baff4cb895bcbe7e9a6ebf5178fc20b36fe85 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/dhanushk-offl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e73baff4cb895bcbe7e9a6ebf5178fc20b36fe85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hallx-1.1.0-py3-none-any.whl.
File metadata
- Download URL: hallx-1.1.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dffc13afce680ad3b0c8ebd985096e86b7a780817429ca28cb81700e1e5eb4cc
|
|
| MD5 |
b39c4bd92bae0f90e3f91d113805ef7c
|
|
| BLAKE2b-256 |
a1d3533504ef2178060a1b2f4370551cca1f45f92f4181cd65047cf562cd1408
|
Provenance
The following attestation bundles were made for hallx-1.1.0-py3-none-any.whl:
Publisher:
release.yml on dhanushk-offl/hallx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hallx-1.1.0-py3-none-any.whl -
Subject digest:
dffc13afce680ad3b0c8ebd985096e86b7a780817429ca28cb81700e1e5eb4cc - Sigstore transparency entry: 2386935575
- Sigstore integration time:
-
Permalink:
dhanushk-offl/hallx@e73baff4cb895bcbe7e9a6ebf5178fc20b36fe85 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/dhanushk-offl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e73baff4cb895bcbe7e9a6ebf5178fc20b36fe85 -
Trigger Event:
push
-
Statement type: