Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions evalbench/eval_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""A gRPC servicer that handles EvalService requests."""

import ast
import asyncio
import json
import os
import pandas as pd
from collections.abc import AsyncIterator
from typing import AsyncGenerator

Expand Down Expand Up @@ -517,4 +519,31 @@ def _process_results(
"p90": round(latencies.quantile(0.9), 2),
}

# Add percentiles for metrics reported via the `other` map. `other` is
# stored as a string-serialized dict in the dataframe, so parse it first.
if "other" in results_df.columns:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any pointer to where this "other" is coming from ? Should this also be in the standalone evalbench ?

def _parse_other(o):
if isinstance(o, dict):
return o
if isinstance(o, str) and o:
try:
return ast.literal_eval(o)
except (ValueError, SyntaxError):
return {}
return {}

parsed_other = results_df["other"].apply(_parse_other)
for metric_key in (
"time_to_first_response",
"input_token_count",
"output_token_count",
):
values = parsed_other.apply(lambda d, k=metric_key: d.get(k))
values = pd.to_numeric(values, errors="coerce").dropna()
if not values.empty:
summary[metric_key] = {
"p50": round(values.quantile(0.5), 2),
"p90": round(values.quantile(0.9), 2),
}

return summary
Loading