Skip to main content

A Python package for evaluating LLM application outputs.

Project description

GroundedAI

Overview

The grounded-ai package is a powerful tool developed by GroundedAI to evaluate the performance of large language models (LLMs) and their applications. It leverages our own fine tuned small language models and metric specific adapters to compute various metrics, providing insights into the quality and reliability of LLM outputs. Our models can be found here: https://huggingface.co/grounded-ai

Features

  • Metric Evaluation: Compute a wide range of metrics to assess the performance of LLM outputs, including:

    • Factual accuracy
    • Relevance to the given context
    • Potential biases or toxicity
    • Hallucination
  • Small Language Model Integration: Utilize state-of-the-art small language models, optimized for efficient evaluation tasks, to analyze LLM outputs accurately and quickly.

  • Adapter Support: Leverage GroundedAI's proprietary adapters, such as the phi3-toxicity-judge adapter, to fine-tune the small language models for specific domains, tasks, or evaluation criteria, ensuring tailored and precise assessments.

  • Flexible Input/Output Handling: Accept LLM outputs in various formats (text, JSON, etc.) and provide evaluation results in a structured and easily consumable manner.

Getting Started

Install the grounded-ai package from PyPI:

pip install grounded-ai==0.0.9-alpha

Example Usage: Toxicity Evaluation

The ToxicityEvaluator class is used to evaluate the toxicity of a given text. Here's an example of how to use it:

from grounded_ai.evaluators.toxicity_evaluator import ToxicityEvaluator

toxicity_evaluator = ToxicityEvaluator(quantization=True)
toxicity_evaluator.warmup()
data = [
    "That guy is so stupid and ugly",
    "Bunnies are the cutest animals in the world"
]
response = toxicity_evaluator.evaluate(data)
# Output
# {'toxic': 1, 'non-toxic': 1, 'percentage_toxic': 50.0}

In this example, we initialize the ToxicityEvaluator. The quantization parameter is optionally set to True to enable quantization for faster inference with less memory.

We then load the base model and the GroundedAI adapter using the warmup() method.

Next, we define a list of texts (data) that we want to evaluate for toxicity.

Finally, we call the evaluate method with the data list, and it returns a dictionary containing the number of toxic and non-toxic texts, as well as the percentage of toxic texts.

In the output, we can see that out of the two texts, one is classified as toxic, and the other as non-toxic, resulting in a 50% toxicity percentage.

Documentation

Detailed documentation, including API references, examples, and guides, coming soon at https://groundedai.tech/api.

Contributing

We welcome contributions from the community! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the GroundedAI grounded-eval GitHub repository.

License

The grounded-ai package is released under the MIT License.

Project details


Download files

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

Source Distribution

grounded_ai-0.0.9.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

grounded_ai-0.0.9-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file grounded_ai-0.0.9.tar.gz.

File metadata

  • Download URL: grounded_ai-0.0.9.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for grounded_ai-0.0.9.tar.gz
Algorithm Hash digest
SHA256 5feda27a3bbe3e1324fed2ef2cf74290611c27a598255dba986b117060ed2856
MD5 914268aebce8d2f02ad93f0434d89eec
BLAKE2b-256 2b56d60fd25765128f849e66993b57ae813adfe1782b9700b5d3661b2629d38d

See more details on using hashes here.

File details

Details for the file grounded_ai-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: grounded_ai-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for grounded_ai-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 011daf792379e31ce4448dcee41d5ebe7d1d208337c0482c3262fcc9b8e41efc
MD5 fc03029f90cd4e6ebf8aca0fa32b4c52
BLAKE2b-256 d83e24c300ddfa462b9ff5bf13a238ddb649b61f175558a4a492f1b3b5be3766

See more details on using hashes here.

Supported by

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