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 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
3 changes: 2 additions & 1 deletion src/lighteval/models/vllm/vllm_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ 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."
)
breakpoint()
context_size = self.max_length - max_new_tokens
if context_size < 0:
logger.critical(
Expand Down
19 changes: 15 additions & 4 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 Expand Up @@ -254,7 +265,7 @@ def arc_with_options(line, task_name: str = None):
query += "".join([f"\n{key}. {choice}" for key, choice in zip(LETTER_INDICES, line["choices"]["text"])])
query += "\nAnswer:"
return Doc(
task_name=task_name,
mm task_name=task_name,
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that an extraneous 'mm' has been introduced before the task_name parameter. Please remove it to restore valid syntax.

Suggested change
mm task_name=task_name,
task_name=task_name,

Copilot uses AI. Check for mistakes.

query=query,
choices=line["choices"]["text"],
gold_index=line["choices"]["label"].index(line["answerKey"]),
Expand Down
Loading
Loading