Repository navigation
Add longbench-v2 benchmark (data-only) - #1159
Merged
gwarmstrong merged 4 commits intoApr 28, 2026
Merged
gwarmstrong merged 4 commits into
gwarmstrong merged 4 commits into
Conversation
Migrates LongBench v2 (THUDM/LongBench-v2, 503 long-context MCQ questions) from NeMo Skills as a data-only port on top of the existing `mcqa` resource server. No new servers or agents. `prepare.py` mirrors `nemo_skills/dataset/longbench-v2/prepare.py`: same HuggingFace dataset, same fields preserved (`index`, `context`, `question`, `choice_A..D`, `expected_answer`, `domain`, `sub_domain`, `difficulty`, `length`, `context_tokens` via tiktoken `cl100k_base`), plus `options` and `grading_mode` consumed by the `mcqa` server. Signed-off-by: gwarmstrong <gwarmstrong@users.noreply.github.com>
LongBench-v2 contexts contain raw `<|endoftext|>` strings (verbatim text inside long-document corpora) that tiktoken refuses to encode by default. Pass `disallowed_special=()` so the tokenizer treats them as plain text; we only need a length, not a faithful token id sequence. Signed-off-by: gwarmstrong <gwarmstrong@users.noreply.github.com>
Two fixes addressing PR review feedback: - resources_servers/mcqa/requirements.txt: add tiktoken so benchmarks/longbench_v2/prepare.py (which uses cl100k_base for context_tokens) works in the per-server venv. Matches mrcr's pattern. - benchmarks/longbench_v2/README.md: add the missing +prompt_config=benchmarks/longbench_v2/prompts/default.yaml override to the ng_collect_rollouts block; without it the command fails with KeyError: 'responses_create_params' because no template gets applied to the prepared rows. Signed-off-by: gwarmstrong <gwarmstrong@users.noreply.github.com>
gwarmstrong
enabled auto-merge (squash)
April 28, 2026 21:36
cmunley1
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One-sentence summary
Migrates the
longbench-v2benchmark (THUDM/LongBench-v2, 503long-context MCQ questions) from NeMo Skills into Gym on top of the
existing
mcqaresource server. No new servers or agents, nometric-infra changes. Scope is deliberately data-prep-only: the new
prepare.pymirrors the Skills prepare method and the final file isvalidated against Skills' output for every row.
Includes
benchmarks/longbench_v2/β full LongBench-v2 test splitTHUDM/LongBench-v2(HuggingFace, singletrainsplitholding all 503 evaluation questions) β identical upstream dataset
to Skills'
nemo_skills/dataset/longbench-v2/prepare.pysingle-doc QA, multi-doc QA, long in-context learning, long-dialogue
history, code-repo understanding, long structured data
mcqaresource server (no server changes);prepare.pyemits the standard mcqaoptionslist andgrading_mode: strict_single_letter_boxedbenchmarks/longbench_v2/prompts/default.yamlβ character-for-characterport of
nemo_skills/prompt/config/eval/longbench/default.yaml(single user message, CoT-style, ends with
Answer: \boxed{A/B/C/D})Tiktoken
<|endoftext|>handlingLongBench-v2 contexts contain raw
<|endoftext|>strings as plain textinside long-document corpora. tiktoken refuses to encode them by
default. Both Skills' upstream
prepare.py(when run unpatched) and anearlier draft of this Gym
prepare.pyaborted on these rows. The fix(commit
a4bd3e8eon this branch) passesdisallowed_special=()sothe count is computed treating the literals as ordinary text β we only
need a length, not a faithful token-id sequence. The same patch is
applied on the Skills side in the parity-check recipe so both sides
are exercised symmetrically.
Validated against NeMo Skills
Scope is data-prep parity only. This PR does not include rollout or
metrics-parity numbers (no model runs were made). The new
prepare()output is compared row-by-row against Skills'prepare.pyoutput. Every Skills field is identical on every row:
Per-field equality on the 13 Skills fields (
index,context,question,choice_A..D,expected_answer,domain,sub_domain,difficulty,length,context_tokens):value_diff=0on all 503rows. Expected-answer agreement: 503 / 503. Normalized-question overlap:
100 % (15 questions repeat verbatim across different long contexts in
the upstream dataset, hence 488 unique normalized questions for 503
rows). Gym's
optionslist matcheschoice_A..Don all 503 rows.Grader-mode note
Skills'
eval_mcqruns two extraction passes: try\boxed{}first,fall back to
(?i)Answer\s*:\s*([A-Z]). The mcqa resource serverexposes either pass independently (
strict_single_letter_boxedorlenient_answer_colon) but not the combined fallback. Since theprompt explicitly instructs the model to emit
Answer: \boxed{X}, theboxed pass catches the dominant case and
strict_single_letter_boxed(the mcqa default and the convention used by every other mcqa-backed
Gym benchmark) is used here. This is a property of the existing mcqa
server and is out of scope for this data-only PR β if a future Skills-vs-Gym
end-to-end check shows a
no_answergap larger than ~2 pp, it wouldbe addressed inside
mcqa(e.g. by adding alenient_boxed_then_answer_colonmode), not by re-doing this data port.