-
Notifications
You must be signed in to change notification settings - Fork 6
(4/n) Package Arena-Hard Task Variants #82
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
Changes from 1 commit
e5f2bc9
45957a3
c5e1215
ac7ecfe
4cfd3ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,6 @@ | |
| from judgearena.benchmarks.mt_bench.mt_bench_utils import run_mt_bench | ||
| from judgearena.benchmarks.pairwise.baselines import native_pairwise_baseline | ||
| from judgearena.datasets import load_instructions | ||
| from judgearena.datasets.arena_hard import ( | ||
| download_arena_hard, | ||
| is_arena_hard_dataset, | ||
| ) | ||
| from judgearena.datasets.fluency import is_fluency_task as task_is_fluency | ||
| from judgearena.datasets.fluency import load_fluency_contexts | ||
| from judgearena.evaluate import judge_and_parse_prefs, resolve_run_judge_prompt | ||
|
|
@@ -58,17 +54,12 @@ def try_load_dataset_completions( | |
| local_path_tables = data_root / "tables" | ||
| resolved_task = get_packaged_task(dataset) | ||
| if resolved_task is not None: | ||
| from judgearena.datasets.judgearena_tables import load_task_model_outputs | ||
| from judgearena.datasets.registry import resolve_dataset_adapter | ||
|
|
||
| df_outputs = load_task_model_outputs(resolved_task, local_path_tables) | ||
| adapter = resolve_dataset_adapter(resolved_task.spec.dataset.adapter) | ||
|
Collaborator
Author
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.
|
||
| df_outputs = adapter.load_model_outputs(resolved_task, local_path_tables) | ||
| if df_outputs is None: | ||
| return None | ||
| elif is_arena_hard_dataset(dataset): | ||
|
Collaborator
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. great to see some if/else disappear! |
||
| download_arena_hard(dataset=dataset, local_tables_path=local_path_tables) | ||
| output_path = local_path_tables / "model_outputs" / f"{dataset}.csv.zip" | ||
| if not output_path.exists(): | ||
| return None | ||
| df_outputs = read_df(output_path) | ||
| else: | ||
| download_hf(name=dataset, local_path=local_path_tables) | ||
| output_path = local_path_tables / "model_outputs" / f"{dataset}.csv.zip" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,5 @@ | ||
| import pandas as pd | ||
|
|
||
| from judgearena.datasets.arena_hard import ( | ||
| download_arena_hard, | ||
| is_arena_hard_dataset, | ||
| ) | ||
| from judgearena.datasets.m_arenahard import ( | ||
| load_m_arenahard, | ||
| split_m_arena_hard_dataset, | ||
|
|
@@ -18,9 +14,10 @@ def load_instructions(dataset: str, n_instructions: int | None = None) -> pd.Dat | |
| resolved_task = get_packaged_task(dataset) | ||
| if resolved_task is not None: | ||
| from judgearena import utils as judgearena_utils | ||
| from judgearena.datasets.judgearena_tables import load_task_instructions | ||
| from judgearena.datasets.registry import resolve_dataset_adapter | ||
|
|
||
| df_instructions = load_task_instructions( | ||
| adapter = resolve_dataset_adapter(resolved_task.spec.dataset.adapter) | ||
| df_instructions = adapter.load_instructions( | ||
| resolved_task, judgearena_utils.data_root / "tables" | ||
| ) | ||
|
|
||
|
|
@@ -55,20 +52,7 @@ def load_instructions(dataset: str, n_instructions: int | None = None) -> pd.Dat | |
| ) | ||
|
|
||
| else: | ||
| assert dataset in [ | ||
|
Collaborator
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. also great |
||
| "arena-hard-v0.1", | ||
| "arena-hard-v2.0", | ||
| ] | ||
| from judgearena import utils as judgearena_utils | ||
|
|
||
| local_path_tables = judgearena_utils.data_root / "tables" | ||
| if is_arena_hard_dataset(dataset): | ||
| download_arena_hard(dataset=dataset, local_tables_path=local_path_tables) | ||
| else: | ||
| judgearena_utils.download_hf(name=dataset, local_path=local_path_tables) | ||
| df_instructions = judgearena_utils.read_df( | ||
| local_path_tables / "instructions" / f"{dataset}.csv" | ||
| ) | ||
| raise ValueError(f"Unsupported instruction dataset {dataset!r}.") | ||
|
|
||
| df_instructions = df_instructions.set_index("instruction_index").sort_index() | ||
| logger.info("Loaded %d instructions for %s.", len(df_instructions), dataset) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """Registry connecting task dataset-adapter IDs to implementations.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Callable | ||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
|
|
||
| import pandas as pd | ||
|
|
||
| from judgearena.tasks.schema import ResolvedTaskSpec | ||
|
|
||
| TaskDataFunction = Callable[[ResolvedTaskSpec, Path], pd.DataFrame | None] | ||
| TaskDownloadFunction = Callable[[ResolvedTaskSpec, Path], None] | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class DatasetAdapter: | ||
|
Collaborator
Author
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. Similarly we can write this as a
Collaborator
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. Agree that here a dict with multiple keys is worse than datacase (same thing for returning large tuples). |
||
| name: str | ||
| download: TaskDownloadFunction | ||
| load_instructions: TaskDataFunction | ||
| load_model_outputs: TaskDataFunction | ||
|
|
||
|
|
||
| def dataset_adapters() -> tuple[DatasetAdapter, ...]: | ||
|
Collaborator
Author
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. As we want to add new tasks, if it requires a special download function or load function, we will add it here. This will normalize all the instances in the pipeline. |
||
| """Return registered dataset implementations.""" | ||
| from judgearena.datasets import arena_hard, judgearena_tables | ||
|
|
||
| return ( | ||
| DatasetAdapter( | ||
| "judgearena_tables", | ||
| judgearena_tables.download_task_sources, | ||
| judgearena_tables.load_task_instructions, | ||
| judgearena_tables.load_task_model_outputs, | ||
| ), | ||
| DatasetAdapter( | ||
| "arena_hard", | ||
| arena_hard.download_task_sources, | ||
| arena_hard.load_task_instructions, | ||
| arena_hard.load_task_model_outputs, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def resolve_dataset_adapter(name: str) -> DatasetAdapter: | ||
| """Return the implementation registered under ``name``.""" | ||
| for adapter in dataset_adapters(): | ||
| if adapter.name == name: | ||
| return adapter | ||
| raise ValueError(f"Unknown task dataset adapter {name!r}.") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| schema_version: 1 | ||
| task_version: 1 | ||
| tags: [pairwise, instruction-following, arena-hard] | ||
|
|
||
| dataset: | ||
| adapter: arena_hard | ||
| sources: | ||
| examples: | ||
| type: huggingface_dataset | ||
| repo_id: lmarena-ai/arena-hard-auto | ||
| revision: "15f3746e21432264ce9b453999bde4f3c946d2e6" | ||
| fields: | ||
| id: instruction_index | ||
| instruction: instruction | ||
|
|
||
| protocol: | ||
| runner: pairwise | ||
| generation: | ||
| mode: single_turn_chat | ||
| judge: | ||
| default_prompt: default | ||
| parser: pairwise_preference | ||
| default_swap_mode: fixed | ||
| allowed_swap_modes: [fixed, both] | ||
| scoring: | ||
| adapter: pairwise_win_rate | ||
| primary_metric: winrate | ||
| higher_is_better: true | ||
|
|
||
| metadata: | ||
| reference_implementation: https://github.com/lmarena/arena-hard-auto |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| extends: _base.yaml | ||
| task: arena-hard-v0.1 | ||
| description: Pairwise evaluation on Arena-Hard v0.1. | ||
|
|
||
| dataset: | ||
| sources: | ||
| examples: | ||
| config: arena-hard-v0.1 | ||
| allow_patterns: | ||
| - data/arena-hard-v0.1/question.jsonl | ||
| - data/arena-hard-v0.1/model_answer/*.jsonl | ||
|
|
||
| protocol: | ||
| baseline: | ||
| strategy: task_default | ||
| reference_id: gpt-4-0314 | ||
| allow_runtime_override: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| extends: _base.yaml | ||
| task: arena-hard-v2.0 | ||
| description: Pairwise evaluation on Arena-Hard v2.0. | ||
|
|
||
| dataset: | ||
| sources: | ||
| examples: | ||
| config: arena-hard-v2.0 | ||
| allow_patterns: | ||
| - data/arena-hard-v2.0/question.jsonl | ||
| - data/arena-hard-v2.0/model_answer/*.jsonl | ||
| fields: | ||
| category: category | ||
|
|
||
| protocol: | ||
| baseline: | ||
| strategy: category_defaults | ||
| category_field: category | ||
| references: | ||
| hard_prompt: o3-mini-2025-01-31 | ||
| coding: o3-mini-2025-01-31 | ||
| math: o3-mini-2025-01-31 | ||
| creative_writing: gemini-2.0-flash-001 | ||
| allow_runtime_override: true |
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.
Note: we have this because we are adding tasks one-by-one and don't want to break the old pipeline.