Skip to content

Share the long-context task base, class factory and JSONL/hub helpers between RULER and HELMET #454

Open

Description

@jopetty

Follow-up to the review of #281. The HELMET port copied a lot of RULER's structure. Today a fix to one copy has to be made by hand in the other, and the copies have already drifted: RULER stops on four newline tokens, while HELMET stops on one. This issue tracks merging the shared code so each fix lands in one place.

Everything below depends on #281 merging first, because that's where the HELMET code lives.

Main items

  1. One long-context task base. In evals/tasks/helmet.py, HelmetTask copies RulerTask from evals/tasks/ruler.py nearly line for line: __init__, template loading, instances, the metadata skeleton, format_request, request_type and extract_answer. Move this to a shared base in evals/tasks/common/ and make both tasks subclasses of it.
  2. One task factory. _make_ruler_task_class and _make_helmet_task_class are copies, docstrings included, and both register their classes through type(...) plus globals() injection. Replace them with one registry helper that registers a single class with partial configuration, following the review guide. The stop-sequence drift goes away once there is a single factory.
  3. Shared JSONL and Hub helpers.
    • _load_jsonl is defined in data/ruler_loader.py, data/helmet_loader.py, data/helmet_kilt_loader.py and data/helmet_msmarco_loader.py.
    • The hf_hub_download wrapper with silent_tqdm is copied between ruler_loader.py and helmet_loader.py.
    • Move these, along with the generic sample_jsonl_rows and sample_jsonl_by_key, into data/jsonl.py, plus a Hub-download helper whose revision argument is required.

Smaller items in the same area

  1. Truncation helpers. _load_reference_tokenizer and _truncate_context are private names in helmet_infbench_loader.py, but four loaders import them. Move them into a shared HELMET module under public names.
  2. Metric classes. NDCGMetric, RougeLF1Metric and RougeLRecallMetric re-implement AccuracyMetric.compute. Use AccuracyMetric(name=..., scorer=...) instead.
  3. ROUGE scorers. RougeLF1Scorer and RougeLRecallScorer differ only in which score they read, so they could be one scorer with a field.
  4. RULER's QA scorer. RulerQAScorer and ruler._normalize_answer duplicate SubstringExactMatchScorer and _squad_normalize_answer. Have RULER use the shared scorer, and make _squad_normalize_answer public, since three other modules already import it.
  5. Gold-answer lookup. The "all_gold_answers, else gold_answer, wrapped in a list" logic appears about seven times. Make one helper.
  6. Placement. The HELMET-specific scorers (helmet_judge.py, helmet_summ_prompts.py and alce.py) belong next to the task in an evals/tasks/helmet/ package. In the other direction, HelmetExactMatchScorer belongs in common/scorers, and parse_rankings belongs with output parsing rather than in a data loader.
  7. HELMET task subclasses. The HELMET subclasses differ only in which loader they call. Give each HELMET_TASKS entry a loader and loader_kwargs instead, which also replaces the key-by-key copying in _generate_helmet_tasks.

Constraints

  • Task hashes. Items 1, 2 and 7 touch RULER, and parts of the RULER configuration are serialized into the task hash (stop sequences, metrics). Either keep RULER's hashes unchanged or document the change, as Resolve named primary metrics to their Metric instance #453 does.
  • RULER prompts. RULER renders the prebuilt input field from its data files. HELMET's RULER recall tasks render from templates and fields, putting the answer prefix on its own line where input has a space. The shared base needs to keep both behaviors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions