Skip to main content

Compute shannon entropy from LLM responses to detect hallucinations

Project description

Shannon Entropy

Compute Shannon entropy from LLM responses to detect hallucinations and measure uncertainty in natural language generation.

Installation

pip install aks-shannon-entropy

Features

  • Shannon Entropy Computation: Calculate entropy from LLM response distributions
  • Hallucination Detection: Identify unreliable or hallucinated model outputs
  • Uncertainty Quantification: Measure model confidence and uncertainty
  • LLM Integration: Works with HuggingFace transformers and other LLM frameworks

Usage

from shannon_entropy import compute_entropy

responses = ["response1", "response2", "response3"]
entropy = compute_entropy(responses)
print(f"Entropy: {entropy}")

Dependencies

See pyproject.toml for full dependencies.

License

MIT - See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aks_shannon_entropy-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file aks_shannon_entropy-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aks_shannon_entropy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13fe638ac519d34177fa96aa34b29c0689f51c3d3e086ab851cb70da659a7fa2
MD5 95418779a51d7e3a05374963c46e91a7
BLAKE2b-256 2028106b367587bdc75ca4d6c483832f357321888753197a3d11197fc688dca0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page