Metrics
What are Metrics?
Using Metrics
import dbnl
import dbnl.eval
import pandas as pd
# login to dbnl
dbnl.login()
project = dbnl.create_project(name="Metrics Project")
df = pd.DataFrame(
{
"id": [1, 2, 3],
"question": [
"What is the meaning of life?",
"What is the airspeed velocity of an unladen swallow?",
"What is the capital of Assyria?",
],
"answer": [
"To be happy and fulfilled.",
"It's a question of aerodynamics.",
"Nineveh was the capital of Assyria.",
],
"expected_answer": [
"42",
"It's a question of aerodynamics.",
"Nineveh was the capital of Assyria.",
],
}
)
# Create individual metrics
metrics = [
dbnl.eval.metrics.token_count("question"),
dbnl.eval.metrics.word_count("question"),
dbnl.eval.metrics.rouge1("answer", "expected_answer"),
]
# Compute metrics and report results to Distributional
run = dbnl.eval.report_run_with_results(
project=project, column_data=df, metrics=metrics
)

Convenience Functions

Was this helpful?

