Skip to main content

hallx

hallx logo

Lightweight hallucination-risk scoring for production LLM pipelines

Tests Release OpenSSF Scorecard PyPI Downloads / month Python License

What Is Hallx

Hallx is a practical guardrail layer that evaluates LLM responses before they are trusted in downstream systems.

It scores responses using:

  • schema validity
  • consistency across repeated generations
  • grounding against provided context

It returns:

  • confidence
  • risk_level
  • issues
  • recommendation
  • coverage (which checks ran or were skipped)

At least grounding or consistency must run to produce a normal risk verdict. Otherwise, Hallx returns insufficient_evidence and recommends review, unless the score already indicates high risk. Use required_checks={"grounding"} to require specific checks. Confidence is a heuristic, not a probability of truth. See the usage guide for the behavior change and safety-gate details.

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

Hallx workflow

Languages

Community

Metadata

Release files for hallx 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hallx 1.1.1
File Size Uploaded Provenance Actions
hallx-1.1.1.tar.gz 39.5 kB With provenance Details for hallx-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hallx 1.1.1
File Interpreter ABI Platform Actions
hallx-1.1.1-py3-none-any.whl Python 3 none any Details for hallx-1.1.1-py3-none-any.whl

Total release size: 78.5 kB

Release files / hallx-1.1.1.tar.gz

Download URL hallx-1.1.1.tar.gz
Size 39.5 kB
Tags Source
SHA-256 checksum
How to use checksums
58d7cc145bc265629aa782b9e7e8e47d45b0c7a660cd2b04d8fb5bb032c8c713
BLAKE2b-256 checksum
How to use checksums
c10e318c49ca66e6c26b7e1fad791c9eb5dc7c48b0e68171ce8fcc6c831ff873
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 Nov 14, 2026.

Transparency log

Release files / hallx-1.1.1-py3-none-any.whl

Download URL hallx-1.1.1-py3-none-any.whl
Size 39.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b27b627cfdeb28b41973b5162530dbbfd0e03df3ae9d825f9873139e3a73d14a
BLAKE2b-256 checksum
How to use checksums
0c26309a16fceb685a7bf19ce0fa1bcdd93359d3471da64f9496338432f5122d
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 Nov 14, 2026.

Transparency log

Security for hallx 1.1.1

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.

Select from 2 files

Attestation for hallx-1.1.1.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 Nov 14, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page