Observed since 21 Oct, 09:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Agiflow (EVAL) for Python
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.
First, ensure you have the necessary packages installed. You can install the required dependencies using pip:
pip install agiflow-eval
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:
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)
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)
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)
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)
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)
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)
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())
We welcome contributions to agiflow_eval. Please see our CONTRIBUTING.md for guidelines on how to get involved.
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to the DeepEval project for providing the foundation upon which this library is built.
For any questions or feedback, please open an issue or reach out via the project's contact information.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.0.2 | 25 Jun 2024 | 6 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 09:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:68336100a2522ffe612a952e40cb50ebb55bf4056502d95bcf26d217efbae574