Skip to content

Commit

Permalink
Handle no valid eval results for mt_bench
Browse files Browse the repository at this point in the history
Signed-off-by: Dan McPherson <[email protected]>
  • Loading branch information
danmcp committed Nov 14, 2024
1 parent 8e32704 commit 6c02db7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/instructlab/eval/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ def __init__(self, tasks_dir) -> None:
self.tasks_dir = tasks_dir
self.message = f"Invalid Tasks Dir: {tasks_dir}"

class InvalidEvaluationResult(EvalError):
"""
Error raised for invalid eval results
Attributes
message error message to be printed on raise
"""

def __init__(self, message) -> None:
super().__init__()
self.message = message


class ModelServingAPIError(EvalError):
"""
Expand Down
10 changes: 8 additions & 2 deletions src/instructlab/eval/mt_bench_judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import numpy as np
import pandas as pd

# First Party
from instructlab.eval import exceptions

# Local
from .logger_config import setup_logger
from .mt_bench_common import (
Expand Down Expand Up @@ -97,8 +100,11 @@ def make_judgment(
turn_scores = []
# First turn
df_1 = judgment_df[judgment_df["turn"] == 1].groupby(["model", "turn"]).mean()
overall_score = df_1["score"].iloc[0]
turn_scores.append(overall_score)
if len(df_1.index) > 0:
overall_score = df_1["score"].iloc[0]
turn_scores.append(overall_score)
else:
raise exceptions.InvalidEvaluationResult("Evaluation provided no result. See logs for more details.")

if bench_name == "mt_bench":
# Second turn
Expand Down

0 comments on commit 6c02db7

Please sign in to comment.