Pedro-Sarmiento/Aluora

Aluora is a Python library designed to detect hallucinations in text generated by large language models (LLMs)

0

stars

8

commits

Python

primary language

May 7, 2026

updated

README

Aluora

PyPI version Python License: MIT PyPI Downloads

Aluora is a Python library for hallucination detection in text generated by Large Language Models. It integrates multiple complementary detection methods to assess the risk that a given LLM response is unsupported or fabricated relative to its context and question.

Designed for use in RAG systems operating in critical environments, where silently fabricated answers can cause real harm.


Why Aluora

LLM hallucinations are not detected reliably by any single method. Each existing approach has different blind spots: uncertainty-based methods miss confidently wrong answers; consistency-based methods miss semantically plausible fabrications; lexical methods miss high-level reasoning errors.

Aluora combines three orthogonal approaches into a single API, returning a structured assessment that can be plugged into RAG pipelines, evaluation suites, or human-in-the-loop workflows.


Detection methods

MethodApproachWhat it catches
HalluDetectDropout-based DenseNet with MC Dropout + mutual information for uncertainty estimationConfidently-wrong answers; quantifies model uncertainty
HHEMSemantic consistency scoring using a pretrained transformer classifierSemantic mismatch between answer and grounding context
LettuceDetectSpan-level hallucination detection using contextual lexical evaluationPinpoints which specific spans of the answer are unsupported

Architecture

flowchart LR
    Input[Context + Question + Answer] --> H1[HalluDetect<br/>uncertainty]
    Input --> H2[HHEM<br/>semantic consistency]
    Input --> H3[LettuceDetect<br/>span-level]
    H1 --> Out[Aggregated JSON output]
    H2 --> Out
    H3 --> Out

Installation

From PyPI:

pip install aluora

From source:

git clone https://github.com/Pedro-Sarmiento/aluora.git
cd aluora
pip install -e .

Quick start

from Aluora.core.extractor import hallucination_metrics

hallucination_metrics(
    context="The robot was built in 2023.",
    question="When was the robot built?",
    answer="The robot was built in 2023.",
    output_json_path="results.json"
)

Output structure

{
  "halludetect": {
    "predicted_class": 0,
    "label": "Hallucination",
    "probability_class_1": 0.15,
    "mutual_information": 0.08
  },
  "hhem": {
    "prob_no_hallucination": 0.02,
    "risk_level": "HIGH"
  },
  "lettuce": {
    "detected_spans": [],
    "estimated_risk": "MEDIUM"
  }
}

Interpreting the output

FieldMeaning
halludetect.predicted_classBinary class predicted by HalluDetect (0 = hallucination, 1 = grounded)
halludetect.probability_class_1Confidence the answer is grounded (closer to 1 is better)
halludetect.mutual_informationEpistemic uncertainty estimate — high values indicate the model is unsure
hhem.prob_no_hallucinationProbability that the answer is consistent with the context
hhem.risk_levelCategorical risk label derived from HHEM probability (LOW / MEDIUM / HIGH)
lettuce.detected_spansList of answer spans flagged as unsupported by the context
lettuce.estimated_riskAggregated risk label from span-level analysis

Background

Aluora originated from a Bachelor's Thesis at the Universidad de Las Palmas de Gran Canaria (BSc in Data Science and Engineering), focused on the detection, mitigation, and evaluation of hallucinations in Retrieval-Augmented Generation systems for critical environments. The library packages the practical detection components of that work into a reusable tool.


Roadmap

  • Batch evaluation interface for full RAG test sets
  • CLI for quick command-line evaluation
  • Configurable thresholds for risk-level mapping
  • Additional detection methods (LLM-as-a-judge, citation verification)
  • Documentation site with method-by-method tutorials

Contributions and method suggestions welcome — open an issue.


Citation

If you use Aluora in academic work, please cite it as:

