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

Removes default bert scorer init #234

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Changes from 2 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
10 changes: 7 additions & 3 deletions src/lighteval/metrics/metrics_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,7 @@ def __init__(
normalize_pred (callable, optional): Function to use to normalize the predicted strings.
Defaults to None if no normalization is applied.
"""
self.bert_scorer = BERTScorer(
model_type="microsoft/deberta-large-mnli", lang="en", rescale_with_baseline=True, num_layers=9
)
self.bert_scorer = None

self.normalize_gold = normalize_gold
self.normalize_pred = normalize_pred
Expand All @@ -441,6 +439,12 @@ def compute(self, golds: list[str], predictions: list[str]) -> dict:
Returns:
dict: Scores over the current sample's items.
"""
if self.bert_scorer is None:
hlog_warn("The first metric computation step might be a bit long as we need to download the model.")
clefourrier marked this conversation as resolved.
Show resolved Hide resolved
# We only initialize on first compute
self.bert_scorer = BERTScorer(
model_type="microsoft/deberta-large-mnli", lang="en", rescale_with_baseline=True, num_layers=9
)
golds = as_list(golds)
predictions = as_list(predictions)
# Normalize
Expand Down
Loading