Skip to content

MT-Lens v2: upgrade to lm-evaluation-harness v0.4.13 and a two-environment evaluation pipeline - #5

Merged
xixianliao merged 635 commits into
langtech-bsc:mainfrom
xixianliao:main
Oct 1, 2026
Merged

xixianliao merged 635 commits into
langtech-bsc:mainfrom
xixianliao:main

Conversation

@xixianliao

Copy link
Copy Markdown

Summary

This PR updates MT-Lens to the current release of EleutherAI's lm-evaluation-harness (v0.4.13), so that newer model architectures (e.g. Gemma 4, which needs Transformers 5) can be evaluated. The previous version is kept on the v1 branch.

Main changes

  • Upgrade to lm-evaluation-harness v0.4.13 with Transformers 5 support. The MT-specific code is kept as a small layer on top of upstream.
  • Two-environment pipeline (scripts/run_mt.sh): translations are generated with Transformers 5, and the neural metrics (COMET, COMET-Kiwi, BLEURT, MetricX) are computed in a separate Transformers 4 environment. The metric implementations are unchanged. Both environments are pinned (requirements-generation-v5.txt, requirements-neural-v4.txt).
  • Fixes found while validating the new version, among them: misaligned Aranese source sentences in the FLORES+ devtest data, garbage output for T5-based models (madlad400) with Transformers 5, Japanese/Korean/Chinese tokenization for BLEU and TER, and segment-level chrF ignoring the metric configuration.
  • README updated with the new installation and usage.

Validation

  • MT scores are consistent with the previous version.
  • Standard lm-eval tasks give the same scores as unmodified upstream v0.4.13.
  • The hf, nllb, vLLM, GGUF, fairseq/CTranslate2 and simplegenerator backends, and the HolisticBias, MMHB, MT-GenEval and perturbation tasks, were run end to end.

HallerPatrick and others added 30 commits December 15, 2025 16:18
* Adding  task based on the PisaBench benchmark

* Update `tasks` README with `pisa` task

* Fixing formatting for pre-commit hook

* Renamed template.yaml to template_yaml, adjusted includes in tasks
…utherAI#3305)

* adding slr_bench tasks

* extend the readme file

* add to readme; pacify pre-commit

---------

Co-authored-by: Baber <baber@hey.com>
…erAI#3472)

* fix `log_experiment_args` bug in evaluate. see EleutherAI#3466; update docstrings
* Update version to `0.4.5.dev0`

* 0.4.10

* only set version in pyproject

* add numpy to deps

---------

Co-authored-by: Baber <baber@hey.com>
Fixes EleutherAI#3452

When answer is an integer index into choices, a=0 should be treated as
a valid answer, not as falsy. Previously, the condition 'if a and not
gen_prefix' incorrectly treated a=0 as falsy, causing the target_delimiter
to be skipped for few-shot examples where the answer was the first choice.

This caused inconsistent formatting:
- Few-shot examples: 'Answer:A' (no space)
- Model predictions: ' A' (with leading space from target_delimiter)

The fix explicitly checks 'a is not None and a != ""' instead of
relying on truthiness.

Added regression tests for answer index 0 and non-zero cases.
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
* OpenAI Multilingual MMLU

* Remove Marin Custom Metrics

* Remove Marin Custom Metrics
* Add IFEval multilingual with Spanish and Catalan tasks

* Add ifeval_{es,ca} to tasks README
* brief description of the task

* Update README.md

fix

* new datasets piQA, boolQA, openbookQA, commonsenseQA added

---------

Co-authored-by: Baber Abbasi <92168766+baberabb@users.noreply.github.com>
* fix sglang namespace

* nit: duplicate task

* rm `truthfulqa_va` tag as its already a task name
* task yaml configuration added

1. The configuration file is copied from gsm8k and made initial edit.

* New task: ULQA

1. The YAML configuration for ulqa is added.

* celep1/2, uleval, ulqa

1. The task configuration files are added and tested.

* Update ulqa.yaml

1. generation_kwargs arguments are updated.

* Update ulqa.yaml

1. More evaluation matrics are added.

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update ulqa.yaml

* Update celep2.yaml

* Huggingface Dataset Path Updated.

* lambada_uyghur task added

* lambada_uyghur task config updated

* Update lambada_uyghur.yaml

* Update lambada_uyghur.yaml

