Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add llm as judge in metrics #146

Merged
merged 14 commits into from
Apr 11, 2024
6 changes: 4 additions & 2 deletions src/lighteval/metrics/metrics_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import nltk
import numpy as np
from colorama import Fore, Style
from nltk.metrics.distance import edit_distance
from nltk.tokenize import word_tokenize
from nltk.tokenize.treebank import TreebankWordTokenizer
Expand Down Expand Up @@ -620,6 +619,7 @@ def edit_similarity(self, s1, s2):
edist = edit_distance(s1, s2)
return 1.0 - edist / max(len(s1), len(s2)) if len(s1) > 0 and len(s2) > 0 else 0


class LlmAsJudge:
NathanHB marked this conversation as resolved.
Show resolved Hide resolved
available_models = ["gpt-3.5-turbo"]
NathanHB marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -650,7 +650,9 @@ def compute_multi_turn(self, predictions: list[str], formatted_doc: Doc, **kwarg
ref_answers = formatted_doc.specific["reference"]

score, messages, judgement = self.judge.evaluate_answer(questions, predictions, ref_answers, single_turn=True)
score_mt, messages_mt, judgement_mt = self.judge.evaluate_answer(questions, predictions, ref_answers, single_turn=False)
score_mt, messages_mt, judgement_mt = self.judge.evaluate_answer(
questions, predictions, ref_answers, single_turn=False
)

return {
"single_turn": score,
Expand Down
Loading