@software{sarmiento_aluora,
  author = {Sarmiento Yánez, Pedro},
  title  = {Aluora: A multi-method hallucination detection library for LLMs},
  year   = {2025},
  url    = {https://github.com/Pedro-Sarmiento/aluora}
}

License

MIT — see LICENSE for details.


Author

Pedro Sarmiento Yánez — AI Engineer working on LLMs in production.

GitHub · LinkedIn

Contributors

Pedro-Sarmiento/Aluora

Aluora is a Python library designed to detect hallucinations in text generated by large language models (LLMs)

0

stars

8

commits

Python

primary language

May 7, 2026

updated

README

Aluora

PyPI version Python License: MIT PyPI Downloads

Aluora is a Python library for hallucination detection in text generated by Large Language Models. It integrates multiple complementary detection methods to assess the risk that a given LLM response is unsupported or fabricated relative to its context and question.

Designed for use in RAG systems operating in critical environments, where silently fabricated answers can cause real harm.


Why Aluora

LLM hallucinations are not detected reliably by any single method. Each existing approach has different blind spots: uncertainty-based methods miss confidently wrong answers; consistency-based methods miss semantically plausible fabrications; lexical methods miss high-level reasoning errors.

Aluora combines three orthogonal approaches into a single API, returning a structured assessment that can be plugged into RAG pipelines, evaluation suites, or human-in-the-loop workflows.


Detection methods

MethodApproachWhat it catches
HalluDetectDropout-based DenseNet with MC Dropout + mutual information for uncertainty estimationConfidently-wrong answers; quantifies model uncertainty
HHEMSemantic consistency scoring using a pretrained transformer classifierSemantic mismatch between answer and grounding context
LettuceDetectSpan-level hallucination detection using contextual lexical evaluationPinpoints which specific spans of the answer are unsupported

Architecture

flowchart LR
    Input[Context + Question + Answer] --> H1[HalluDetect<br/>uncertainty]
    Input --> H2[HHEM<br/>semantic consistency]
    Input --> H3[LettuceDetect<br/>span-level]
    H1 --> Out[Aggregated JSON output]
    H2 --> Out
    H3 --> Out

Installation

From PyPI:

pip install aluora

From source:

git clone https://github.com/Pedro-Sarmiento/aluora.git
cd aluora
pip install -e .

Quick start

from Aluora.core.extractor import hallucination_metrics

hallucination_metrics(
    context="The robot was built in 2023.",
    question="When was the robot built?",
    answer="The robot was built in 2023.",
    output_json_path="results.json"
)

Output structure

{
  "halludetect": {
    "predicted_class": 0,
    "label": "Hallucination",
    "probability_class_1": 0.15,
    "mutual_information": 0.08
  },
  "hhem": {
    "prob_no_hallucination": 0.02,
    "risk_level": "HIGH"
  },
  "lettuce": {
    "detected_spans": [],
    "estimated_risk": "MEDIUM"
  }
}

Interpreting the output

FieldMeaning
halludetect.predicted_classBinary class predicted by HalluDetect (0 = hallucination, 1 = grounded)
halludetect.probability_class_1Confidence the answer is grounded (closer to 1 is better)
halludetect.mutual_informationEpistemic uncertainty estimate — high values indicate the model is unsure
hhem.prob_no_hallucinationProbability that the answer is consistent with the context
hhem.risk_levelCategorical risk label derived from HHEM probability (LOW / MEDIUM / HIGH)
lettuce.detected_spansList of answer spans flagged as unsupported by the context
lettuce.estimated_riskAggregated risk label from span-level analysis

Background

Aluora originated from a Bachelor's Thesis at the Universidad de Las Palmas de Gran Canaria (BSc in Data Science and Engineering), focused on the detection, mitigation, and evaluation of hallucinations in Retrieval-Augmented Generation systems for critical environments. The library packages the practical detection components of that work into a reusable tool.


Roadmap

  • Batch evaluation interface for full RAG test sets
  • CLI for quick command-line evaluation
  • Configurable thresholds for risk-level mapping
  • Additional detection methods (LLM-as-a-judge, citation verification)
  • Documentation site with method-by-method tutorials

Contributions and method suggestions welcome — open an issue.


Citation

If you use Aluora in academic work, please cite it as:

@software{sarmiento_aluora,
  author = {Sarmiento Yánez, Pedro},
  title  = {Aluora: A multi-method hallucination detection library for LLMs},
  year   = {2025},
  url    = {https://github.com/Pedro-Sarmiento/aluora}
}

License

MIT — see LICENSE for details.


Author

Pedro Sarmiento Yánez — AI Engineer working on LLMs in production.

GitHub · LinkedIn

Contributors

Languages

Python

100.0%