* Update lambada_uyghur.yaml

* lambada Uyghur test

* lambada Uyghur test

* lambada Uyghur test

* lambada Uyghur test

* lambada Uyghur working version

* ulut task added

* ulut task debugged

* ulut task debugged

* ulut task debugged

* ulut sub-task names updated

* ulut sub-task nug config updated

* ulut sub-task nug config updated

* ulut task config files debugged

* ulut task group added

* ulut task group debugged

* ulut task group debugged

* ulut task group debugged

* ulut task group debugged

* ulut task group debugged

* All sub-tasks are converted to multiple choise questions.

* All sub-tasks are converted to multiple choise questions.

* tag added to ulut.yaml

* Update README.md

added ulqa to task list

* added README file

* Update README.md

* Update README.md

* Update README.md

* all Uyghur tasks are merged

* ulqa task updated

* ulqa task updated

* ulut doc_to_decontamination_query value added

* doc_to_decontamination_query added to more tasks in ulqa

* metrics bleu and chrf removed from generative tasks in ulqa

* Resolve merge conflict: keep ULQA benchmark entry

* fix parsing bug

* rm `ulut` tag as its already a group name

---------

Co-authored-by: Baber <baber@hey.com>
* fix off by max_length error; fix type hints

* mock ray, vllm

* add test
…leutherAI#3465)

* Fix MGSM generation kwargs in IberoBench languages

* Generation should only stop at </s>, <|im_end|> and the question
  string
* Remove criteria to stop on line breaks as it cuts off generation when
  the model adds a line break gefore the answer
* Remove temperature argument as is not compatible with do_sample=false

* rename mgsm_native_cot_eu yaml to match task name

* update changelogs and version numbers

