Skip to content

Adds RULER benchmark #722

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 21 additions & 1 deletion src/lighteval/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,27 @@ class Metrics(Enum):
corpus_level_fn=np.mean,
higher_is_better=True,
)

ruler_match_any = SampleLevelMetric(
metric_name="ruler_match_any",
sample_level_fn=lambda predictions, golds, formatted_doc: max(
[1.0 if r.lower() in predictions[0].lower() else 0.0 for r in golds]
),
category=MetricCategory.GENERATIVE,
use_case=MetricUseCase.SUMMARIZATION,
corpus_level_fn=np.mean,
higher_is_better=True,
)
ruler_match_all = SampleLevelMetric(
metric_name="ruler_match_all",
sample_level_fn=lambda predictions, golds, formatted_doc: sum(
[1.0 if r.lower() in predictions[0].lower() else 0.0 for r in golds]
)
/ len(golds),
category=MetricCategory.GENERATIVE,
use_case=MetricUseCase.SUMMARIZATION,
corpus_level_fn=np.mean,
higher_is_better=True,
)
bleurt = SampleLevelMetric(
metric_name="bleurt",
sample_level_fn=BLEURT().compute,
Expand Down
2 changes: 1 addition & 1 deletion src/lighteval/models/vllm/vllm_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def greedy_until(
if max_new_tokens is not None:
if context_size + max_new_tokens > self.max_length:
logger.warning(
f"{context_size + max_new_tokens=} which is greater than {self.max_length=}. Truncating context to {self.max_length - max_new_tokens} tokens."
f"{context_size + max_new_tokens=} which is greater than {self.max_length=}. Truncating context to {self.max_length=} - {max_new_tokens=} = {self.max_length - max_new_tokens} tokens."
)
context_size = self.max_length - max_new_tokens
if context_size < 0:
Expand Down
17 changes: 14 additions & 3 deletions src/lighteval/tasks/default_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
# fmt: on


def ruler(line, task_name: str = None):
query = line["input"]
choices = line["outputs"]
gold_index = 0
instruction = "Only answer the question to complete the prompt, without any additional text.\n"
query = f"{instruction}{query}"

return Doc(query=query, instruction=instruction, choices=choices, gold_index=gold_index, task_name=task_name)

def mmmu_pro(line, task_name: Optional[str] = None):
# fmt: off
question = line["question"] # "What is the capital of France?"
Expand Down Expand Up @@ -87,7 +96,6 @@ def mmmu_pro(line, task_name: Optional[str] = None):
instruction=instructions,
)


def mmmu_pro_vision(line, task_name: str = None):
instruction = (
"Answer with the option letter from the given choices directly."
Expand Down Expand Up @@ -119,14 +127,17 @@ def mmmu_pro_vision(line, task_name: str = None):
instruction=instruction,
)


def simpleqa(line, task_name: str = None):
query = line["problem"]
choices = [line["answer"]]
gold_index = 0

return Doc(
task_name=task_name, query=query, choices=choices, gold_index=gold_index, specific={**eval(line["metadata"])}
task_name=task_name,
query=query,
choices=choices,
gold_index=gold_index,
specific={**eval(line["metadata"])},
)


Expand Down
Loading
Loading