chen459664 commited on
Commit
77a82b1
·
verified ·
1 Parent(s): 23c1e16

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. lm-evaluation-harness/lm_eval.egg-info/PKG-INFO +787 -0
  2. lm-evaluation-harness/lm_eval.egg-info/dependency_links.txt +1 -0
  3. lm-evaluation-harness/lm_eval.egg-info/entry_points.txt +3 -0
  4. lm-evaluation-harness/lm_eval/tasks/xcopa/default_sw.yaml +4 -0
  5. lm-evaluation-harness/lm_eval/tasks/xnli/README.md +78 -0
  6. lm-evaluation-harness/lm_eval/tasks/xnli/utils.py +166 -0
  7. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_common_yaml +18 -0
  8. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_en.yaml +7 -0
  9. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_es.yaml +7 -0
  10. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_fr.yaml +7 -0
  11. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_ru.yaml +7 -0
  12. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_th.yaml +7 -0
  13. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_tr.yaml +7 -0
  14. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_vi.yaml +7 -0
  15. lm-evaluation-harness/lm_eval/tasks/xnli/xnli_zh.yaml +7 -0
  16. lm-evaluation-harness/lm_eval/tasks/xnli_eu/README.md +50 -0
  17. lm-evaluation-harness/lm_eval/tasks/xnli_eu/xnli_common_yaml +15 -0
  18. lm-evaluation-harness/lm_eval/tasks/xquad/README.md +62 -0
  19. lm-evaluation-harness/lm_eval/tasks/xquad/utils.py +15 -0
  20. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_ar.yaml +4 -0
  21. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_common_yaml +27 -0
  22. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_de.yaml +4 -0
  23. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_el.yaml +4 -0
  24. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_en.yaml +4 -0
  25. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_es.yaml +4 -0
  26. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_hi.yaml +4 -0
  27. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_ro.yaml +4 -0
  28. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_ru.yaml +4 -0
  29. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_th.yaml +4 -0
  30. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_tr.yaml +4 -0
  31. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_vi.yaml +4 -0
  32. lm-evaluation-harness/lm_eval/tasks/xquad/xquad_zh.yaml +4 -0
  33. lm-evaluation-harness/lm_eval/tasks/xstorycloze/README.md +84 -0
  34. lm-evaluation-harness/lm_eval/tasks/xstorycloze/_xstorycloze.yaml +19 -0
  35. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_ar.yaml +17 -0
  36. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_en.yaml +3 -0
  37. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_es.yaml +3 -0
  38. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_eu.yaml +3 -0
  39. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_hi.yaml +3 -0
  40. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_id.yaml +3 -0
  41. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_my.yaml +3 -0
  42. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_ru.yaml +3 -0
  43. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_sw.yaml +3 -0
  44. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_te.yaml +3 -0
  45. lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_zh.yaml +3 -0
  46. lm-evaluation-harness/lm_eval/tasks/xwinograd/README.md +61 -0
  47. lm-evaluation-harness/lm_eval/tasks/xwinograd/_xwinograd.yaml +14 -0
  48. lm-evaluation-harness/lm_eval/tasks/xwinograd/utils.py +94 -0
  49. lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_common_yaml +18 -0
  50. lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_en.yaml +4 -0
