Skip to main content

Model Hallucination Evaluator CLI

A Python CLI tool for evaluating model hallucinations on various datasets, such as FEVER, SimpleQuestions (SimpQ), TruthfulQA, and FactCC, using the Entropix API and the Hugging Face ecosystem. This tool is designed to help researchers and developers assess the factual accuracy of their models and identify potential hallucinations.


Features

  • Evaluate hallucination rates for local or hosted models.
  • Supports multiple datasets:
    • FEVER: Fact verification claims and evidence dataset.
    • SimpleQuestions (SimpQ): Fact-based QA dataset.
    • TruthfulQA: Evaluates truthfulness of models.
    • FactCC: Factual consistency in summarization.
  • Beautiful and informative CLI interface using rich.
  • Customizable dataset size for quick evaluations.
  • Hugging Face API integration for user-friendly evaluation.

Installation

From PyPI

Install the package directly from PyPI:

pip install model-hallucination

From Source

  1. Clone the repository:

    git clone https://github.com/abhijit-without-h/model-hallucination.git
    cd model-hallucination
    
  2. Install the dependencies:

    pip install -r requirements.txt
    
  3. Install the package:

    pip install .
    

Usage

The CLI provides a simple interface for evaluating models on supported datasets.

Available Commands

Evaluate Dataset

Evaluate a model’s hallucination likelihood on a specific dataset.

model-hallucination evaluate-dataset --dataset DATASET_NAME --max-samples SAMPLE_COUNT --api-key YOUR_API_KEY

Arguments

Argument Description
--dataset Dataset to evaluate: fever, simpq, truthfulqa, or factcc.
--max-samples Maximum number of samples to evaluate (default: 100).
--api-key Your Hugging Face API key.

Example Usage

  1. Evaluate FEVER dataset:

    model-hallucination evaluate-dataset --dataset fever --max-samples 50 --api-key hf_your_api_key
    
  2. Evaluate TruthfulQA dataset:

    model-hallucination evaluate-dataset --dataset truthfulqa --max-samples 100 --api-key hf_your_api_key
    

Supported Datasets

1. FEVER

  • Fact verification dataset.
  • Contains claims and corresponding evidence.

2. SimpleQuestions (SimpQ)

  • Fact-based QA dataset.
  • Includes simple questions with a single fact-based answer.

3. TruthfulQA

  • Evaluates model truthfulness.
  • Questions designed to test a model’s ability to avoid generating false or misleading information.

4. FactCC

  • Evaluates factual consistency in text summarization.
  • Includes claim-evidence pairs.

Example Output

When evaluating a dataset, the CLI will display results in a table format:

Loading truthfulqa dataset...
Evaluating 50 samples...

Hallucination Evaluation
+-----------------------------+-----------------------+--------------------+
| Input                       | Reference            | Hallucination Score|
+-----------------------------+-----------------------+--------------------+
| What is the capital of Mars?| None (fictional)     | 0.95               |
| What is 2 + 2?              | 4                    | 0.01               |
+-----------------------------+-----------------------+--------------------+

Development

Testing

Run unit tests using pytest:

pytest tests/

Building the Package

To build the package for distribution:

python setup.py sdist bdist_wheel

Publishing to PyPI

Upload the package to PyPI:

twine upload dist/*

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature:
    git checkout -b feature-name
    
  3. Commit your changes:
    git commit -m "Add your message here"
    
  4. Push to your branch:
    git push origin feature-name
    
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • Hugging Face for their datasets library.
  • Entropix API for enabling hallucination evaluation.
  • Open-source contributors for inspiration and guidance.

Contact

For support or feedback, open an issue on the GitHub repository or email abhijitsr92@gmail.com.


Let me know if you'd like any modifications or additions to this! 🚀

Metadata

Release files for model-hallucination-cli 1.0.0

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

Source distribution (sdist)

Source distribution for model-hallucination-cli 1.0.0
File Size Uploaded Provenance Actions
model_hallucination_cli-1.0.0.tar.gz 5.2 kB Without provenance Details for model_hallucination_cli-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for model-hallucination-cli 1.0.0
File Interpreter ABI Platform Actions
model_hallucination_cli-1.0.0-py3-none-any.whl Python 3 none any Details for model_hallucination_cli-1.0.0-py3-none-any.whl

Total release size: 11.2 kB

Release files / model_hallucination_cli-1.0.0.tar.gz

Download URL model_hallucination_cli-1.0.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4568d50c5e6abdb59bb069e06c16799a8c05f7f838cd48b84e4e5ed82ca6bd8e
BLAKE2b-256 checksum
How to use checksums
08a6603d962ea495b9bd3917dd64f8ca75152dadee3364faa3dad946628c0aff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / model_hallucination_cli-1.0.0-py3-none-any.whl

Download URL model_hallucination_cli-1.0.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4a9369a578513a5f7205397367071bc5276c7df28af47c56db6b4ef4214fb13
BLAKE2b-256 checksum
How to use checksums
3bcc4b72e0425ec3d33f341dbd729a3818661eeb9abfbedb20b59da96372c6da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Security for model-hallucination-cli 1.0.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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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