Skip to main content

AGIFlow Eval

Overview

agiflow_eval is a customizable evaluation library designed to measure various metrics for language model outputs. It provides tools to evaluate aspects such as answer relevancy, hallucination, bias, faithfulness, contextual relevancy, and toxicity. The library is ported from the awesome DeepEval to support custom evaluation templates and LLM models.

Installation

First, ensure you have the necessary packages installed. You can install the required dependencies using pip:

pip install agiflow-eval

Usage

To use the metrics, first initialize the model and aggregator:

from agiflow_eval import (
  EvalLiteLLM,
  MetadataAggregator,
)

metadata = MetadataAggregator()
model = EvalLiteLLM()

Then create the test case and measure the metric as follows:

Answer Relevancy Metric

Evaluates the relevancy of an answer given a specific input.

from agiflow_eval import AnswerRelevancyMetric, LLMTestCase

metric = AnswerRelevancyMetric(metadata=metadata, model=model)
test_case = LLMTestCase(input="input text", actual_output="actual output text")
score = await metric.a_measure(test_case)

Bias Metric

Measures the presence of bias in the model's output.

from agiflow_eval import BiasMetric, LLMTestCase

metric = BiasMetric(metadata=metadata, model=model)
test_case = LLMTestCase(input="input text", actual_output="actual output text")
score = await metric.a_measure(test_case)

Contextual Relevancy Metric

Assesses the relevancy of the output in a given context.

from agiflow_eval import ContextualRelevancyMetric, LLMTestCase

metric = ContextualRelevancyMetric(metadata=metadata, model=model)
test_case = LLMTestCase(
  input="input text", 
  actual_output="actual output text",
  retrieval_context="retrieval context text"
)
score = await metric.a_measure(test_case)

Faithfulness Metric

Determines the faithfulness of the model's output to the given context or input.

from agiflow_eval import FaithfulnessMetric, LLMTestCase

metric = FaithfulnessMetric(metadata=metadata, model=model)
test_case = LLMTestCase(
  input="input text", 
  actual_output="actual output text",
  retrieval_context="retrieval context text"
)
score = await metric.a_measure(test_case)

Hallucination Metric

Measures the degree of hallucination in the model's output.

from agiflow_eval import HallucinationMetric, LLMTestCase

metric = HallucinationMetric(metadata=metadata, model=model)
test_case = LLMTestCase(
  input="input text", 
  actual_output="actual output text",
  context="context text"
)
score = await metric.a_measure(test_case)

Toxicity Metric

Evaluates the toxicity level of the model's output.

from agiflow_eval import ToxicityMetric, LLMTestCase

metric = ToxicityMetric(metadata=metadata, model=model)
test_case = LLMTestCase(
  input="input text", 
  actual_output="actual output text"
)
score = await metric.a_measure(test_case)

Custom Template

You can simply extends the Default Metric Template class and pass it to Metric class as follow:

from agiflow_eval import ToxicityMetric, ToxicityTemplate, LLMTestCase

class YourTemplate(ToxicityTemplate):
...

metric = ToxicityMetric(metadata=metadata, model=model, template=YourTemplate())

Contributing

We welcome contributions to agiflow_eval. Please see our CONTRIBUTING.md for guidelines on how to get involved.

License

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

Acknowledgements

Special thanks to the DeepEval project for providing the foundation upon which this library is built.

Contact

For any questions or feedback, please open an issue or reach out via the project's contact information.

Release files for agiflow-eval 0.0.2

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

Source distribution (sdist)

Source distribution for agiflow-eval 0.0.2
File Size Uploaded
agiflow_eval-0.0.2.tar.gz 73.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agiflow-eval 0.0.2
File Interpreter ABI Platform
agiflow_eval-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 112.3 kB

Release files / agiflow_eval-0.0.2.tar.gz

Download URL agiflow_eval-0.0.2.tar.gz
Size 73.6 kB
Tags Source
SHA-256 checksum
How to use checksums
609ed3147758e173748da8fd5ca39715eb921001dc8d48634caf75328745755f
BLAKE2b-256 checksum
How to use checksums
835bfeb5d86c2f1309918efe40fd26074f45bb18fb27ddc3b51827c9d6470542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.6 Darwin/22.6.0

Release files / agiflow_eval-0.0.2-py3-none-any.whl

Download URL agiflow_eval-0.0.2-py3-none-any.whl
Size 38.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
435615894b301f70f5882d70461d075683857b981b9cef7f9f876407ff34ae26
BLAKE2b-256 checksum
How to use checksums
a7c20db9a523808c34f8a1d486669ee7bb3b40825370b9b70e711db25fdad044
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.6 Darwin/22.6.0

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

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