-
Notifications
You must be signed in to change notification settings - Fork 60
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
Transformers model as Judge #174
Open
anilaltuner
wants to merge
7
commits into
huggingface:main
Choose a base branch
from
anilaltuner:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fdb22c7
Transformers as Judge added
anilaltuner 6906b04
Transformers as Judge added
anilaltuner 8a33c12
Formatting fix
anilaltuner aef34a7
Check model from HfApi
anilaltuner 8ebfb16
Merge branch 'main' into main
clefourrier c8e26f0
Merge branch 'main' into main
clefourrier 6f976c7
Merge branch 'main' into main
NathanHB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
|
||
import nltk | ||
import numpy as np | ||
from huggingface_hub import HfApi | ||
from nltk.metrics.distance import edit_distance | ||
from nltk.tokenize import word_tokenize | ||
from nltk.tokenize.treebank import TreebankWordTokenizer | ||
|
@@ -40,7 +41,7 @@ | |
from lighteval.metrics.imports.bert_scorer import BERTScorer | ||
from lighteval.metrics.imports.data_stats_metric import DataStatsMetric | ||
from lighteval.metrics.imports.summac import SummaCZS | ||
from lighteval.metrics.llm_as_judge import JudgeOpenAI | ||
from lighteval.metrics.llm_as_judge import JudgeLM | ||
from lighteval.metrics.normalizations import remove_braces, remove_braces_and_strip | ||
from lighteval.tasks.requests import Doc | ||
from lighteval.utils import as_list | ||
|
@@ -622,11 +623,18 @@ def edit_similarity(self, s1, s2): | |
|
||
|
||
class JudgeLLM: | ||
available_models = ["gpt-3.5-turbo", "gpt-4o", "gpt-4-turbo", "gpt-4"] | ||
gpt_models = ["gpt-3.5-turbo"] | ||
|
||
def __init__(self, judge_model_name: str, template_path: str, multi_turn: bool = False): | ||
if judge_model_name not in self.available_models: | ||
raise ValueError(f"{judge_model_name} not in available models for llm as a judge metric") | ||
if judge_model_name in self.gpt_models: | ||
judge_type = "openai" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this wouldn't work, if we pass in |
||
else: | ||
api = HfApi() | ||
models = api.list_models(model_name=judge_model_name) | ||
if models: | ||
judge_type = "transformers" | ||
else: | ||
raise ValueError(f"{judge_model_name} not in available models for llm as a judge metric") | ||
|
||
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") | ||
self.multi_turn = multi_turn | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temperature is not needed if
do_sample
is set to False