lm-evaluation-harness/lm_eval.egg-info/PKG-INFO ADDED
@@ -0,0 +1,787 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: lm_eval
3
+ Version: 0.4.8
4
+ Summary: A framework for evaluating language models
5
+ Author-email: EleutherAI <contact@eleuther.ai>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/EleutherAI/lm-evaluation-harness
8
+ Project-URL: Repository, https://github.com/EleutherAI/lm-evaluation-harness
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE.md
16
+ Requires-Dist: accelerate>=0.26.0
17
+ Requires-Dist: evaluate
18
+ Requires-Dist: datasets>=2.16.0
19
+ Requires-Dist: evaluate>=0.4.0
20
+ Requires-Dist: jsonlines
21
+ Requires-Dist: numexpr
22
+ Requires-Dist: peft>=0.2.0
23
+ Requires-Dist: pybind11>=2.6.2
24
+ Requires-Dist: pytablewriter
25
+ Requires-Dist: rouge-score>=0.0.4
26
+ Requires-Dist: sacrebleu>=1.5.0
27
+ Requires-Dist: scikit-learn>=0.24.1
28
+ Requires-Dist: sqlitedict
29
+ Requires-Dist: torch>=1.8
30
+ Requires-Dist: tqdm-multiprocess
31
+ Requires-Dist: transformers>=4.1
32
+ Requires-Dist: zstandard
33
+ Requires-Dist: dill
34
+ Requires-Dist: word2number
35
+ Requires-Dist: more_itertools
36
+ Provides-Extra: acpbench
37
+ Requires-Dist: lark>=1.1.9; extra == "acpbench"
38
+ Requires-Dist: tarski[clingo]==0.8.2; extra == "acpbench"
39
+ Requires-Dist: pddl==0.4.2; extra == "acpbench"
40
+ Requires-Dist: kstar-planner==1.4.2; extra == "acpbench"
41
+ Provides-Extra: api
42
+ Requires-Dist: requests; extra == "api"
43
+ Requires-Dist: aiohttp; extra == "api"
44
+ Requires-Dist: tenacity; extra == "api"
45
+ Requires-Dist: tqdm; extra == "api"
46
+ Requires-Dist: tiktoken; extra == "api"
47
+ Provides-Extra: audiolm-qwen
48
+ Requires-Dist: librosa; extra == "audiolm-qwen"
49
+ Requires-Dist: soundfile; extra == "audiolm-qwen"
50
+ Provides-Extra: deepsparse
51
+ Requires-Dist: deepsparse-nightly[llm]>=1.8.0.20240404; extra == "deepsparse"
52
+ Provides-Extra: dev
53
+ Requires-Dist: pytest; extra == "dev"
54
+ Requires-Dist: pytest-cov; extra == "dev"
55
+ Requires-Dist: pytest-xdist; extra == "dev"
56
+ Requires-Dist: pre-commit; extra == "dev"
57
+ Requires-Dist: mypy; extra == "dev"
58
+ Requires-Dist: unitxt==1.22.0; extra == "dev"
59
+ Requires-Dist: requests; extra == "dev"
60
+ Requires-Dist: aiohttp; extra == "dev"
61
+ Requires-Dist: tenacity; extra == "dev"
62
+ Requires-Dist: tqdm; extra == "dev"
63
+ Requires-Dist: tiktoken; extra == "dev"
64
+ Requires-Dist: sentencepiece; extra == "dev"
65
+ Provides-Extra: gptq
66
+ Requires-Dist: auto-gptq[triton]>=0.6.0; extra == "gptq"
67
+ Provides-Extra: gptqmodel
68
+ Requires-Dist: gptqmodel>=1.0.9; extra == "gptqmodel"
69
+ Provides-Extra: hf-transfer
70
+ Requires-Dist: hf_transfer; extra == "hf-transfer"
71
+ Provides-Extra: ibm-watsonx-ai
72
+ Requires-Dist: ibm_watsonx_ai>=1.1.22; extra == "ibm-watsonx-ai"
73
+ Requires-Dist: python-dotenv; extra == "ibm-watsonx-ai"
74
+ Provides-Extra: ifeval
75
+ Requires-Dist: langdetect; extra == "ifeval"
76
+ Requires-Dist: immutabledict; extra == "ifeval"
77
+ Requires-Dist: nltk>=3.9.1; extra == "ifeval"
78
+ Provides-Extra: ipex
79
+ Requires-Dist: optimum; extra == "ipex"
80
+ Provides-Extra: japanese-leaderboard
81
+ Requires-Dist: emoji==2.14.0; extra == "japanese-leaderboard"
82
+ Requires-Dist: neologdn==0.5.3; extra == "japanese-leaderboard"
83
+ Requires-Dist: fugashi[unidic-lite]; extra == "japanese-leaderboard"
84
+ Requires-Dist: rouge_score>=0.1.2; extra == "japanese-leaderboard"
85
+ Provides-Extra: longbench
86
+ Requires-Dist: jieba; extra == "longbench"
87
+ Requires-Dist: fuzzywuzzy; extra == "longbench"
88
+ Requires-Dist: rouge; extra == "longbench"
89
+ Provides-Extra: mamba
90
+ Requires-Dist: mamba_ssm; extra == "mamba"
91
+ Requires-Dist: causal-conv1d==1.0.2; extra == "mamba"
92
+ Requires-Dist: torch; extra == "mamba"
93
+ Provides-Extra: math
94
+ Requires-Dist: sympy>=1.12; extra == "math"
95
+ Requires-Dist: antlr4-python3-runtime==4.11; extra == "math"
96
+ Requires-Dist: math_verify[antlr4_11_0]; extra == "math"
97
+ Provides-Extra: multilingual
98
+ Requires-Dist: nagisa>=0.2.7; extra == "multilingual"
99
+ Requires-Dist: jieba>=0.42.1; extra == "multilingual"
100
+ Requires-Dist: pycountry; extra == "multilingual"
101
+ Provides-Extra: neuronx
102
+ Requires-Dist: optimum[neuronx]; extra == "neuronx"
103
+ Provides-Extra: optimum
104
+ Requires-Dist: optimum[openvino]; extra == "optimum"
105
+ Provides-Extra: promptsource
106
+ Requires-Dist: promptsource>=0.2.3; extra == "promptsource"
107
+ Provides-Extra: ruler
108
+ Requires-Dist: nltk; extra == "ruler"
109
+ Requires-Dist: wonderwords; extra == "ruler"
110
+ Requires-Dist: scipy; extra == "ruler"
111
+ Provides-Extra: sae-lens
112
+ Requires-Dist: sae_lens; extra == "sae-lens"
113
+ Provides-Extra: sentencepiece
114
+ Requires-Dist: sentencepiece>=0.1.98; extra == "sentencepiece"
115
+ Provides-Extra: sparseml
116
+ Requires-Dist: sparseml-nightly[llm]>=1.8.0.20240404; extra == "sparseml"
117
+ Provides-Extra: sparsify
118
+ Requires-Dist: sparsify; extra == "sparsify"
119
+ Provides-Extra: testing
120
+ Requires-Dist: pytest; extra == "testing"
121
+ Requires-Dist: pytest-cov; extra == "testing"
122
+ Requires-Dist: pytest-xdist; extra == "testing"
123
+ Provides-Extra: vllm
124
+ Requires-Dist: vllm>=0.4.2; extra == "vllm"
125
+ Provides-Extra: wandb
126
+ Requires-Dist: wandb>=0.16.3; extra == "wandb"
127
+ Requires-Dist: pandas; extra == "wandb"
128
+ Requires-Dist: numpy; extra == "wandb"
129
+ Provides-Extra: zeno
130
+ Requires-Dist: pandas; extra == "zeno"
131
+ Requires-Dist: zeno-client; extra == "zeno"
132
+ Provides-Extra: all
133
+ Requires-Dist: lm_eval[acpbench]; extra == "all"
134
+ Requires-Dist: lm_eval[api]; extra == "all"
135
+ Requires-Dist: lm_eval[audiolm_qwen]; extra == "all"
136
+ Requires-Dist: lm_eval[deepsparse]; extra == "all"
137
+ Requires-Dist: lm_eval[dev]; extra == "all"
138
+ Requires-Dist: lm_eval[gptq]; extra == "all"
139
+ Requires-Dist: lm_eval[gptqmodel]; extra == "all"
140
+ Requires-Dist: lm_eval[hf_transfer]; extra == "all"
141
+ Requires-Dist: lm_eval[ibm_watsonx_ai]; extra == "all"
142
+ Requires-Dist: lm_eval[ifeval]; extra == "all"
143
+ Requires-Dist: lm_eval[ipex]; extra == "all"
144
+ Requires-Dist: lm_eval[japanese_leaderboard]; extra == "all"
145
+ Requires-Dist: lm_eval[longbench]; extra == "all"
146
+ Requires-Dist: lm_eval[mamba]; extra == "all"
147
+ Requires-Dist: lm_eval[math]; extra == "all"
148
+ Requires-Dist: lm_eval[multilingual]; extra == "all"
149
+ Requires-Dist: lm_eval[neuronx]; extra == "all"
150
+ Requires-Dist: lm_eval[optimum]; extra == "all"
151
+ Requires-Dist: lm_eval[promptsource]; extra == "all"
152
+ Requires-Dist: lm_eval[ruler]; extra == "all"
153
+ Requires-Dist: lm_eval[sae_lens]; extra == "all"
154
+ Requires-Dist: lm_eval[sentencepiece]; extra == "all"
155
+ Requires-Dist: lm_eval[sparseml]; extra == "all"
156
+ Requires-Dist: lm_eval[sparsify]; extra == "all"
157
+ Requires-Dist: lm_eval[testing]; extra == "all"
158
+ Requires-Dist: lm_eval[vllm]; extra == "all"
159
+ Requires-Dist: lm_eval[wandb]; extra == "all"
160
+ Requires-Dist: lm_eval[zeno]; extra == "all"
161
+ Dynamic: license-file
162
+
163
+ # Language Model Evaluation Harness
164
+
165
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10256836.svg)](https://doi.org/10.5281/zenodo.10256836)
166
+
167
+ ---
168
+
169
+ ## Latest News 📣
170
+
171
+ - [2025/03] Added support for steering HF models!
172
+ - [2025/02] Added [SGLang](https://docs.sglang.ai/) support!
173
+ - [2024/09] We are prototyping allowing users of LM Evaluation Harness to create and evaluate on text+image multimodal input, text output tasks, and have just added the `hf-multimodal` and `vllm-vlm` model types and `mmmu` task as a prototype feature. We welcome users to try out this in-progress feature and stress-test it for themselves, and suggest they check out [`lmms-eval`](https://github.com/EvolvingLMMs-Lab/lmms-eval), a wonderful project originally forking off of the lm-evaluation-harness, for a broader range of multimodal tasks, models, and features.
174
+ - [2024/07] [API model](docs/API_guide.md) support has been updated and refactored, introducing support for batched and async requests, and making it significantly easier to customize and use for your own purposes. **To run Llama 405B, we recommend using VLLM's OpenAI-compliant API to host the model, and use the `local-completions` model type to evaluate the model.**
175
+ - [2024/07] New Open LLM Leaderboard tasks have been added ! You can find them under the [leaderboard](lm_eval/tasks/leaderboard/README.md) task group.
176
+
177
+ ---
178
+
179
+ ## Announcement
180
+
181
+ **A new v0.4.0 release of lm-evaluation-harness is available** !
182
+
183
+ New updates and features include:
184
+
185
+ - **New Open LLM Leaderboard tasks have been added ! You can find them under the [leaderboard](lm_eval/tasks/leaderboard/README.md) task group.**
186
+ - Internal refactoring
187
+ - Config-based task creation and configuration
188
+ - Easier import and sharing of externally-defined task config YAMLs
189
+ - Support for Jinja2 prompt design, easy modification of prompts + prompt imports from Promptsource
190
+ - More advanced configuration options, including output post-processing, answer extraction, and multiple LM generations per document, configurable fewshot settings, and more
191
+ - Speedups and new modeling libraries supported, including: faster data-parallel HF model usage, vLLM support, MPS support with HuggingFace, and more
192
+ - Logging and usability changes
193
+ - New tasks including CoT BIG-Bench-Hard, Belebele, user-defined task groupings, and more
194
+
195
+ Please see our updated documentation pages in `docs/` for more details.
196
+
197
+ Development will be continuing on the `main` branch, and we encourage you to give us feedback on what features are desired and how to improve the library further, or ask questions, either in issues or PRs on GitHub, or in the [EleutherAI discord](https://discord.gg/eleutherai)!
198
+
199
+ ---
200
+
201
+ ## Overview
202
+
203
+ This project provides a unified framework to test generative language models on a large number of different evaluation tasks.
204
+
205
+ **Features:**
206
+
207
+ - Over 60 standard academic benchmarks for LLMs, with hundreds of subtasks and variants implemented.
208
+ - Support for models loaded via [transformers](https://github.com/huggingface/transformers/) (including quantization via [GPTQModel](https://github.com/ModelCloud/GPTQModel) and [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ)), [GPT-NeoX](https://github.com/EleutherAI/gpt-neox), and [Megatron-DeepSpeed](https://github.com/microsoft/Megatron-DeepSpeed/), with a flexible tokenization-agnostic interface.
209
+ - Support for fast and memory-efficient inference with [vLLM](https://github.com/vllm-project/vllm).
210
+ - Support for commercial APIs including [OpenAI](https://openai.com), and [TextSynth](https://textsynth.com/).
211
+ - Support for evaluation on adapters (e.g. LoRA) supported in [HuggingFace's PEFT library](https://github.com/huggingface/peft).
212
+ - Support for local models and benchmarks.
213
+ - Evaluation with publicly available prompts ensures reproducibility and comparability between papers.
214
+ - Easy support for custom prompts and evaluation metrics.
215
+
216
+ The Language Model Evaluation Harness is the backend for 🤗 Hugging Face's popular [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard), has been used in [hundreds of papers](https://scholar.google.com/scholar?oi=bibs&hl=en&authuser=2&cites=15052937328817631261,4097184744846514103,1520777361382155671,17476825572045927382,18443729326628441434,14801318227356878622,7890865700763267262,12854182577605049984,15641002901115500560,5104500764547628290), and is used internally by dozens of organizations including NVIDIA, Cohere, BigScience, BigCode, Nous Research, and Mosaic ML.
217
+
218
+ ## Install
219
+
220
+ To install the `lm-eval` package from the github repository, run:
221
+
222
+ ```bash
223
+ git clone --depth 1 https://github.com/EleutherAI/lm-evaluation-harness
224
+ cd lm-evaluation-harness
225
+ pip install -e .
226
+ ```
227
+
228
+ We also provide a number of optional dependencies for extended functionality. A detailed table is available at the end of this document.
229
+
230
+ ## Basic Usage
231
+
232
+ ### User Guide
233
+
234
+ A user guide detailing the full list of supported arguments is provided [here](./docs/interface.md), and on the terminal by calling `lm_eval -h`. Alternatively, you can use `lm-eval` instead of `lm_eval`.
235
+
236
+ A list of supported tasks (or groupings of tasks) can be viewed with `lm-eval --tasks list`. Task descriptions and links to corresponding subfolders are provided [here](./lm_eval/tasks/README.md).
237
+
238
+ ### Hugging Face `transformers`
239
+
240
+ To evaluate a model hosted on the [HuggingFace Hub](https://huggingface.co/models) (e.g. GPT-J-6B) on `hellaswag` you can use the following command (this assumes you are using a CUDA-compatible GPU):
241
+
242
+ ```bash
243
+ lm_eval --model hf \
244
+ --model_args pretrained=EleutherAI/gpt-j-6B \
245
+ --tasks hellaswag \
246
+ --device cuda:0 \
247
+ --batch_size 8
248
+ ```
249
+
250
+ Additional arguments can be provided to the model constructor using the `--model_args` flag. Most notably, this supports the common practice of using the `revisions` feature on the Hub to store partially trained checkpoints, or to specify the datatype for running a model:
251
+
252
+ ```bash
253
+ lm_eval --model hf \
254
+ --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
255
+ --tasks lambada_openai,hellaswag \
256
+ --device cuda:0 \
257
+ --batch_size 8
258
+ ```
259
+
260
+ Models that are loaded via both `transformers.AutoModelForCausalLM` (autoregressive, decoder-only GPT style models) and `transformers.AutoModelForSeq2SeqLM` (such as encoder-decoder models like T5) in Huggingface are supported.
261
+
262
+ Batch size selection can be automated by setting the ```--batch_size``` flag to ```auto```. This will perform automatic detection of the largest batch size that will fit on your device. On tasks where there is a large difference between the longest and shortest example, it can be helpful to periodically recompute the largest batch size, to gain a further speedup. To do this, append ```:N``` to above flag to automatically recompute the largest batch size ```N``` times. For example, to recompute the batch size 4 times, the command would be:
263
+
264
+ ```bash
265
+ lm_eval --model hf \
266
+ --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
267
+ --tasks lambada_openai,hellaswag \
268
+ --device cuda:0 \
269
+ --batch_size auto:4
270
+ ```
271
+
272
+ > [!Note]
273
+ > Just like you can provide a local path to `transformers.AutoModel`, you can also provide a local path to `lm_eval` via `--model_args pretrained=/path/to/model`
274
+
275
+ #### Multi-GPU Evaluation with Hugging Face `accelerate`
276
+
277
+ We support three main ways of using Hugging Face's [accelerate 🚀](https://github.com/huggingface/accelerate) library for multi-GPU evaluation.
278
+
279
+ To perform *data-parallel evaluation* (where each GPU loads a **separate full copy** of the model), we leverage the `accelerate` launcher as follows:
280
+
281
+ ```bash
282
+ accelerate launch -m lm_eval --model hf \
283
+ --tasks lambada_openai,arc_easy \
284
+ --batch_size 16
285
+ ```
286
+
287
+ (or via `accelerate launch --no-python lm_eval`).
288
+
289
+ For cases where your model can fit on a single GPU, this allows you to evaluate on K GPUs K times faster than on one.
290
+
291
+ **WARNING**: This setup does not work with FSDP model sharding, so in `accelerate config` FSDP must be disabled, or the NO_SHARD FSDP option must be used.
292
+
293
+ The second way of using `accelerate` for multi-GPU evaluation is when your model is *too large to fit on a single GPU.*
294
+
295
+ In this setting, run the library *outside the `accelerate` launcher*, but passing `parallelize=True` to `--model_args` as follows:
296
+
297
+ ```bash
298
+ lm_eval --model hf \
299
+ --tasks lambada_openai,arc_easy \
300
+ --model_args parallelize=True \
301
+ --batch_size 16
302
+ ```
303
+
304
+ This means that your model's weights will be split across all available GPUs.
305
+
306
+ For more advanced users or even larger models, we allow for the following arguments when `parallelize=True` as well:
307
+
308
+ - `device_map_option`: How to split model weights across available GPUs. defaults to "auto".
309
+ - `max_memory_per_gpu`: the max GPU memory to use per GPU in loading the model.
310
+ - `max_cpu_memory`: the max amount of CPU memory to use when offloading the model weights to RAM.
311
+ - `offload_folder`: a folder where model weights will be offloaded to disk if needed.
312
+
313
+ The third option is to use both at the same time. This will allow you to take advantage of both data parallelism and model sharding, and is especially useful for models that are too large to fit on a single GPU.
314
+
315
+ ```bash
316
+ accelerate launch --multi_gpu --num_processes {nb_of_copies_of_your_model} \
317
+ -m lm_eval --model hf \
318
+ --tasks lambada_openai,arc_easy \
319
+ --model_args parallelize=True \
320
+ --batch_size 16
321
+ ```
322
+
323
+ To learn more about model parallelism and how to use it with the `accelerate` library, see the [accelerate documentation](https://huggingface.co/docs/transformers/v4.15.0/en/parallelism)
324
+
325
+ **Warning: We do not natively support multi-node evaluation using the `hf` model type! Please reference [our GPT-NeoX library integration](https://github.com/EleutherAI/gpt-neox/blob/main/eval.py) for an example of code in which a custom multi-machine evaluation script is written.**
326
+
327
+ **Note: we do not currently support multi-node evaluations natively, and advise using either an externally hosted server to run inference requests against, or creating a custom integration with your distributed framework [as is done for the GPT-NeoX library](https://github.com/EleutherAI/gpt-neox/blob/main/eval_tasks/eval_adapter.py).**
328
+
329
+ ### Steered Hugging Face `transformers` models
330
+
331
+ To evaluate a Hugging Face `transformers` model with steering vectors applied, specify the model type as `steered` and provide the path to either a PyTorch file containing pre-defined steering vectors, or a CSV file that specifies how to derive steering vectors from pretrained `sparsify` or `sae_lens` models (you will need to install the corresponding optional dependency for this method).
332
+
333
+ Specify pre-defined steering vectors:
334
+
335
+ ```python
336
+ import torch
337
+
338
+ steer_config = {
339
+ "layers.3": {
340
+ "steering_vector": torch.randn(1, 768),
341
+ "bias": torch.randn(1, 768),
342
+ "steering_coefficient": 1,
343
+ "action": "add"
344
+ },
345
+ }
346
+ torch.save(steer_config, "steer_config.pt")
347
+ ```
348
+
349
+ Specify derived steering vectors:
350
+
351
+ ```python
352
+ import pandas as pd
353
+
354
+ pd.DataFrame({
355
+ "loader": ["sparsify"],
356
+ "action": ["add"],
357
+ "sparse_model": ["EleutherAI/sae-pythia-70m-32k"],
358
+ "hookpoint": ["layers.3"],
359
+ "feature_index": [30],
360
+ "steering_coefficient": [10.0],
361
+ }).to_csv("steer_config.csv", index=False)
362
+ ```
363
+
364
+ Run the evaluation harness with steering vectors applied:
365
+
366
+ ```bash
367
+ lm_eval --model steered \
368
+ --model_args pretrained=EleutherAI/pythia-160m,steer_path=steer_config.pt \
369
+ --tasks lambada_openai,hellaswag \
370
+ --device cuda:0 \
371
+ --batch_size 8
372
+ ```
373
+
374
+ ### NVIDIA `nemo` models
375
+
376
+ [NVIDIA NeMo Framework](https://github.com/NVIDIA/NeMo) is a generative AI framework built for researchers and pytorch developers working on language models.
377
+
378
+ To evaluate a `nemo` model, start by installing NeMo following [the documentation](https://github.com/NVIDIA/NeMo?tab=readme-ov-file#installation). We highly recommended to use the NVIDIA PyTorch or NeMo container, especially if having issues installing Apex or any other dependencies (see [latest released containers](https://github.com/NVIDIA/NeMo/releases)). Please also install the lm evaluation harness library following the instructions in [the Install section](https://github.com/EleutherAI/lm-evaluation-harness/tree/main?tab=readme-ov-file#install).
379
+
380
+ NeMo models can be obtained through [NVIDIA NGC Catalog](https://catalog.ngc.nvidia.com/models) or in [NVIDIA's Hugging Face page](https://huggingface.co/nvidia). In [NVIDIA NeMo Framework](https://github.com/NVIDIA/NeMo/tree/main/scripts/nlp_language_modeling) there are conversion scripts to convert the `hf` checkpoints of popular models like llama, falcon, mixtral or mpt to `nemo`.
381
+
382
+ Run a `nemo` model on one GPU:
383
+
384
+ ```bash
385
+ lm_eval --model nemo_lm \
386
+ --model_args path=<path_to_nemo_model> \
387
+ --tasks hellaswag \
388
+ --batch_size 32
389
+ ```
390
+
391
+ It is recommended to unpack the `nemo` model to avoid the unpacking inside the docker container - it may overflow disk space. For that you can run:
392
+
393
+ ```bash
394
+ mkdir MY_MODEL
395
+ tar -xvf MY_MODEL.nemo -c MY_MODEL
396
+ ```
397
+
398
+ #### Multi-GPU evaluation with NVIDIA `nemo` models
399
+
400
+ By default, only one GPU is used. But we do support either data replication or tensor/pipeline parallelism during evaluation, on one node.
401
+
402
+ 1) To enable data replication, set the `model_args` of `devices` to the number of data replicas to run. For example, the command to run 8 data replicas over 8 GPUs is:
403
+
404
+ ```bash
405
+ torchrun --nproc-per-node=8 --no-python lm_eval \
406
+ --model nemo_lm \
407
+ --model_args path=<path_to_nemo_model>,devices=8 \
408
+ --tasks hellaswag \
409
+ --batch_size 32
410
+ ```
411
+
412
+ 1) To enable tensor and/or pipeline parallelism, set the `model_args` of `tensor_model_parallel_size` and/or `pipeline_model_parallel_size`. In addition, you also have to set up `devices` to be equal to the product of `tensor_model_parallel_size` and/or `pipeline_model_parallel_size`. For example, the command to use one node of 4 GPUs with tensor parallelism of 2 and pipeline parallelism of 2 is:
413
+
414
+ ```bash
415
+ torchrun --nproc-per-node=4 --no-python lm_eval \
416
+ --model nemo_lm \
417
+ --model_args path=<path_to_nemo_model>,devices=4,tensor_model_parallel_size=2,pipeline_model_parallel_size=2 \
418
+ --tasks hellaswag \
419
+ --batch_size 32
420
+ ```
421
+
422
+ Note that it is recommended to substitute the `python` command by `torchrun --nproc-per-node=<number of devices> --no-python` to facilitate loading the model into the GPUs. This is especially important for large checkpoints loaded into multiple GPUs.
423
+
424
+ Not supported yet: multi-node evaluation and combinations of data replication with tensor or pipeline parallelism.
425
+
426
+ #### Multi-GPU evaluation with OpenVINO models
427
+
428
+ Pipeline parallelism during evaluation is supported with OpenVINO models
429
+
430
+ To enable pipeline parallelism, set the `model_args` of `pipeline_parallel`. In addition, you also have to set up `device` to value `HETERO:<GPU index1>,<GPU index2>` for example `HETERO:GPU.1,GPU.0` For example, the command to use pipeline parallelism of 2 is:
431
+
432
+ ```bash
433
+ lm_eval --model openvino \
434
+ --tasks wikitext \
435
+ --model_args pretrained=<path_to_ov_model>,pipeline_parallel=True \
436
+ --device HETERO:GPU.1,GPU.0
437
+ ```
438
+
439
+ ### Tensor + Data Parallel and Optimized Inference with `vLLM`
440
+
441
+ We also support vLLM for faster inference on [supported model types](https://docs.vllm.ai/en/latest/models/supported_models.html), especially faster when splitting a model across multiple GPUs. For single-GPU or multi-GPU — tensor parallel, data parallel, or a combination of both — inference, for example:
442
+
443
+ ```bash
444
+ lm_eval --model vllm \
445
+ --model_args pretrained={model_name},tensor_parallel_size={GPUs_per_model},dtype=auto,gpu_memory_utilization=0.8,data_parallel_size={model_replicas} \
446
+ --tasks lambada_openai \
447
+ --batch_size auto
448
+ ```
449
+
450
+ To use vllm, do `pip install lm_eval[vllm]`. For a full list of supported vLLM configurations, please reference our [vLLM integration](https://github.com/EleutherAI/lm-evaluation-harness/blob/e74ec966556253fbe3d8ecba9de675c77c075bce/lm_eval/models/vllm_causallms.py) and the vLLM documentation.
451
+
452
+ vLLM occasionally differs in output from Huggingface. We treat Huggingface as the reference implementation, and provide a [script](./scripts/model_comparator.py) for checking the validity of vllm results against HF.
453
+
454
+ > [!Tip]
455
+ > For fastest performance, we recommend using `--batch_size auto` for vLLM whenever possible, to leverage its continuous batching functionality!
456
+
457
+ > [!Tip]
458
+ > Passing `max_model_len=4096` or some other reasonable default to vLLM through model args may cause speedups or prevent out-of-memory errors when trying to use auto batch size, such as for Mistral-7B-v0.1 which defaults to a maximum length of 32k.
459
+
460
+ ### Tensor + Data Parallel and Fast Offline Batching Inference with `SGLang`
461
+
462
+ We support SGLang for efficient offline batch inference. Its **[Fast Backend Runtime](https://docs.sglang.ai/index.html)** delivers high performance through optimized memory management and parallel processing techniques. Key features include tensor parallelism, continuous batching, and support for various quantization methods (FP8/INT4/AWQ/GPTQ).
463
+
464
+ To use SGLang as the evaluation backend, please **install it in advance** via SGLang documents [here](https://docs.sglang.ai/start/install.html#install-sglang).
465
+
466
+ > [!Tip]
467
+ > Due to the installing method of [`Flashinfer`](https://docs.flashinfer.ai/)-- a fast attention kernel library, we don't include the dependencies of `SGLang` within [pyproject.toml](pyproject.toml). Note that the `Flashinfer` also has some requirements on `torch` version.
468
+
469
+ SGLang's server arguments are slightly different from other backends, see [here](https://docs.sglang.ai/backend/server_arguments.html) for more information. We provide an example of the usage here:
470
+
471
+ ```bash
472
+ lm_eval --model sglang \
473
+ --model_args pretrained={model_name},dp_size={data_parallel_size},tp_size={tensor_parallel_size},dtype=auto \
474
+ --tasks gsm8k_cot \
475
+ --batch_size auto
476
+ ```
477
+
478
+ > [!Tip]
479
+ > When encountering out of memory (OOM) errors (especially for multiple-choice tasks), try these solutions:
480
+ >
481
+ > 1. Use a manual `batch_size`, rather than `auto`.
482
+ > 2. Lower KV cache pool memory usage by adjusting `mem_fraction_static` - Add to your model arguments for example `--model_args pretrained=...,mem_fraction_static=0.7`.
483
+ > 3. Increase tensor parallel size `tp_size` (if using multiple GPUs).
484
+
485
+ ### Model APIs and Inference Servers
486
+
487
+ Our library also supports the evaluation of models served via several commercial APIs, and we hope to implement support for the most commonly used performant local/self-hosted inference servers.
488
+
489
+ To call a hosted model, use:
490
+
491
+ ```bash
492
+ export OPENAI_API_KEY=YOUR_KEY_HERE
493
+ lm_eval --model openai-completions \
494
+ --model_args model=davinci-002 \
495
+ --tasks lambada_openai,hellaswag
496
+ ```
497
+
498
+ We also support using your own local inference server with servers that mirror the OpenAI Completions and ChatCompletions APIs.
499
+
500
+ ```bash
501
+ lm_eval --model local-completions --tasks gsm8k --model_args model=facebook/opt-125m,base_url=http://{yourip}:8000/v1/completions,num_concurrent=1,max_retries=3,tokenized_requests=False,batch_size=16
502
+ ```
503
+
504
+ Note that for externally hosted models, configs such as `--device` which relate to where to place a local model should not be used and do not function. Just like you can use `--model_args` to pass arbitrary arguments to the model constructor for local models, you can use it to pass arbitrary arguments to the model API for hosted models. See the documentation of the hosting service for information on what arguments they support.
505
+
506
+ | API or Inference Server | Implemented? | `--model <xxx>` name | Models supported: | Request Types: |
507
+ | --------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
508
+ | OpenAI Completions | :heavy_check_mark: | `openai-completions`, `local-completions` | All OpenAI Completions API models | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
509
+ | OpenAI ChatCompletions | :heavy_check_mark: | `openai-chat-completions`, `local-chat-completions` | [All ChatCompletions API models](https://platform.openai.com/docs/guides/gpt) | `generate_until` (no logprobs) |
510
+ | Anthropic | :heavy_check_mark: | `anthropic` | [Supported Anthropic Engines](https://docs.anthropic.com/claude/reference/selecting-a-model) | `generate_until` (no logprobs) |
511
+ | Anthropic Chat | :heavy_check_mark: | `anthropic-chat`, `anthropic-chat-completions` | [Supported Anthropic Engines](https://docs.anthropic.com/claude/docs/models-overview) | `generate_until` (no logprobs) |
512
+ | Textsynth | :heavy_check_mark: | `textsynth` | [All supported engines](https://textsynth.com/documentation.html#engines) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
513
+ | Cohere | [:hourglass: - blocked on Cohere API bug](https://github.com/EleutherAI/lm-evaluation-harness/pull/395) | N/A | [All `cohere.generate()` engines](https://docs.cohere.com/docs/models) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
514
+ | [Llama.cpp](https://github.com/ggerganov/llama.cpp) (via [llama-cpp-python](https://github.com/abetlen/llama-cpp-python)) | :heavy_check_mark: | `gguf`, `ggml` | [All models supported by llama.cpp](https://github.com/ggerganov/llama.cpp) | `generate_until`, `loglikelihood`, (perplexity evaluation not yet implemented) |
515
+ | vLLM | :heavy_check_mark: | `vllm` | [Most HF Causal Language Models](https://docs.vllm.ai/en/latest/models/supported_models.html) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
516
+ | Mamba | :heavy_check_mark: | `mamba_ssm` | [Mamba architecture Language Models via the `mamba_ssm` package](https://huggingface.co/state-spaces) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
517
+ | Huggingface Optimum (Causal LMs) | :heavy_check_mark: | `openvino` | Any decoder-only AutoModelForCausalLM converted with Huggingface Optimum into OpenVINO™ Intermediate Representation (IR) format | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
518
+ | Huggingface Optimum-intel IPEX (Causal LMs) | :heavy_check_mark: | `ipex` | Any decoder-only AutoModelForCausalLM | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
519
+ | Neuron via AWS Inf2 (Causal LMs) | :heavy_check_mark: | `neuronx` | Any decoder-only AutoModelForCausalLM supported to run on [huggingface-ami image for inferentia2](https://aws.amazon.com/marketplace/pp/prodview-gr3e6yiscria2) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
520
+ | [Neural Magic DeepSparse](https://github.com/neuralmagic/deepsparse) | :heavy_check_mark: | `deepsparse` | Any LM from [SparseZoo](https://sparsezoo.neuralmagic.com/) or on [HF Hub with the "deepsparse" tag](https://huggingface.co/models?other=deepsparse) | `generate_until`, `loglikelihood` |
521
+ | [Neural Magic SparseML](https://github.com/neuralmagic/sparseml) | :heavy_check_mark: | `sparseml` | Any decoder-only AutoModelForCausalLM from [SparseZoo](https://sparsezoo.neuralmagic.com/) or on [HF Hub](https://huggingface.co/neuralmagic). Especially useful for models with quantization like [`zoo:llama2-7b-gsm8k_llama2_pretrain-pruned60_quantized`](https://sparsezoo.neuralmagic.com/models/llama2-7b-gsm8k_llama2_pretrain-pruned60_quantized) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
522
+ | NVIDIA NeMo | :heavy_check_mark: | `nemo_lm` | [All supported models](https://docs.nvidia.com/nemo-framework/user-guide/24.09/nemotoolkit/core/core.html#nemo-models) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
523
+ | Watsonx.ai | :heavy_check_mark: | `watsonx_llm` | [Supported Watsonx.ai Engines](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx) | `generate_until` `loglikelihood` |
524
+ | [Your local inference server!](docs/API_guide.md) | :heavy_check_mark: | `local-completions` or `local-chat-completions` | Support for OpenAI API-compatible servers, with easy customization for other APIs. | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
525
+
526
+ Models which do not supply logits or logprobs can be used with tasks of type `generate_until` only, while local models, or APIs that supply logprobs/logits of their prompts, can be run on all task types: `generate_until`, `loglikelihood`, `loglikelihood_rolling`, and `multiple_choice`.
527
+
528
+ For more information on the different task `output_types` and model request types, see [our documentation](https://github.com/EleutherAI/lm-evaluation-harness/blob/main/docs/model_guide.md#interface).
529
+
530
+ > [!Note]
531
+ > For best performance with closed chat model APIs such as Anthropic Claude 3 and GPT-4, we recommend carefully looking at a few sample outputs using `--limit 10` first to confirm answer extraction and scoring on generative tasks is performing as expected. providing `system="<some system prompt here>"` within `--model_args` for anthropic-chat-completions, to instruct the model what format to respond in, may be useful.
532
+
533
+ ### Other Frameworks
534
+
535
+ A number of other libraries contain scripts for calling the eval harness through their library. These include [GPT-NeoX](https://github.com/EleutherAI/gpt-neox/blob/main/eval_tasks/eval_adapter.py), [Megatron-DeepSpeed](https://github.com/microsoft/Megatron-DeepSpeed/blob/main/examples/MoE/readme_evalharness.md), and [mesh-transformer-jax](https://github.com/kingoflolz/mesh-transformer-jax/blob/master/eval_harness.py).
536
+
537
+ To create your own custom integration you can follow instructions from [this tutorial](https://github.com/EleutherAI/lm-evaluation-harness/blob/main/docs/interface.md#external-library-usage).
538
+
539
+ ### Additional Features
540
+
541
+ > [!Note]
542
+ > For tasks unsuitable for direct evaluation — either due risks associated with executing untrusted code or complexities in the evaluation process — the `--predict_only` flag is available to obtain decoded generations for post-hoc evaluation.
543
+
544
+ If you have a Metal compatible Mac, you can run the eval harness using the MPS back-end by replacing `--device cuda:0` with `--device mps` (requires PyTorch version 2.1 or higher). **Note that the PyTorch MPS backend is still in early stages of development, so correctness issues or unsupported operations may exist. If you observe oddities in model performance on the MPS back-end, we recommend first checking that a forward pass of your model on `--device cpu` and `--device mps` match.**
545
+
546
+ > [!Note]
547
+ > You can inspect what the LM inputs look like by running the following command:
548
+ >
549
+ > ```bash
550
+ > python write_out.py \
551
+ > --tasks <task1,task2,...> \
552
+ > --num_fewshot 5 \
553
+ > --num_examples 10 \
554
+ > --output_base_path /path/to/output/folder
555
+ > ```
556
+ >
557
+ > This will write out one text file for each task.
558
+
559
+ To verify the data integrity of the tasks you're performing in addition to running the tasks themselves, you can use the `--check_integrity` flag:
560
+
561
+ ```bash
562
+ lm_eval --model openai \
563
+ --model_args engine=davinci-002 \
564
+ --tasks lambada_openai,hellaswag \
565
+ --check_integrity
566
+ ```
567
+
568
+ ## Advanced Usage Tips
569
+
570
+ For models loaded with the HuggingFace `transformers` library, any arguments provided via `--model_args` get passed to the relevant constructor directly. This means that anything you can do with `AutoModel` can be done with our library. For example, you can pass a local path via `pretrained=` or use models finetuned with [PEFT](https://github.com/huggingface/peft) by taking the call you would run to evaluate the base model and add `,peft=PATH` to the `model_args` argument:
571
+
572
+ ```bash
573
+ lm_eval --model hf \
574
+ --model_args pretrained=EleutherAI/gpt-j-6b,parallelize=True,load_in_4bit=True,peft=nomic-ai/gpt4all-j-lora \
575
+ --tasks openbookqa,arc_easy,winogrande,hellaswag,arc_challenge,piqa,boolq \
576
+ --device cuda:0
577
+ ```
578
+
579
+ Models provided as delta weights can be easily loaded using the Hugging Face transformers library. Within --model_args, set the delta argument to specify the delta weights, and use the pretrained argument to designate the relative base model to which they will be applied:
580
+
581
+ ```bash
582
+ lm_eval --model hf \
583
+ --model_args pretrained=Ejafa/llama_7B,delta=lmsys/vicuna-7b-delta-v1.1 \
584
+ --tasks hellaswag
585
+ ```
586
+
587
+ GPTQ quantized models can be loaded using [GPTQModel](https://github.com/ModelCloud/GPTQModel) (faster) or [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ)
588
+
589
+ GPTQModel: add `,gptqmodel=True` to `model_args`
590
+
591
+ ```bash
592
+ lm_eval --model hf \
593
+ --model_args pretrained=model-name-or-path,gptqmodel=True \
594
+ --tasks hellaswag
595
+ ```
596
+
597
+ AutoGPTQ: add `,autogptq=True` to `model_args`:
598
+
599
+ ```bash
600
+ lm_eval --model hf \
601
+ --model_args pretrained=model-name-or-path,autogptq=model.safetensors,gptq_use_triton=True \
602
+ --tasks hellaswag
603
+ ```
604
+
605
+ We support wildcards in task names, for example you can run all of the machine-translated lambada tasks via `--task lambada_openai_mt_*`.
606
+
607
+ ## Saving & Caching Results
608
+
609
+ To save evaluation results provide an `--output_path`. We also support logging model responses with the `--log_samples` flag for post-hoc analysis.
610
+
611
+ > [!TIP]
612
+ > Use `--use_cache <DIR>` to cache evaluation results and skip previously evaluated samples when resuming runs of the same (model, task) pairs. Note that caching is rank-dependent, so restart with the same GPU count if interrupted. You can also use --cache_requests to save dataset preprocessing steps for faster evaluation resumption.
613
+
614
+ To push results and samples to the Hugging Face Hub, first ensure an access token with write access is set in the `HF_TOKEN` environment variable. Then, use the `--hf_hub_log_args` flag to specify the organization, repository name, repository visibility, and whether to push results and samples to the Hub - [example dataset on the HF Hub](https://huggingface.co/datasets/KonradSzafer/lm-eval-results-demo). For instance:
615
+
616
+ ```bash
617
+ lm_eval --model hf \
618
+ --model_args pretrained=model-name-or-path,autogptq=model.safetensors,gptq_use_triton=True \
619
+ --tasks hellaswag \
620
+ --log_samples \
621
+ --output_path results \
622
+ --hf_hub_log_args hub_results_org=EleutherAI,hub_repo_name=lm-eval-results,push_results_to_hub=True,push_samples_to_hub=True,public_repo=False \
623
+ ```
624
+
625
+ This allows you to easily download the results and samples from the Hub, using:
626
+
627
+ ```python
628
+ from datasets import load_dataset
629
+
630
+ load_dataset("EleutherAI/lm-eval-results-private", "hellaswag", "latest")
631
+ ```
632
+
633
+ For a full list of supported arguments, check out the [interface](https://github.com/EleutherAI/lm-evaluation-harness/blob/main/docs/interface.md) guide in our documentation!
634
+
635
+ ## Visualizing Results
636
+
637
+ You can seamlessly visualize and analyze the results of your evaluation harness runs using both Weights & Biases (W&B) and Zeno.
638
+
639
+ ### Zeno
640
+
641
+ You can use [Zeno](https://zenoml.com) to visualize the results of your eval harness runs.
642
+
643
+ First, head to [hub.zenoml.com](https://hub.zenoml.com) to create an account and get an API key [on your account page](https://hub.zenoml.com/account).
644
+ Add this key as an environment variable:
645
+
646
+ ```bash
647
+ export ZENO_API_KEY=[your api key]
648
+ ```
649
+
650
+ You'll also need to install the `lm_eval[zeno]` package extra.
651
+
652
+ To visualize the results, run the eval harness with the `log_samples` and `output_path` flags.
653
+ We expect `output_path` to contain multiple folders that represent individual model names.
654
+ You can thus run your evaluation on any number of tasks and models and upload all of the results as projects on Zeno.
655
+
656
+ ```bash
657
+ lm_eval \
658
+ --model hf \
659
+ --model_args pretrained=EleutherAI/gpt-j-6B \
660
+ --tasks hellaswag \
661
+ --device cuda:0 \
662
+ --batch_size 8 \
663
+ --log_samples \
664
+ --output_path output/gpt-j-6B
665
+ ```
666
+
667
+ Then, you can upload the resulting data using the `zeno_visualize` script:
668
+
669
+ ```bash
670
+ python scripts/zeno_visualize.py \
671
+ --data_path output \
672
+ --project_name "Eleuther Project"
673
+ ```
674
+
675
+ This will use all subfolders in `data_path` as different models and upload all tasks within these model folders to Zeno.
676
+ If you run the eval harness on multiple tasks, the `project_name` will be used as a prefix and one project will be created per task.
677
+
678
+ You can find an example of this workflow in [examples/visualize-zeno.ipynb](examples/visualize-zeno.ipynb).
679
+
680
+ ### Weights and Biases
681
+
682
+ With the [Weights and Biases](https://wandb.ai/site) integration, you can now spend more time extracting deeper insights into your evaluation results. The integration is designed to streamline the process of logging and visualizing experiment results using the Weights & Biases (W&B) platform.
683
+
684
+ The integration provide functionalities
685
+
686
+ - to automatically log the evaluation results,
687
+ - log the samples as W&B Tables for easy visualization,
688
+ - log the `results.json` file as an artifact for version control,
689
+ - log the `<task_name>_eval_samples.json` file if the samples are logged,
690
+ - generate a comprehensive report for analysis and visualization with all the important metric,
691
+ - log task and cli specific configs,
692
+ - and more out of the box like the command used to run the evaluation, GPU/CPU counts, timestamp, etc.
693
+
694
+ First you'll need to install the lm_eval[wandb] package extra. Do `pip install lm_eval[wandb]`.
695
+
696
+ Authenticate your machine with an your unique W&B token. Visit https://wandb.ai/authorize to get one. Do `wandb login` in your command line terminal.
697
+
698
+ Run eval harness as usual with a `wandb_args` flag. Use this flag to provide arguments for initializing a wandb run ([wandb.init](https://docs.wandb.ai/ref/python/init)) as comma separated string arguments.
699
+
700
+ ```bash
701
+ lm_eval \
702
+ --model hf \
703
+ --model_args pretrained=microsoft/phi-2,trust_remote_code=True \
704
+ --tasks hellaswag,mmlu_abstract_algebra \
705
+ --device cuda:0 \
706
+ --batch_size 8 \
707
+ --output_path output/phi-2 \
708
+ --limit 10 \
709
+ --wandb_args project=lm-eval-harness-integration \
710
+ --log_samples
711
+ ```
712
+
713
+ In the stdout, you will find the link to the W&B run page as well as link to the generated report. You can find an example of this workflow in [examples/visualize-wandb.ipynb](examples/visualize-wandb.ipynb), and an example of how to integrate it beyond the CLI.
714
+
715
+ ## How to Contribute or Learn More?
716
+
717
+ For more information on the library and how everything fits together, check out all of our [documentation pages](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/docs)! We plan to post a larger roadmap of desired + planned library improvements soon, with more information on how contributors can help.
718
+
719
+ ### Implementing new tasks
720
+
721
+ To implement a new task in the eval harness, see [this guide](./docs/new_task_guide.md).
722
+
723
+ In general, we follow this priority list for addressing concerns about prompting and other eval details:
724
+
725
+ 1. If there is widespread agreement among people who train LLMs, use the agreed upon procedure.
726
+ 2. If there is a clear and unambiguous official implementation, use that procedure.
727
+ 3. If there is widespread agreement among people who evaluate LLMs, use the agreed upon procedure.
728
+ 4. If there are multiple common implementations but not universal or widespread agreement, use our preferred option among the common implementations. As before, prioritize choosing from among the implementations found in LLM training papers.
729
+
730
+ These are guidelines and not rules, and can be overruled in special circumstances.
731
+
732
+ We try to prioritize agreement with the procedures used by other groups to decrease the harm when people inevitably compare runs across different papers despite our discouragement of the practice. Historically, we also prioritized the implementation from [Language Models are Few Shot Learners](https://arxiv.org/abs/2005.14165) as our original goal was specifically to compare results with that paper.
733
+
734
+ ### Support
735
+
736
+ The best way to get support is to open an issue on this repo or join the [EleutherAI Discord server](https://discord.gg/eleutherai). The `#lm-thunderdome` channel is dedicated to developing this project and the `#release-discussion` channel is for receiving support for our releases. If you've used the library and have had a positive (or negative) experience, we'd love to hear from you!
737
+
738
+ ## Optional Extras
739
+
740
+ Extras dependencies can be installed via `pip install -e ".[NAME]"`
741
+
742
+ | Name | Use |
743
+ | -------------------- | ----------------------------------------------------- |
744
+ | api | For using api models (Anthropic, OpenAI API) |
745
+ | audiolm_qwen | For running Qwen2 audio models |
746
+ | deepsparse | For running NM's DeepSparse models |
747
+ | dev | For linting PRs and contributions |
748
+ | gptq | For loading models with AutoGPTQ |
749
+ | gptqmodel | For loading models with GPTQModel |
750
+ | hf_transfer | For speeding up HF Hub file downloads |
751
+ | ibm_watsonx_ai | For using IBM watsonx.ai model apis |
752
+ | ifeval | For running the IFEval task |
753
+ | ipex | For running on optimum-intel ipex backend |
754
+ | japanese_leaderboard | For running Japanese LLM Leaderboard tasks |
755
+ | longbench | For running LongBench tasks |
756
+ | mamba | For loading Mamba SSM models |
757
+ | math | For running math task answer checking |
758
+ | multilingual | For multilingual tokenizers |
759
+ | neuronx | For running on AWS inf2 instances |
760
+ | optimum | For running Intel OpenVINO models |
761
+ | promptsource | For using PromptSource prompts |
762
+ | ruler | For running RULER tasks |
763
+ | sae_lens | For using SAELens to steer models |
764
+ | sentencepiece | For using the sentencepiece tokenizer |
765
+ | sparseml | For using NM's SparseML models |
766
+ | sparsify | For using Sparsify to steer models |
767
+ | testing | For running library test suite |
768
+ | vllm | For loading models with vLLM |
769
+ | wandb | For integration with `Weights and Biases` platform |
770
+ | zeno | For visualizing results with Zeno |
771
+ | -------------------- | ----------------------------------------------------- |
772
+ | all | Loads all extras (not recommended) |
773
+
774
+ ## Cite as
775
+
776
+ ```text
777
+ @misc{eval-harness,
778
+ author = {Gao, Leo and Tow, Jonathan and Abbasi, Baber and Biderman, Stella and Black, Sid and DiPofi, Anthony and Foster, Charles and Golding, Laurence and Hsu, Jeffrey and Le Noac'h, Alain and Li, Haonan and McDonell, Kyle and Muennighoff, Niklas and Ociepa, Chris and Phang, Jason and Reynolds, Laria and Schoelkopf, Hailey and Skowron, Aviya and Sutawika, Lintang and Tang, Eric and Thite, Anish and Wang, Ben and Wang, Kevin and Zou, Andy},
779
+ title = {The Language Model Evaluation Harness},
780
+ month = 07,
781
+ year = 2024,
782
+ publisher = {Zenodo},
783
+ version = {v0.4.3},
784
+ doi = {10.5281/zenodo.12608602},
785
+ url = {https://zenodo.org/records/12608602}
786
+ }
787
+ ```
lm-evaluation-harness/lm_eval.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
lm-evaluation-harness/lm_eval.egg-info/entry_points.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [console_scripts]
2
+ lm-eval = lm_eval.__main__:cli_evaluate
3
+ lm_eval = lm_eval.__main__:cli_evaluate
lm-evaluation-harness/lm_eval/tasks/xcopa/default_sw.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: default_et.yaml
2
+ task: xcopa_sw
3
+ dataset_name: sw
4
+ doc_to_text: !function utils.doc_to_text_sw
lm-evaluation-harness/lm_eval/tasks/xnli/README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XNLI
2
+
3
+ ### Paper
4
+
5
+ Title: `XNLI: Evaluating Cross-lingual Sentence Representations`
6
+
7
+ Abstract: https://arxiv.org/abs/1809.05053
8
+
9
+ Based on the implementation of @yongzx (see https://github.com/EleutherAI/lm-evaluation-harness/pull/258)
10
+
11
+ Prompt format (same as XGLM and mGPT):
12
+
13
+ sentence1 + ", right? " + mask = (Yes|Also|No) + ", " + sentence2
14
+
15
+ Predicition is the full sequence with the highest likelihood.
16
+
17
+ Language specific prompts are translated word-by-word with Google Translate
18
+ and may differ from the ones used by mGPT and XGLM (they do not provide their prompts).
19
+
20
+ Homepage: https://github.com/facebookresearch/XNLI
21
+
22
+
23
+ ### Citation
24
+
25
+ """
26
+ @InProceedings{conneau2018xnli,
27
+ author = "Conneau, Alexis
28
+ and Rinott, Ruty
29
+ and Lample, Guillaume
30
+ and Williams, Adina
31
+ and Bowman, Samuel R.
32
+ and Schwenk, Holger
33
+ and Stoyanov, Veselin",
34
+ title = "XNLI: Evaluating Cross-lingual Sentence Representations",
35
+ booktitle = "Proceedings of the 2018 Conference on Empirical Methods
36
+ in Natural Language Processing",
37
+ year = "2018",
38
+ publisher = "Association for Computational Linguistics",
39
+ location = "Brussels, Belgium",
40
+ }
41
+ """
42
+
43
+ ### Groups and Tasks
44
+
45
+ #### Groups
46
+
47
+ * `xnli`
48
+
49
+ #### Tasks
50
+
51
+ * `xnli_ar`: Arabic
52
+ * `xnli_bg`: Bulgarian
53
+ * `xnli_de`: German
54
+ * `xnli_el`: Greek
55
+ * `xnli_en`: English
56
+ * `xnli_es`: Spanish
57
+ * `xnli_fr`: French
58
+ * `xnli_hi`: Hindi
59
+ * `xnli_ru`: Russian
60
+ * `xnli_sw`: Swahili
61
+ * `xnli_th`: Thai
62
+ * `xnli_tr`: Turkish
63
+ * `xnli_ur`: Urdu
64
+ * `xnli_vi`: Vietnamese
65
+ * `xnli_zh`: Chinese
66
+
67
+ ### Checklist
68
+
69
+ For adding novel benchmarks/datasets to the library:
70
+ * [ ] Is the task an existing benchmark in the literature?
71
+ * [ ] Have you referenced the original paper that introduced the task?
72
+ * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
73
+
74
+
75
+ If other tasks on this dataset are already supported:
76
+ * [ ] Is the "Main" variant of this task clearly denoted?
77
+ * [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates?
78
+ * [ ] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/xnli/utils.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+
3
+ import yaml
4
+
5
+
6
+ # Different languages that are part of xnli.
7
+ # These correspond to dataset names (Subsets) on HuggingFace.
8
+ # A yaml file is generated by this script for each language.
9
+
10
+ LANGUAGES = {
11
+ "ar": { # Arabic
12
+ "QUESTION_WORD": "صحيح",
13
+ "ENTAILMENT_LABEL": "نعم",
14
+ "NEUTRAL_LABEL": "لذا",
15
+ "CONTRADICTION_LABEL": "رقم",
16
+ },
17
+ "bg": { # Bulgarian
18
+ "QUESTION_WORD": "правилно",
19
+ "ENTAILMENT_LABEL": "да",
20
+ "NEUTRAL_LABEL": "така",
21
+ "CONTRADICTION_LABEL": "не",
22
+ },
23
+ "de": { # German
24
+ "QUESTION_WORD": "richtig",
25
+ "ENTAILMENT_LABEL": "Ja",
26
+ "NEUTRAL_LABEL": "Auch",
27
+ "CONTRADICTION_LABEL": "Nein",
28
+ },
29
+ "el": { # Greek
30
+ "QUESTION_WORD": "σωστός",
31
+ "ENTAILMENT_LABEL": "Ναί",
32
+ "NEUTRAL_LABEL": "Έτσι",
33
+ "CONTRADICTION_LABEL": "όχι",
34
+ },
35
+ "en": { # English
36
+ "QUESTION_WORD": "right",
37
+ "ENTAILMENT_LABEL": "Yes",
38
+ "NEUTRAL_LABEL": "Also",
39
+ "CONTRADICTION_LABEL": "No",
40
+ },
41
+ "es": { # Spanish
42
+ "QUESTION_WORD": "correcto",
43
+ "ENTAILMENT_LABEL": "Sí",
44
+ "NEUTRAL_LABEL": "Asi que",
45
+ "CONTRADICTION_LABEL": "No",
46
+ },
47
+ "fr": { # French
48
+ "QUESTION_WORD": "correct",
49
+ "ENTAILMENT_LABEL": "Oui",
50
+ "NEUTRAL_LABEL": "Aussi",
51
+ "CONTRADICTION_LABEL": "Non",
52
+ },
53
+ "hi": { # Hindi
54
+ "QUESTION_WORD": "सही",
55
+ "ENTAILMENT_LABEL": "हाँ",
56
+ "NEUTRAL_LABEL": "इसलिए",
57
+ "CONTRADICTION_LABEL": "नहीं",
58
+ },
59
+ "ru": { # Russian
60
+ "QUESTION_WORD": "правильно",
61
+ "ENTAILMENT_LABEL": "Да",
62
+ "NEUTRAL_LABEL": "Так",
63
+ "CONTRADICTION_LABEL": "Нет",
64
+ },
65
+ "sw": { # Swahili
66
+ "QUESTION_WORD": "sahihi",
67
+ "ENTAILMENT_LABEL": "Ndiyo",
68
+ "NEUTRAL_LABEL": "Hivyo",
69
+ "CONTRADICTION_LABEL": "Hapana",
70
+ },
71
+ "th": { # Thai
72
+ "QUESTION_WORD": "ถูกต้อง",
73
+ "ENTAILMENT_LABEL": "ใช่",
74
+ "NEUTRAL_LABEL": "ดังนั้น",
75
+ "CONTRADICTION_LABEL": "ไม่",
76
+ },
77
+ "tr": { # Turkish
78
+ "QUESTION_WORD": "doğru",
79
+ "ENTAILMENT_LABEL": "Evet",
80
+ "NEUTRAL_LABEL": "Böylece",
81
+ "CONTRADICTION_LABEL": "Hayır",
82
+ },
83
+ "ur": { # Urdu
84
+ "QUESTION_WORD": "صحیح",
85
+ "ENTAILMENT_LABEL": "جی ہاں",
86
+ "NEUTRAL_LABEL": "اس لئے",
87
+ "CONTRADICTION_LABEL": "نہیں",
88
+ },
89
+ "vi": { # Vietnamese
90
+ "QUESTION_WORD": "đúng",
91
+ "ENTAILMENT_LABEL": "Vâng",
92
+ "NEUTRAL_LABEL": "Vì vậy",
93
+ "CONTRADICTION_LABEL": "Không",
94
+ },
95
+ "zh": { # Chinese
96
+ "QUESTION_WORD": "正确",
97
+ "ENTAILMENT_LABEL": "是的",
98
+ "NEUTRAL_LABEL": "所以",
99
+ "CONTRADICTION_LABEL": "不是的",
100
+ },
101
+ }
102
+
103
+
104
+ def gen_lang_yamls(output_dir: str, overwrite: bool) -> None:
105
+ """
106
+ Generate a yaml file for each language.
107
+
108
+ :param output_dir: The directory to output the files to.
109
+ :param overwrite: Whether to overwrite files if they already exist.
110
+ """
111
+ err = []
112
+ for lang in LANGUAGES.keys():
113
+ file_name = f"xnli_{lang}.yaml"
114
+ try:
115
+ QUESTION_WORD = LANGUAGES[lang]["QUESTION_WORD"]
116
+ ENTAILMENT_LABEL = LANGUAGES[lang]["ENTAILMENT_LABEL"]
117
+ NEUTRAL_LABEL = LANGUAGES[lang]["NEUTRAL_LABEL"]
118
+ CONTRADICTION_LABEL = LANGUAGES[lang]["CONTRADICTION_LABEL"]
119
+ with open(
120
+ f"{output_dir}/{file_name}", "w" if overwrite else "x", encoding="utf8"
121
+ ) as f:
122
+ f.write("# Generated by utils.py\n")
123
+ yaml.dump(
124
+ {
125
+ "include": "xnli_common_yaml",
126
+ "dataset_name": lang,
127
+ "task": f"xnli_{lang}",
128
+ "doc_to_text": "",
129
+ "doc_to_choice": f"{{{{["
130
+ f"""premise+\", {QUESTION_WORD}? {ENTAILMENT_LABEL}, \"+hypothesis,"""
131
+ f"""premise+\", {QUESTION_WORD}? {NEUTRAL_LABEL}, \"+hypothesis,"""
132
+ f"""premise+\", {QUESTION_WORD}? {CONTRADICTION_LABEL}, \"+hypothesis"""
133
+ f"]}}}}",
134
+ },
135
+ f,
136
+ allow_unicode=True,
137
+ )
138
+ except FileExistsError:
139
+ err.append(file_name)
140
+
141
+ if len(err) > 0:
142
+ raise FileExistsError(
143
+ "Files were not created because they already exist (use --overwrite flag):"
144
+ f" {', '.join(err)}"
145
+ )
146
+
147
+
148
+ def main() -> None:
149
+ """Parse CLI args and generate language-specific yaml files."""
150
+ parser = argparse.ArgumentParser()
151
+ parser.add_argument(
152
+ "--overwrite",
153
+ default=False,
154
+ action="store_true",
155
+ help="Overwrite files if they already exist",
156
+ )
157
+ parser.add_argument(
158
+ "--output-dir", default=".", help="Directory to write yaml files to"
159
+ )
160
+ args = parser.parse_args()
161
+
162
+ gen_lang_yamls(output_dir=args.output_dir, overwrite=args.overwrite)
163
+
164
+
165
+ if __name__ == "__main__":
166
+ main()
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_common_yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file will be included in the generated language-specific task configs.
2
+ # It doesn't have a yaml file extension as it is not meant to be imported directly
3
+ # by the harness.
4
+ task: null
5
+ dataset_path: xnli
6
+ dataset_name: null
7
+ output_type: multiple_choice
8
+ training_split: train
9
+ validation_split: validation
10
+ doc_to_text: null
11
+ doc_to_target: label
12
+ doc_to_choice: null
13
+ metric_list:
14
+ - metric: acc
15
+ aggregation: mean
16
+ higher_is_better: true
17
+ metadata:
18
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_en.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: en
3
+ doc_to_choice: '{{[premise+", right? Yes, "+hypothesis,premise+", right? Also, "+hypothesis,premise+",
4
+ right? No, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_en
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_es.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: es
3
+ doc_to_choice: '{{[premise+", correcto? Sí, "+hypothesis,premise+", correcto? Asi
4
+ que, "+hypothesis,premise+", correcto? No, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_es
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_fr.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: fr
3
+ doc_to_choice: '{{[premise+", correct? Oui, "+hypothesis,premise+", correct? Aussi,
4
+ "+hypothesis,premise+", correct? Non, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_fr
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_ru.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: ru
3
+ doc_to_choice: '{{[premise+", правильно? Да, "+hypothesis,premise+", правильно? Так,
4
+ "+hypothesis,premise+", правильно? Нет, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_ru
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_th.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: th
3
+ doc_to_choice: '{{[premise+", ถูกต้อง? ใช่, "+hypothesis,premise+", ถูกต้อง? ดังนั้น,
4
+ "+hypothesis,premise+", ถูกต้อง? ไม่, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_th
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_tr.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: tr
3
+ doc_to_choice: '{{[premise+", doğru? Evet, "+hypothesis,premise+", doğru? Böylece,
4
+ "+hypothesis,premise+", doğru? Hayır, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_tr
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_vi.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: vi
3
+ doc_to_choice: '{{[premise+", đúng? Vâng, "+hypothesis,premise+", đúng? Vì vậy, "+hypothesis,premise+",
4
+ đúng? Không, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_vi
lm-evaluation-harness/lm_eval/tasks/xnli/xnli_zh.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: zh
3
+ doc_to_choice: '{{[premise+", 正确? 是的, "+hypothesis,premise+", 正确? 所以, "+hypothesis,premise+",
4
+ 正确? 不是的, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_zh
lm-evaluation-harness/lm_eval/tasks/xnli_eu/README.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XNLIeu
2
+
3
+ ### Paper
4
+
5
+ Title: XNLIeu: a dataset for cross-lingual NLI in Basque
6
+
7
+ Abstract: https://arxiv.org/abs/2404.06996
8
+
9
+ XNLI is a popular Natural Language Inference (NLI) benchmark widely used to evaluate cross-lingual Natural Language Understanding (NLU) capabilities across languages. In this paper, we expand XNLI to include Basque, a low-resource language that can greatly benefit from transfer-learning approaches. The new dataset, dubbed XNLIeu, has been developed by first machine-translating the English XNLI corpus into Basque, followed by a manual post-edition step. We have conducted a series of experiments using mono- and multilingual LLMs to assess a) the effect of professional post-edition on the MT system; b) the best cross-lingual strategy for NLI in Basque; and c) whether the choice of the best cross-lingual strategy is influenced by the fact that the dataset is built by translation. The results show that post-edition is necessary and that the translate-train cross-lingual strategy obtains better results overall, although the gain is lower when tested in a dataset that has been built natively from scratch. Our code and datasets are publicly available under open licenses at https://github.com/hitz-zentroa/xnli-eu.
10
+
11
+ Homepage: https://github.com/hitz-zentroa/xnli-eu
12
+
13
+
14
+ ### Citation
15
+
16
+ ```bibtex
17
+ @misc{heredia2024xnlieu,
18
+ title={XNLIeu: a dataset for cross-lingual NLI in Basque},
19
+ author={Maite Heredia and Julen Etxaniz and Muitze Zulaika and Xabier Saralegi and Jeremy Barnes and Aitor Soroa},
20
+ year={2024},
21
+ eprint={2404.06996},
22
+ archivePrefix={arXiv},
23
+ primaryClass={cs.CL}
24
+ }
25
+ ```
26
+
27
+ ### Groups, Tags, and Tasks
28
+
29
+ #### Tags
30
+
31
+ * `xnli_eu_mt_native`: Includes MT and Native variants of the XNLIeu dataset.
32
+
33
+ #### Tasks
34
+
35
+ * `xnli_eu`: XNLI in Basque postedited from MT.
36
+ * `xnli_eu_mt`: XNLI in Basque machine translated from English.
37
+ * `xnli_eu_native`: XNLI in Basque natively created.
38
+
39
+ ### Checklist
40
+
41
+ For adding novel benchmarks/datasets to the library:
42
+ * [x] Is the task an existing benchmark in the literature?
43
+ * [x] Have you referenced the original paper that introduced the task?
44
+ * [x] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
45
+
46
+
47
+ If other tasks on this dataset are already supported:
48
+ * [ ] Is the "Main" variant of this task clearly denoted?
49
+ * [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates?
50
+ * [ ] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/xnli_eu/xnli_common_yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task: null
2
+ dataset_path: xnli
3
+ dataset_name: null
4
+ output_type: multiple_choice
5
+ training_split: train
6
+ validation_split: validation
7
+ doc_to_text: null
8
+ doc_to_target: label
9
+ doc_to_choice: null
10
+ metric_list:
11
+ - metric: acc
12
+ aggregation: mean
13
+ higher_is_better: true
14
+ metadata:
15
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xquad/README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XQuAD
2
+
3
+ ### Paper
4
+
5
+ Title: `On the Cross-lingual Transferability of Monolingual Representations`
6
+
7
+ Abstract: https://aclanthology.org/2020.acl-main.421.pdf
8
+
9
+ XQuAD (Cross-lingual Question Answering Dataset) is a benchmark dataset for evaluating cross-lingual question answering performance. The dataset consists of a subset of 240 paragraphs and 1190 question-answer pairs from the development set of SQuAD v1.1 (Rajpurkar et al., 2016) together with their professional translations into ten languages: Spanish, German, Greek, Russian, Turkish, Arabic, Vietnamese, Thai, Chinese, and Hindi. Consequently, the dataset is entirely parallel across 11 languages.
10
+
11
+ Homepage: https://github.com/deepmind/xquad
12
+
13
+
14
+ ### Citation
15
+
16
+ ```
17
+ @article{Artetxe:etal:2019,
18
+ author = {Mikel Artetxe and Sebastian Ruder and Dani Yogatama},
19
+ title = {On the cross-lingual transferability of monolingual representations},
20
+ journal = {CoRR},
21
+ volume = {abs/1910.11856},
22
+ year = {2019},
23
+ archivePrefix = {arXiv},
24
+ eprint = {1910.11856}
25
+ }
26
+ ```
27
+
28
+ ### Groups and Tasks
29
+
30
+ #### Groups
31
+
32
+ * `xquad`: All available languages.
33
+
34
+ #### Tasks
35
+ Perform extractive question answering for each language's subset of XQuAD.
36
+ * `xquad_ar`: Arabic
37
+ * `xquad_de`: German
38
+ * `xquad_el`: Greek
39
+ * `xquad_en`: English
40
+ * `xquad_es`: Spanish
41
+ * `xquad_hi`: Hindi
42
+ * `xquad_ro`: Romanian
43
+ * `xquad_ru`: Russian
44
+ * `xquad_th`: Thai
45
+ * `xquad_tr`: Turkish
46
+ * `xquad_vi`: Vietnamese
47
+ * `xquad_zh`: Chinese
48
+
49
+
50
+
51
+ ### Checklist
52
+
53
+ For adding novel benchmarks/datasets to the library:
54
+ * [x] Is the task an existing benchmark in the literature?
55
+ * [x] Have you referenced the original paper that introduced the task?
56
+ * [x] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
57
+
58
+
59
+ If other tasks on this dataset are already supported:
60
+ * [ ] Is the "Main" variant of this task clearly denoted?
61
+ * [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates?
62
+ * [ ] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/xquad/utils.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from itertools import product
3
+
4
+ import evaluate
5
+ import transformers.data.metrics.squad_metrics as squad_metrics
6
+
7
+ from lm_eval.utils import general_detokenize
8
+
9
+
10
+ def process_results_qa(doc, results):
11
+ preds = results[0]
12
+ reference = doc["answers"]["text"][0]
13
+ f1_sum = squad_metrics.compute_f1(reference, preds)
14
+ exact_match = squad_metrics.compute_exact(reference, preds)
15
+ return {"f1": f1_sum, "exact_match": exact_match}
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_ar.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_ar
3
+ dataset_name: xquad.ar
4
+ doc_to_text: "سيا: {{context}}\n\nسؤال: {{question}}\n\nإجابة:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_common_yaml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file will be included in the generated language-specific task configs.
2
+ # It doesn't have a yaml file extension as it is not meant to be imported directly
3
+ # by the harness.
4
+ tag: xquad
5
+ task: null
6
+ dataset_path: xquad
7
+ dataset_name: null
8
+ output_type: generate_until
9
+ validation_split: validation
10
+ doc_to_text: null
11
+ doc_to_target: '{{answers["text"][0]}}'
12
+ process_results: !function utils.process_results_qa
13
+ target_delimiter: ' '
14
+ generation_kwargs:
15
+ until:
16
+ - "\n"
17
+ do_sample: false
18
+ temperature: 0.0
19
+ metric_list:
20
+ - metric: exact_match
21
+ aggregation: mean
22
+ higher_is_better: true
23
+ - metric: f1
24
+ aggregation: mean
25
+ higher_is_better: true
26
+ metadata:
27
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_de.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_de
3
+ dataset_name: xquad.de
4
+ doc_to_text: "Kontext: {{context}}\n\nFrage: {{question}}\n\nAntwort:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_el.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_el
3
+ dataset_name: xquad.el
4
+ doc_to_text: "Συμφραζόμενα: {{context}}\n\nΕρώτηση: {{question}}\n\nΑπάντηση:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_en.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_en
3
+ dataset_name: xquad.en
4
+ doc_to_text: "Context: {{context}}\n\nQuestion: {{question}}\n\nAnswer:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_es.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_es
3
+ dataset_name: xquad.es
4
+ doc_to_text: "Contexto: {{context}}\n\nPregunta: {{question}}\n\nRespuesta:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_hi.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_hi
3
+ dataset_name: xquad.hi
4
+ doc_to_text: "प्रसंग: {{context}}\n\nसवाल: {{question}}\n\nउत्तर:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_ro.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_ro
3
+ dataset_name: xquad.ro
4
+ doc_to_text: "Context: {{context}}\n\nÎntrebare: {{question}}\n\nRăspuns:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_ru.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_ru
3
+ dataset_name: xquad.ru
4
+ doc_to_text: "Контекст: {{context}}\n\nВопрос: {{question}}\n\nОтвет:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_th.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_th
3
+ dataset_name: xquad.th
4
+ doc_to_text: "บริบท: {{context}}\n\nคำถาม: {{question}}\n\nคำตอบ:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_tr.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_tr
3
+ dataset_name: xquad.tr
4
+ doc_to_text: "Bağlam: {{context}}\n\nSoru: {{question}}\n\nCevap:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_vi.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_vi
3
+ dataset_name: xquad.vi
4
+ doc_to_text: "Bối cảnh: {{context}}\n\nCâu hỏi: {{question}}\n\nTrả lời:"
lm-evaluation-harness/lm_eval/tasks/xquad/xquad_zh.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ include: xquad_common_yaml
2
+ task: xquad_zh
3
+ dataset_name: xquad.zh
4
+ doc_to_text: "语境: {{context}}\n\n问题: {{question}}\n\n回答:"
lm-evaluation-harness/lm_eval/tasks/xstorycloze/README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XStoryCloze
2
+
3
+ ### Paper
4
+
5
+ Title: `Few-shot Learning with Multilingual Language Models`
6
+
7
+ Abstract: https://arxiv.org/abs/2112.10668
8
+
9
+ XStoryCloze consists of the professionally translated version of the [English StoryCloze dataset](https://cs.rochester.edu/nlp/rocstories/) (Spring 2016 version) to 10 non-English languages. This dataset is released by Meta AI.
10
+
11
+ Homepage: https://github.com/facebookresearch/fairseq/pull/4820
12
+
13
+
14
+ ### Citation
15
+
16
+ ```
17
+ @article{DBLP:journals/corr/abs-2112-10668,
18
+ author = {Xi Victoria Lin and
19
+ Todor Mihaylov and
20
+ Mikel Artetxe and
21
+ Tianlu Wang and
22
+ Shuohui Chen and
23
+ Daniel Simig and
24
+ Myle Ott and
25
+ Naman Goyal and
26
+ Shruti Bhosale and
27
+ Jingfei Du and
28
+ Ramakanth Pasunuru and
29
+ Sam Shleifer and
30
+ Punit Singh Koura and
31
+ Vishrav Chaudhary and
32
+ Brian O'Horo and
33
+ Jeff Wang and
34
+ Luke Zettlemoyer and
35
+ Zornitsa Kozareva and
36
+ Mona T. Diab and
37
+ Veselin Stoyanov and
38
+ Xian Li},
39
+ title = {Few-shot Learning with Multilingual Language Models},
40
+ journal = {CoRR},
41
+ volume = {abs/2112.10668},
42
+ year = {2021},
43
+ url = {https://arxiv.org/abs/2112.10668},
44
+ eprinttype = {arXiv},
45
+ eprint = {2112.10668},
46
+ timestamp = {Tue, 04 Jan 2022 15:59:27 +0100},
47
+ biburl = {https://dblp.org/rec/journals/corr/abs-2112-10668.bib},
48
+ bibsource = {dblp computer science bibliography, https://dblp.org}
49
+ }
50
+ ```
51
+
52
+ ### Groups and Tasks
53
+
54
+ #### Groups
55
+
56
+ * `xstorycloze`
57
+
58
+ #### Tasks
59
+
60
+ * `xstorycloze_ar`: Arabic
61
+ * `xstorycloze_en`: English
62
+ * `xstorycloze_es`: Spanish
63
+ * `xstorycloze_eu`: Basque
64
+ * `xstorycloze_hi`: Hindi
65
+ * `xstorycloze_id`: Indonesian
66
+ * `xstorycloze_my`: Burmese
67
+ * `xstorycloze_ru`: Russian
68
+ * `xstorycloze_sw`: Swahili
69
+ * `xstorycloze_te`: Telugu
70
+ * `xstorycloze_zh`: Chinese
71
+
72
+
73
+ ### Checklist
74
+
75
+ For adding novel benchmarks/datasets to the library:
76
+ * [ ] Is the task an existing benchmark in the literature?
77
+ * [ ] Have you referenced the original paper that introduced the task?
78
+ * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
79
+
80
+
81
+ If other tasks on this dataset are already supported:
82
+ * [ ] Is the "Main" variant of this task clearly denoted?
83
+ * [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates?
84
+ * [ ] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/xstorycloze/_xstorycloze.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ group: xstorycloze
2
+ task:
3
+ - xstorycloze_ar
4
+ - xstorycloze_en
5
+ - xstorycloze_es
6
+ - xstorycloze_eu
7
+ - xstorycloze_hi
8
+ - xstorycloze_id
9
+ - xstorycloze_my
10
+ - xstorycloze_ru
11
+ - xstorycloze_sw
12
+ - xstorycloze_te
13
+ - xstorycloze_zh
14
+ aggregate_metric_list:
15
+ - metric: acc
16
+ aggregation: mean
17
+ weight_by_size: true
18
+ metadata:
19
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_ar.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task: xstorycloze_ar
2
+ dataset_path: juletxara/xstory_cloze
3
+ dataset_name: ar
4
+ output_type: multiple_choice
5
+ training_split: train
6
+ validation_split: eval
7
+ doc_to_text: "{{[input_sentence_1, input_sentence_2, input_sentence_3, input_sentence_4]|join(' ')}}"
8
+ doc_to_target: "{{answer_right_ending-1}}"
9
+ doc_to_choice: "{{[sentence_quiz1, sentence_quiz2]}}"
10
+ should_decontaminate: true
11
+ doc_to_decontamination_query: "{{[input_sentence_1, input_sentence_2, input_sentence_3, input_sentence_4]|join(' ')}}"
12
+ metric_list:
13
+ - metric: acc
14
+ aggregation: mean
15
+ higher_is_better: true
16
+ metadata:
17
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_en.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_en
3
+ dataset_name: en
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_es.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_es
3
+ dataset_name: es
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_eu.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_eu
3
+ dataset_name: eu
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_hi.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_hi
3
+ dataset_name: hi
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_id.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_id
3
+ dataset_name: id
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_my.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_my
3
+ dataset_name: my
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_ru.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_ru
3
+ dataset_name: ru
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_sw.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_sw
3
+ dataset_name: sw
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_te.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_te
3
+ dataset_name: te
lm-evaluation-harness/lm_eval/tasks/xstorycloze/default_zh.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: default_ar.yaml
2
+ task: xstorycloze_zh
3
+ dataset_name: zh
lm-evaluation-harness/lm_eval/tasks/xwinograd/README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Task-name
2
+
3
+ ### Paper
4
+
5
+ Title: `It's All in the Heads: Using Attention Heads as a Baseline for Cross-Lingual Transfer in Commonsense Reasoning`
6
+ Abstract: `https://arxiv.org/abs/2106.12066`
7
+
8
+ Multilingual winograd schema challenge that includes English, French, Japanese, Portuguese, Russian and Chinese. Winograd schema challenges come from the XWinograd dataset introduced in Tikhonov et al. As it only contains 16 Chinese schemas, we add 488 Chinese schemas from clue/cluewsc2020.
9
+
10
+ Homepage: `https://huggingface.co/datasets/Muennighoff/xwinograd`
11
+
12
+
13
+ ### Citation
14
+
15
+ ```
16
+ @misc{muennighoff2022crosslingual,
17
+ title={Crosslingual Generalization through Multitask Finetuning},
18
+ author={Niklas Muennighoff and Thomas Wang and Lintang Sutawika and Adam Roberts and Stella Biderman and Teven Le Scao and M Saiful Bari and Sheng Shen and Zheng-Xin Yong and Hailey Schoelkopf and Xiangru Tang and Dragomir Radev and Alham Fikri Aji and Khalid Almubarak and Samuel Albanie and Zaid Alyafeai and Albert Webson and Edward Raff and Colin Raffel},
19
+ year={2022},
20
+ eprint={2211.01786},
21
+ archivePrefix={arXiv},
22
+ primaryClass={cs.CL}
23
+ }
24
+ @misc{tikhonov2021heads,
25
+ title={It's All in the Heads: Using Attention Heads as a Baseline for Cross-Lingual Transfer in Commonsense Reasoning},
26
+ author={Alexey Tikhonov and Max Ryabinin},
27
+ year={2021},
28
+ eprint={2106.12066},
29
+ archivePrefix={arXiv},
30
+ primaryClass={cs.CL}
31
+ }
32
+ ```
33
+
34
+ ### Groups and Tasks
35
+
36
+ #### Groups
37
+
38
+ * `xwinograd`
39
+
40
+ #### Tasks
41
+
42
+ List or describe tasks defined in this folder, and their names here:
43
+ * `xwinograd_en`: Winograd schema challenges in English.
44
+ * `xwinograd_fr`: Winograd schema challenges in French.
45
+ * `xwinograd_jp`: Winograd schema challenges in Japanese.
46
+ * `xwinograd_pt`: Winograd schema challenges in Portuguese.
47
+ * `xwinograd_ru`: Winograd schema challenges in Russian.
48
+ * `xwinograd_zh`: Winograd schema challenges in Chinese.
49
+
50
+ ### Checklist
51
+
52
+ For adding novel benchmarks/datasets to the library:
53
+ * [x] Is the task an existing benchmark in the literature?
54
+ * [x] Have you referenced the original paper that introduced the task?
55
+ * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
56
+
57
+
58
+ If other tasks on this dataset are already supported:
59
+ * [ ] Is the "Main" variant of this task clearly denoted?
60
+ * [x] Have you provided a short sentence in a README on what each new variant adds / evaluates?
61
+ * [ ] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/xwinograd/_xwinograd.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ group: xwinograd
2
+ task:
3
+ - xwinograd_en
4
+ - xwinograd_fr
5
+ - xwinograd_jp
6
+ - xwinograd_pt
7
+ - xwinograd_ru
8
+ - xwinograd_zh
9
+ aggregate_metric_list:
10
+ - metric: acc
11
+ aggregation: mean
12
+ weight_by_size: true
13
+ metadata:
14
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xwinograd/utils.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ from typing import Dict, List
3
+
4
+ import yaml
5
+
6
+
7
+ # Different languages that are part of xwinograd.
8
+ # These correspond to dataset names (Subsets) on HuggingFace.
9
+ # A yaml file is generated by this script for each language.
10
+ LANGUAGES = ["en", "fr", "jp", "pt", "ru", "zh"]
11
+
12
+
13
+ def doc_to_text(doc: Dict) -> int:
14
+ """
15
+ Return index of the correct choice.
16
+
17
+ Note: We are using the "multiple input" mode of the multiple-choice
18
+ output-type, which means we use different contexts with the same target
19
+ for the different choices, rather than the same context and different targets.
20
+ """
21
+ answer_to_num = {"1": 0, "2": 1}
22
+ return answer_to_num[doc["answer"]]
23
+
24
+
25
+ def doc_to_target(doc: Dict) -> str:
26
+ """
27
+ Return the target completion.
28
+
29
+ Note that this does not depend on the correct choice as we are using
30
+ "multiple input" mode.
31
+ """
32
+ idx = doc["sentence"].index("_") + 1
33
+ return doc["sentence"][idx:].strip()
34
+
35
+
36
+ def doc_to_choice(doc: Dict) -> List[str]:
37
+ """Return the choices that will be used as contexts in "multiple input" mode."""
38
+ idx = doc["sentence"].index("_")
39
+ options = [doc["option1"], doc["option2"]]
40
+ return [doc["sentence"][:idx] + opt for opt in options]
41
+
42
+
43
+ def gen_lang_yamls(output_dir: str, overwrite: bool) -> None:
44
+ """
45
+ Generate a yaml file for each language.
46
+
47
+ :param output_dir: The directory to output the files to.
48
+ :param overwrite: Whether to overwrite files if they already exist.
49
+ """
50
+ err = []
51
+ for lang in LANGUAGES:
52
+ file_name = f"xwinograd_{lang}.yaml"
53
+ try:
54
+ with open(
55
+ f"{output_dir}/{file_name}", "w" if overwrite else "x", encoding="utf-8"
56
+ ) as f:
57
+ f.write("# Generated by utils.py\n")
58
+ yaml.dump(
59
+ {
60
+ "include": "xwinograd_common_yaml",
61
+ "dataset_name": lang,
62
+ "task": f"xwinograd_{lang}",
63
+ },
64
+ f,
65
+ )
66
+ except FileExistsError:
67
+ err.append(file_name)
68
+
69
+ if len(err) > 0:
70
+ raise FileExistsError(
71
+ "Files were not created because they already exist (use --overwrite flag):"
72
+ f" {', '.join(err)}"
73
+ )
74
+
75
+
76
+ def main() -> None:
77
+ """Parse CLI args and generate language-specific yaml files."""
78
+ parser = argparse.ArgumentParser()
79
+ parser.add_argument(
80
+ "--overwrite",
81
+ default=False,
82
+ action="store_true",
83
+ help="Overwrite files if they already exist",
84
+ )
85
+ parser.add_argument(
86
+ "--output-dir", default=".", help="Directory to write yaml files to"
87
+ )
88
+ args = parser.parse_args()
89
+
90
+ gen_lang_yamls(output_dir=args.output_dir, overwrite=args.overwrite)
91
+
92
+
93
+ if __name__ == "__main__":
94
+ main()
lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_common_yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file will be included in the generated language-specific task configs.
2
+ # It doesn't have a yaml file extension as it is not meant to be imported directly
3
+ # by the harness.
4
+ dataset_path: Muennighoff/xwinograd
5
+ dataset_name: null # Overridden by language-specific config.
6
+ output_type: multiple_choice
7
+ training_split: null
8
+ validation_split: null
9
+ test_split: test
10
+ doc_to_text: !function utils.doc_to_text
11
+ doc_to_target: !function utils.doc_to_target
12
+ doc_to_choice: !function utils.doc_to_choice
13
+ metric_list:
14
+ - metric: acc
15
+ aggregation: mean
16
+ higher_is_better: true
17
+ metadata:
18
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_en.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: en
3
+ include: xwinograd_common_yaml
4
+ task: xwinograd_en