* update catalan_bench.yaml version
…sks (EleutherAI#3508)

* test `construct_requests` in test_prompt

* add delimiter in gen_prefix
* Update `utils.py` for the LIBRA task

Instead of the outdated pymorphy2 library, it is proposed to use pymorphy3.

* Update vllm_causallms.py

Fix the bug `TypeError: Unexpected keyword argument 'max_gen_toks'` in the vllm_causalllms.py module.
* use full paths

* update qa4mre
…erAI#3509)

* vllm: set temp=0 when do_sample=False

* fix

* add gen_kwarg utility

* vllm standardize gen_kwargs

* add truncation utility

* fix. add tests

* fix. add tests

* fix!

* nit

* always require `do_sample`

* use gen_kwarg utility in HF

* add defaults

* nits

* fix: update generation kwargs handling and improve max token extraction logic

* pacify pre-commit

* fix

* default batch auto

* handle huggingface max_length

* add tests

* update docs
- requirements-neural-v4.txt: re-freeze venv-neural-v4, which now includes
  the MeCab tokenizers for ja/ko BLEU, and install the project with -e .
- README: the neural env also runs the full evaluation for simplegenerator,
  gguf and fairseq/ctranslate models
Keep the original README and add only the two-environment install commands,
which backend runs where, and MT_MODELS_DIR.
The HF helpers moved to lm_eval.models.utils_hf and the rolling-window
helpers to lm_eval.utils, so importing the backend failed.
The Streamlit app reads results_summary/results_summary.csv, which this
script builds; the generated CSV stays untracked.
datasets 3.x asks before running a local loader script and fails in batch
jobs, so every task backed by data/ broke on a fresh HF cache. Pass
trust_remote_code=True when the path resolves to one of these scripts.
Transformers 5 rejects load_in_8bit/load_in_4bit in from_pretrained, and
nllb.py passed them even when unused. Pass quantization through
BitsAndBytesConfig only when requested, and use dtype/torch_dtype by
version as the HF backend does.
The metrics sliced the outputs at fixed offsets of 1012 segments, so any
subset crashed with an IndexError. Derive the block size from the number of
outputs (15 equal blocks), which is unchanged on the full set, and fail with
a clear message when the blocks are uneven, e.g. under --limit.
On a subset (e.g. --limit) one of the masculine/feminine/generic groups can
have no segments, which crashed the task with a ZeroDivisionError. Report no
score for that group instead.
chrf_segments and the MMHB per-gender chrF used sacrebleu defaults instead of
the chrf entry in mt_metrics_config.yaml, unlike corpus chrF. With the current
config (the sacrebleu defaults) scores are unchanged; MMHB segment scores are
no longer rounded to two decimals.
HFLM called model.tie_weights() after from_pretrained. Transformers 5 reads
tie_word_embeddings as True for untied T5 checkpoints such as madlad400, so
this replaced the LM head with the input embeddings and every translation
came out as repeated garbage (BLEU 0). from_pretrained already handles tying
in Transformers 5, so only re-tie on older versions; same for nllb.
HolisticBias, MMHB and perturbations compute their own metrics and do not
write the arrays neural_scoring reads, so the two-stage pipeline failed on
them (and the old *holistic* guard never matched their task names). Detect
them from --tasks and run generation plus all metrics in METRIC_PYTHON.
lm-eval 0.4.13 adds a stderr entry ("N/A") to every metric, so the BSC check
that skipped list values (segment scores, sources, translations) never ran
and whole lists were printed. Every row was padded to the longest cell, which
made logs tens of MB. Skip list values regardless of stderr; the JSON output
is unchanged.
Bring back results/nllb_3.3B, results/madlad400_3B and
results_summary/results_summary.csv from langtech-bsc main so the Streamlit
app has data to show; other results stay untracked.
- say how the hf examples map to run_mt_v3.sh and that HolisticBias, MMHB and
  perturbations run in venv-neural-v4
- update model names (anthropic-completions, nemo_lm; drop deepsparse,
  sparseml and duplicates) and the flores+ dev / ntrex language counts
- fix the Tatoeba task-name format and the vllm example
- describe how to pack the MMHB data and list the fields MMHB actually outputs
- drop the empty "Adding new MT-datasets" section
mt_task logged to "lm-eval", which lm-eval 0.4.13 does not configure, so its
INFO messages (e.g. which CJK tokenizer is used) never appeared.
The scoring stage only reported where it saved the file, so the log never
showed COMET, BLEURT or MetricX. Print every scalar metric of each scored
task once the file is written.
In the two-stage pipeline the generation stage printed a table with only the
surface metrics. Skip that table when neural metrics are deferred and have
neural_scoring.score print the usual table with all metrics once.
MT tasks declared every metric as higher-is-better, so TER showed an up arrow
in the results table. TER and MetricX (and their segment scores) are error
scores.
Restore the file modes of the unchanged datasets (only the permissions had
changed) and drop the bouquet_paragraph task and data, which are not part of
this update. flores+_devtest keeps the corrected Aranese data and the added
lld_Latn and srp_Latn.
Remove the 22 task modules (aapp, act, alia, tacon, wmt24pp, tier1_holdout,
...) together with their dataset_paths entries and their imports in
lm_eval/tasks/__init__.py, which still imported the bouquet_paragraph task
removed earlier and broke importing lm_eval.tasks. The task registry and
dataset_paths now match v1.
The srp_Latn data and the 'sh' -> srp_Latn mapping were already there but
'sh' was missing from the language list, so no sh_* task existed.
The hf backend appended "\n" and "\n\n" to the stop sequences of every task.
That is right for single-line translations, but it cut the multi-line answers
of other lm-eval generation tasks at the first newline (GSM8K, first 100 docs,
Qwen2.5-1.5B-Instruct: 0.00/0.21 instead of upstream's 0.34/0.50). Apply them
only to requests of tasks registered as MTask; a task passing until=[] still
opts out. MT outputs are unchanged.
Replace the loose constraints with the full pip freeze of the environment
used for the v3 runs (Python 3.12, transformers 5.17.0, torch 2.13.0), with
the project installed through "-e .". README installs from the file alone.
atomic_write used mkstemp, which creates the file with mode 0600 regardless
of the umask, so scored result files in a shared directory were readable
only by whoever ran the scoring. Apply the umask-based mode before replacing.
The evaluation entry point does not need a version in its name; update the
README and the SLURM example accordingly.
With fetch-depth 2 the changed-files step cannot find the merge base of a pull
request with many commits and the job fails before testing anything.
It was removed in an earlier cleanup, but .pre-commit-config.yaml passes it to
codespell, which then fails to start. Same content as upstream v0.4.13.
@xixianliao
xixianliao marked this pull request as ready for review October 1, 2026 10:19
@xixianliao
xixianliao merged commit e68a107 into langtech-bsc:main Oct 1, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.