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 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
16 changes: 15 additions & 1 deletion src/lighteval/tasks/default_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,27 @@
# 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 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