chen459664 commited on
Commit
68f9583
·
verified ·
1 Parent(s): 9052d77

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-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/PKG-INFO +631 -0
  2. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/SOURCES.txt +0 -0
  3. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/dependency_links.txt +1 -0
  4. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/entry_points.txt +3 -0
  5. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/requires.txt +132 -0
  6. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/top_level.txt +1 -0
  7. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_moral_scenarios.yaml +7 -0
  8. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_prehistory.yaml +7 -0
  9. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_professional_medicine.yaml +7 -0
  10. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_public_relations.yaml +7 -0
  11. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_sociology.yaml +7 -0
  12. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_us_foreign_policy.yaml +7 -0
  13. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_virology.yaml +7 -0
  14. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_world_religions.yaml +7 -0
  15. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/utils.py +19 -0
  16. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/_tech_and_engineering.yaml +16 -0
  17. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_accounting.yaml +4 -0
  18. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_agriculture.yaml +4 -0
  19. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_architecture_and_engineering.yaml +4 -0
  20. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_art_theory.yaml +4 -0
  21. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_biology.yaml +4 -0
  22. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_chemistry.yaml +4 -0
  23. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_computer_science.yaml +4 -0
  24. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_economics.yaml +4 -0
  25. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_electronics.yaml +4 -0
  26. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_finance.yaml +4 -0
  27. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_geography.yaml +4 -0
  28. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_history.yaml +4 -0
  29. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_manage.yaml +4 -0
  30. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_marketing.yaml +4 -0
  31. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_materials.yaml +4 -0
  32. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_math.yaml +4 -0
  33. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_mechanical_engineering.yaml +4 -0
  34. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_music.yaml +4 -0
  35. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_pharmacy.yaml +4 -0
  36. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_physics.yaml +4 -0
  37. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_psychology.yaml +4 -0
  38. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_public_health.yaml +4 -0
  39. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_sociology.yaml +4 -0
  40. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/utils.py +341 -0
  41. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/_generate_configs.py +26 -0
  42. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/_template_yaml +14 -0
  43. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-coordinate-itself.yaml +4 -0
  44. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-coordinate-other-ais.yaml +4 -0
  45. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-coordinate-other-versions.yaml +4 -0
  46. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-corrigible-less-HHH.yaml +4 -0
  47. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-corrigible-more-HHH.yaml +4 -0
  48. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-corrigible-neutral-HHH.yaml +4 -0
  49. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-myopic-reward.yaml +4 -0
  50. lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-one-box-tendency.yaml +4 -0
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/PKG-INFO ADDED
@@ -0,0 +1,631 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: lm_eval
3
+ Version: 0.4.5
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.8
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: api
37
+ Requires-Dist: requests; extra == "api"
38
+ Requires-Dist: aiohttp; extra == "api"
39
+ Requires-Dist: tenacity; extra == "api"
40
+ Requires-Dist: tqdm; extra == "api"
41
+ Requires-Dist: tiktoken; extra == "api"
42
+ Provides-Extra: dev
43
+ Requires-Dist: pytest; extra == "dev"
44
+ Requires-Dist: pytest-cov; extra == "dev"
45
+ Requires-Dist: pytest-xdist; extra == "dev"
46
+ Requires-Dist: pre-commit; extra == "dev"
47
+ Requires-Dist: mypy; extra == "dev"
48
+ Provides-Extra: deepsparse
49
+ Requires-Dist: deepsparse-nightly[llm]>=1.8.0.20240404; extra == "deepsparse"
50
+ Provides-Extra: gptq
51
+ Requires-Dist: auto-gptq[triton]>=0.6.0; extra == "gptq"
52
+ Provides-Extra: awq
53
+ Requires-Dist: auto-awq>=0.2.6; extra == "awq"
54
+ Provides-Extra: hqq
55
+ Requires-Dist: hqq>=0.2.1; extra == "hqq"
56
+ Provides-Extra: hf-transfer
57
+ Requires-Dist: hf_transfer; extra == "hf-transfer"
58
+ Provides-Extra: ibm-watsonx-ai
59
+ Requires-Dist: ibm_watsonx_ai>=1.1.22; extra == "ibm-watsonx-ai"
60
+ Provides-Extra: ifeval
61
+ Requires-Dist: langdetect; extra == "ifeval"
62
+ Requires-Dist: immutabledict; extra == "ifeval"
63
+ Requires-Dist: nltk>=3.9.1; extra == "ifeval"
64
+ Provides-Extra: neuronx
65
+ Requires-Dist: optimum[neuronx]; extra == "neuronx"
66
+ Provides-Extra: mamba
67
+ Requires-Dist: mamba_ssm; extra == "mamba"
68
+ Requires-Dist: causal-conv1d==1.0.2; extra == "mamba"
69
+ Provides-Extra: math
70
+ Requires-Dist: sympy>=1.12; extra == "math"
71
+ Requires-Dist: antlr4-python3-runtime==4.11; extra == "math"
72
+ Provides-Extra: multilingual
73
+ Requires-Dist: nagisa>=0.2.7; extra == "multilingual"
74
+ Requires-Dist: jieba>=0.42.1; extra == "multilingual"
75
+ Requires-Dist: pycountry; extra == "multilingual"
76
+ Provides-Extra: optimum
77
+ Requires-Dist: optimum[openvino]; extra == "optimum"
78
+ Provides-Extra: promptsource
79
+ Requires-Dist: promptsource>=0.2.3; extra == "promptsource"
80
+ Provides-Extra: sentencepiece
81
+ Requires-Dist: sentencepiece>=0.1.98; extra == "sentencepiece"
82
+ Provides-Extra: sparseml
83
+ Requires-Dist: sparseml-nightly[llm]>=1.8.0.20240404; extra == "sparseml"
84
+ Provides-Extra: testing
85
+ Requires-Dist: pytest; extra == "testing"
86
+ Requires-Dist: pytest-cov; extra == "testing"
87
+ Requires-Dist: pytest-xdist; extra == "testing"
88
+ Provides-Extra: vllm
89
+ Requires-Dist: vllm>=0.4.2; extra == "vllm"
90
+ Provides-Extra: zeno
91
+ Requires-Dist: pandas; extra == "zeno"
92
+ Requires-Dist: zeno-client; extra == "zeno"
93
+ Provides-Extra: wandb
94
+ Requires-Dist: wandb>=0.16.3; extra == "wandb"
95
+ Requires-Dist: pandas; extra == "wandb"
96
+ Requires-Dist: numpy; extra == "wandb"
97
+ Provides-Extra: gptqmodel
98
+ Requires-Dist: gptqmodel>=1.0.9; extra == "gptqmodel"
99
+ Provides-Extra: japanese-leaderboard
100
+ Requires-Dist: emoji==2.14.0; extra == "japanese-leaderboard"
101
+ Requires-Dist: neologdn==0.5.3; extra == "japanese-leaderboard"
102
+ Requires-Dist: fugashi[unidic-lite]; extra == "japanese-leaderboard"
103
+ Requires-Dist: rouge_score>=0.1.2; extra == "japanese-leaderboard"
104
+ Provides-Extra: all
105
+ Requires-Dist: lm_eval[anthropic]; extra == "all"
106
+ Requires-Dist: lm_eval[dev]; extra == "all"
107
+ Requires-Dist: lm_eval[deepsparse]; extra == "all"
108
+ Requires-Dist: lm_eval[gptq]; extra == "all"
109
+ Requires-Dist: lm_eval[hf_transfer]; extra == "all"
110
+ Requires-Dist: lm_eval[ibm_watsonx_ai]; extra == "all"
111
+ Requires-Dist: lm_eval[ifeval]; extra == "all"
112
+ Requires-Dist: lm_eval[mamba]; extra == "all"
113
+ Requires-Dist: lm_eval[math]; extra == "all"
114
+ Requires-Dist: lm_eval[multilingual]; extra == "all"
115
+ Requires-Dist: lm_eval[openai]; extra == "all"
116
+ Requires-Dist: lm_eval[promptsource]; extra == "all"
117
+ Requires-Dist: lm_eval[sentencepiece]; extra == "all"
118
+ Requires-Dist: lm_eval[sparseml]; extra == "all"
119
+ Requires-Dist: lm_eval[testing]; extra == "all"
120
+ Requires-Dist: lm_eval[vllm]; extra == "all"
121
+ Requires-Dist: lm_eval[zeno]; extra == "all"
122
+ Requires-Dist: lm_eval[wandb]; extra == "all"
123
+ Requires-Dist: lm_eval[japanese_leaderboard]; extra == "all"
124
+ Dynamic: license-file
125
+
126
+ # Language Model Evaluation Harness
127
+
128
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10256836.svg)](https://doi.org/10.5281/zenodo.10256836)
129
+
130
+ ---
131
+
132
+ *Latest News 📣*
133
+
134
+ - [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.
135
+ - [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.**
136
+ - [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.
137
+
138
+ ---
139
+
140
+ ## Announcement
141
+ **A new v0.4.0 release of lm-evaluation-harness is available** !
142
+
143
+ New updates and features include:
144
+
145
+ - **New Open LLM Leaderboard tasks have been added ! You can find them under the [leaderboard](lm_eval/tasks/leaderboard/README.md) task group.**
146
+ - Internal refactoring
147
+ - Config-based task creation and configuration
148
+ - Easier import and sharing of externally-defined task config YAMLs
149
+ - Support for Jinja2 prompt design, easy modification of prompts + prompt imports from Promptsource
150
+ - More advanced configuration options, including output post-processing, answer extraction, and multiple LM generations per document, configurable fewshot settings, and more
151
+ - Speedups and new modeling libraries supported, including: faster data-parallel HF model usage, vLLM support, MPS support with HuggingFace, and more
152
+ - Logging and usability changes
153
+ - New tasks including CoT BIG-Bench-Hard, Belebele, user-defined task groupings, and more
154
+
155
+ Please see our updated documentation pages in `docs/` for more details.
156
+
157
+ 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)!
158
+
159
+ ---
160
+
161
+ ## Overview
162
+
163
+ This project provides a unified framework to test generative language models on a large number of different evaluation tasks.
164
+
165
+ **Features:**
166
+ - Over 60 standard academic benchmarks for LLMs, with hundreds of subtasks and variants implemented.
167
+ - 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.
168
+ - Support for fast and memory-efficient inference with [vLLM](https://github.com/vllm-project/vllm).
169
+ - Support for commercial APIs including [OpenAI](https://openai.com), and [TextSynth](https://textsynth.com/).
170
+ - Support for evaluation on adapters (e.g. LoRA) supported in [HuggingFace's PEFT library](https://github.com/huggingface/peft).
171
+ - Support for local models and benchmarks.
172
+ - Evaluation with publicly available prompts ensures reproducibility and comparability between papers.
173
+ - Easy support for custom prompts and evaluation metrics.
174
+
175
+ 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.
176
+
177
+ ## Install
178
+
179
+ To install the `lm-eval` package from the github repository, run:
180
+
181
+ ```bash
182
+ git clone --depth 1 https://github.com/EleutherAI/lm-evaluation-harness
183
+ cd lm-evaluation-harness
184
+ pip install -e .
185
+ ```
186
+
187
+ We also provide a number of optional dependencies for extended functionality. A detailed table is available at the end of this document.
188
+
189
+ ## Basic Usage
190
+ ### User Guide
191
+
192
+ 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`.
193
+
194
+ 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).
195
+
196
+ ### Hugging Face `transformers`
197
+
198
+ 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):
199
+
200
+ ```bash
201
+ lm_eval --model hf \
202
+ --model_args pretrained=EleutherAI/gpt-j-6B \
203
+ --tasks hellaswag \
204
+ --device cuda:0 \
205
+ --batch_size 8
206
+ ```
207
+
208
+ 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:
209
+
210
+ ```bash
211
+ lm_eval --model hf \
212
+ --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
213
+ --tasks lambada_openai,hellaswag \
214
+ --device cuda:0 \
215
+ --batch_size 8
216
+ ```
217
+
218
+ 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.
219
+
220
+ 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:
221
+
222
+ ```bash
223
+ lm_eval --model hf \
224
+ --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
225
+ --tasks lambada_openai,hellaswag \
226
+ --device cuda:0 \
227
+ --batch_size auto:4
228
+ ```
229
+
230
+ > [!Note]
231
+ > 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`
232
+
233
+ #### Multi-GPU Evaluation with Hugging Face `accelerate`
234
+
235
+ We support three main ways of using Hugging Face's [accelerate 🚀](https://github.com/huggingface/accelerate) library for multi-GPU evaluation.
236
+
237
+ To perform *data-parallel evaluation* (where each GPU loads a **separate full copy** of the model), we leverage the `accelerate` launcher as follows:
238
+
239
+ ```
240
+ accelerate launch -m lm_eval --model hf \
241
+ --tasks lambada_openai,arc_easy \
242
+ --batch_size 16
243
+ ```
244
+ (or via `accelerate launch --no-python lm_eval`).
245
+
246
+ 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.
247
+
248
+ **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.
249
+
250
+ The second way of using `accelerate` for multi-GPU evaluation is when your model is *too large to fit on a single GPU.*
251
+
252
+ In this setting, run the library *outside the `accelerate` launcher*, but passing `parallelize=True` to `--model_args` as follows:
253
+
254
+ ```
255
+ lm_eval --model hf \
256
+ --tasks lambada_openai,arc_easy \
257
+ --model_args parallelize=True \
258
+ --batch_size 16
259
+ ```
260
+
261
+ This means that your model's weights will be split across all available GPUs.
262
+
263
+ For more advanced users or even larger models, we allow for the following arguments when `parallelize=True` as well:
264
+ - `device_map_option`: How to split model weights across available GPUs. defaults to "auto".
265
+ - `max_memory_per_gpu`: the max GPU memory to use per GPU in loading the model.
266
+ - `max_cpu_memory`: the max amount of CPU memory to use when offloading the model weights to RAM.
267
+ - `offload_folder`: a folder where model weights will be offloaded to disk if needed.
268
+
269
+ 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.
270
+
271
+ ```
272
+ accelerate launch --multi_gpu --num_processes {nb_of_copies_of_your_model} \
273
+ -m lm_eval --model hf \
274
+ --tasks lambada_openai,arc_easy \
275
+ --model_args parallelize=True \
276
+ --batch_size 16
277
+ ```
278
+
279
+ 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)
280
+
281
+ **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.**
282
+
283
+ **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).**
284
+
285
+ ### NVIDIA `nemo` models
286
+
287
+ [NVIDIA NeMo Framework](https://github.com/NVIDIA/NeMo) is a generative AI framework built for researchers and pytorch developers working on language models.
288
+
289
+ 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).
290
+
291
+ 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`.
292
+
293
+ Run a `nemo` model on one GPU:
294
+ ```bash
295
+ lm_eval --model nemo_lm \
296
+ --model_args path=<path_to_nemo_model> \
297
+ --tasks hellaswag \
298
+ --batch_size 32
299
+ ```
300
+
301
+ 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:
302
+
303
+ ```
304
+ mkdir MY_MODEL
305
+ tar -xvf MY_MODEL.nemo -c MY_MODEL
306
+ ```
307
+
308
+ #### Multi-GPU evaluation with NVIDIA `nemo` models
309
+
310
+ By default, only one GPU is used. But we do support either data replication or tensor/pipeline parallelism during evaluation, on one node.
311
+
312
+ 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:
313
+ ```bash
314
+ torchrun --nproc-per-node=8 --no-python lm_eval \
315
+ --model nemo_lm \
316
+ --model_args path=<path_to_nemo_model>,devices=8 \
317
+ --tasks hellaswag \
318
+ --batch_size 32
319
+ ```
320
+
321
+ 2) 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:
322
+ ```bash
323
+ torchrun --nproc-per-node=4 --no-python lm_eval \
324
+ --model nemo_lm \
325
+ --model_args path=<path_to_nemo_model>,devices=4,tensor_model_parallel_size=2,pipeline_model_parallel_size=2 \
326
+ --tasks hellaswag \
327
+ --batch_size 32
328
+ ```
329
+ 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.
330
+
331
+ Not supported yet: multi-node evaluation and combinations of data replication with tensor or pipeline parallelism.
332
+
333
+ ### Tensor + Data Parallel and Optimized Inference with `vLLM`
334
+
335
+ 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:
336
+
337
+ ```bash
338
+ lm_eval --model vllm \
339
+ --model_args pretrained={model_name},tensor_parallel_size={GPUs_per_model},dtype=auto,gpu_memory_utilization=0.8,data_parallel_size={model_replicas} \
340
+ --tasks lambada_openai \
341
+ --batch_size auto
342
+ ```
343
+ 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.
344
+
345
+ 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.
346
+
347
+ > [!Tip]
348
+ > For fastest performance, we recommend using `--batch_size auto` for vLLM whenever possible, to leverage its continuous batching functionality!
349
+
350
+ > [!Tip]
351
+ > 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.
352
+
353
+ ### Model APIs and Inference Servers
354
+
355
+ 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.
356
+
357
+ To call a hosted model, use:
358
+
359
+ ```bash
360
+ export OPENAI_API_KEY=YOUR_KEY_HERE
361
+ lm_eval --model openai-completions \
362
+ --model_args model=davinci \
363
+ --tasks lambada_openai,hellaswag
364
+ ```
365
+
366
+ We also support using your own local inference server with servers that mirror the OpenAI Completions and ChatCompletions APIs.
367
+
368
+ ```bash
369
+ 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
370
+ ```
371
+ 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.
372
+
373
+ | API or Inference Server | Implemented? | `--model <xxx>` name | Models supported: | Request Types: |
374
+ |---------------------------------------------------------------------------------------------------------------------------|---------------------------------|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
375
+ | OpenAI Completions | :heavy_check_mark: | `openai-completions`, `local-completions` | All OpenAI Completions API models | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
376
+ | 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) |
377
+ | Anthropic | :heavy_check_mark: | `anthropic` | [Supported Anthropic Engines](https://docs.anthropic.com/claude/reference/selecting-a-model) | `generate_until` (no logprobs) |
378
+ | 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) |
379
+ | Textsynth | :heavy_check_mark: | `textsynth` | [All supported engines](https://textsynth.com/documentation.html#engines) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
380
+ | 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` |
381
+ | [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) |
382
+ | 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` |
383
+ | 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` |
384
+ | Huggingface Optimum (Causal LMs) | ✔️ | `openvino` | Any decoder-only AutoModelForCausalLM converted with Huggingface Optimum into OpenVINO™ Intermediate Representation (IR) format | `generate_until`, `loglikelihood`, `loglikelihood_rolling` | ... |
385
+ | Neuron via AWS Inf2 (Causal LMs) | ✔️ | `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` | ... |
386
+ | [Neural Magic DeepSparse](https://github.com/neuralmagic/deepsparse) | ✔️ | `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` | ... |
387
+ | [Neural Magic SparseML](https://github.com/neuralmagic/sparseml) | ✔️ | `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` | ... |
388
+ | Your local inference server! | :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` | | ... |
389
+
390
+ 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`.
391
+
392
+ 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).
393
+
394
+ > [!Note]
395
+ > 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.
396
+
397
+
398
+ ### Other Frameworks
399
+
400
+ 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).
401
+
402
+ 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).
403
+
404
+ ### Additional Features
405
+ > [!Note]
406
+ > 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.
407
+
408
+ 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.**
409
+
410
+ > [!Note]
411
+ > You can inspect what the LM inputs look like by running the following command:
412
+ > ```bash
413
+ > python write_out.py \
414
+ > --tasks <task1,task2,...> \
415
+ > --num_fewshot 5 \
416
+ > --num_examples 10 \
417
+ > --output_base_path /path/to/output/folder
418
+ > ```
419
+ > This will write out one text file for each task.
420
+
421
+ 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:
422
+
423
+ ```bash
424
+ lm_eval --model openai \
425
+ --model_args engine=davinci \
426
+ --tasks lambada_openai,hellaswag \
427
+ --check_integrity
428
+ ```
429
+
430
+ ## Advanced Usage Tips
431
+
432
+ 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:
433
+ ```bash
434
+ lm_eval --model hf \
435
+ --model_args pretrained=EleutherAI/gpt-j-6b,parallelize=True,load_in_4bit=True,peft=nomic-ai/gpt4all-j-lora \
436
+ --tasks openbookqa,arc_easy,winogrande,hellaswag,arc_challenge,piqa,boolq \
437
+ --device cuda:0
438
+ ```
439
+
440
+ 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:
441
+ ```bash
442
+ lm_eval --model hf \
443
+ --model_args pretrained=Ejafa/llama_7B,delta=lmsys/vicuna-7b-delta-v1.1 \
444
+ --tasks hellaswag
445
+ ```
446
+
447
+ GPTQ quantized models can be loaded using [GPTQModel](https://github.com/ModelCloud/GPTQModel) (faster) or [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ)
448
+
449
+ GPTQModel: add `,gptqmodel=True` to `model_args`
450
+ ```bash
451
+ lm_eval --model hf \
452
+ --model_args pretrained=model-name-or-path,gptqmodel=True \
453
+ --tasks hellaswag
454
+ ```
455
+
456
+ AutoGPTQ: add `,autogptq=True` to `model_args`:
457
+ ```bash
458
+ lm_eval --model hf \
459
+ --model_args pretrained=model-name-or-path,autogptq=model.safetensors,gptq_use_triton=True \
460
+ --tasks hellaswag
461
+ ```
462
+
463
+ We support wildcards in task names, for example you can run all of the machine-translated lambada tasks via `--task lambada_openai_mt_*`.
464
+
465
+ ## Saving Results
466
+
467
+ To save evaluation results provide an `--output_path`. We also support logging model responses with the `--log_samples` flag for post-hoc analysis.
468
+
469
+ Additionally, one can provide a directory with `--use_cache` to cache the results of prior runs. This allows you to avoid repeated execution of the same (model, task) pairs for re-scoring.
470
+
471
+ 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:
472
+
473
+ ```bash
474
+ lm_eval --model hf \
475
+ --model_args pretrained=model-name-or-path,autogptq=model.safetensors,gptq_use_triton=True \
476
+ --tasks hellaswag \
477
+ --log_samples \
478
+ --output_path results \
479
+ --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 \
480
+ ```
481
+
482
+ This allows you to easily download the results and samples from the Hub, using:
483
+ ```python
484
+ from datasets import load_dataset
485
+
486
+ load_dataset("EleutherAI/lm-eval-results-private", "hellaswag", "latest")
487
+ ```
488
+
489
+ 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!
490
+
491
+ ## Visualizing Results
492
+
493
+ You can seamlessly visualize and analyze the results of your evaluation harness runs using both Weights & Biases (W&B) and Zeno.
494
+
495
+ ### Zeno
496
+
497
+ You can use [Zeno](https://zenoml.com) to visualize the results of your eval harness runs.
498
+
499
+ 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).
500
+ Add this key as an environment variable:
501
+
502
+ ```bash
503
+ export ZENO_API_KEY=[your api key]
504
+ ```
505
+
506
+ You'll also need to install the `lm_eval[zeno]` package extra.
507
+
508
+ To visualize the results, run the eval harness with the `log_samples` and `output_path` flags.
509
+ We expect `output_path` to contain multiple folders that represent individual model names.
510
+ You can thus run your evaluation on any number of tasks and models and upload all of the results as projects on Zeno.
511
+
512
+ ```bash
513
+ lm_eval \
514
+ --model hf \
515
+ --model_args pretrained=EleutherAI/gpt-j-6B \
516
+ --tasks hellaswag \
517
+ --device cuda:0 \
518
+ --batch_size 8 \
519
+ --log_samples \
520
+ --output_path output/gpt-j-6B
521
+ ```
522
+
523
+ Then, you can upload the resulting data using the `zeno_visualize` script:
524
+
525
+ ```bash
526
+ python scripts/zeno_visualize.py \
527
+ --data_path output \
528
+ --project_name "Eleuther Project"
529
+ ```
530
+
531
+ This will use all subfolders in `data_path` as different models and upload all tasks within these model folders to Zeno.
532
+ 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.
533
+
534
+ You can find an example of this workflow in [examples/visualize-zeno.ipynb](examples/visualize-zeno.ipynb).
535
+
536
+ ### Weights and Biases
537
+
538
+ 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.
539
+
540
+ The integration provide functionalities
541
+
542
+ - to automatically log the evaluation results,
543
+ - log the samples as W&B Tables for easy visualization,
544
+ - log the `results.json` file as an artifact for version control,
545
+ - log the `<task_name>_eval_samples.json` file if the samples are logged,
546
+ - generate a comprehensive report for analysis and visualization with all the important metric,
547
+ - log task and cli specific configs,
548
+ - and more out of the box like the command used to run the evaluation, GPU/CPU counts, timestamp, etc.
549
+
550
+ First you'll need to install the lm_eval[wandb] package extra. Do `pip install lm_eval[wandb]`.
551
+
552
+ 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.
553
+
554
+ 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.
555
+
556
+ ```bash
557
+ lm_eval \
558
+ --model hf \
559
+ --model_args pretrained=microsoft/phi-2,trust_remote_code=True \
560
+ --tasks hellaswag,mmlu_abstract_algebra \
561
+ --device cuda:0 \
562
+ --batch_size 8 \
563
+ --output_path output/phi-2 \
564
+ --limit 10 \
565
+ --wandb_args project=lm-eval-harness-integration \
566
+ --log_samples
567
+ ```
568
+
569
+ 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.
570
+
571
+ ## How to Contribute or Learn More?
572
+
573
+ 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.
574
+
575
+ ### Implementing new tasks
576
+
577
+ To implement a new task in the eval harness, see [this guide](./docs/new_task_guide.md).
578
+
579
+ In general, we follow this priority list for addressing concerns about prompting and other eval details:
580
+ 1. If there is widespread agreement among people who train LLMs, use the agreed upon procedure.
581
+ 2. If there is a clear and unambiguous official implementation, use that procedure.
582
+ 3. If there is widespread agreement among people who evaluate LLMs, use the agreed upon procedure.
583
+ 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.
584
+
585
+ These are guidelines and not rules, and can be overruled in special circumstances.
586
+
587
+ 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.
588
+
589
+ ### Support
590
+
591
+ 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!
592
+
593
+ ## Optional Extras
594
+ Extras dependencies can be installed via `pip install -e ".[NAME]"`
595
+
596
+ | Name | Use |
597
+ |-----------------|----------------------------------------------|
598
+ | api | For using api models (Anthropic, OpenAI API) |
599
+ | deepsparse | For running NM's DeepSparse models |
600
+ | dev | For linting PRs and contributions |
601
+ | gptq | For loading models with GPTQ |
602
+ | hf_transfer | For speeding up HF Hub file downloads |
603
+ | ifeval | For running the IFEval task |
604
+ | neuronx | For running on AWS inf2 instances |
605
+ | mamba | For loading Mamba SSM models |
606
+ | math | For running math task answer checking |
607
+ | multilingual | For multilingual tokenizers |
608
+ | optimum | For running Intel OpenVINO models |
609
+ | promptsource | For using PromptSource prompts |
610
+ | sentencepiece | For using the sentencepiece tokenizer |
611
+ | sparseml | For using NM's SparseML models |
612
+ | testing | For running library test suite |
613
+ | vllm | For loading models with vLLM |
614
+ | zeno | For visualizing results with Zeno |
615
+ | --------------- | --------------------------------------- |
616
+ | all | Loads all extras (not recommended) |
617
+
618
+ ## Cite as
619
+
620
+ ```
621
+ @misc{eval-harness,
622
+ 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},
623
+ title = {A framework for few-shot language model evaluation},
624
+ month = 07,
625
+ year = 2024,
626
+ publisher = {Zenodo},
627
+ version = {v0.4.3},
628
+ doi = {10.5281/zenodo.12608602},
629
+ url = {https://zenodo.org/records/12608602}
630
+ }
631
+ ```
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/SOURCES.txt ADDED
The diff for this file is too large to render. See raw diff
 
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
lm-quant-toolkit/.deps/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-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/requires.txt ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate>=0.26.0
2
+ evaluate
3
+ datasets>=2.16.0
4
+ evaluate>=0.4.0
5
+ jsonlines
6
+ numexpr
7
+ peft>=0.2.0
8
+ pybind11>=2.6.2
9
+ pytablewriter
10
+ rouge-score>=0.0.4
11
+ sacrebleu>=1.5.0
12
+ scikit-learn>=0.24.1
13
+ sqlitedict
14
+ torch>=1.8
15
+ tqdm-multiprocess
16
+ transformers>=4.1
17
+ zstandard
18
+ dill
19
+ word2number
20
+ more_itertools
21
+
22
+ [all]
23
+ lm_eval[anthropic]
24
+ lm_eval[dev]
25
+ lm_eval[deepsparse]
26
+ lm_eval[gptq]
27
+ lm_eval[hf_transfer]
28
+ lm_eval[ibm_watsonx_ai]
29
+ lm_eval[ifeval]
30
+ lm_eval[mamba]
31
+ lm_eval[math]
32
+ lm_eval[multilingual]
33
+ lm_eval[openai]
34
+ lm_eval[promptsource]
35
+ lm_eval[sentencepiece]
36
+ lm_eval[sparseml]
37
+ lm_eval[testing]
38
+ lm_eval[vllm]
39
+ lm_eval[zeno]
40
+ lm_eval[wandb]
41
+ lm_eval[japanese_leaderboard]
42
+
43
+ [api]
44
+ requests
45
+ aiohttp
46
+ tenacity
47
+ tqdm
48
+ tiktoken
49
+
50
+ [awq]
51
+ auto-awq>=0.2.6
52
+
53
+ [deepsparse]
54
+ deepsparse-nightly[llm]>=1.8.0.20240404
55
+
56
+ [dev]
57
+ pytest
58
+ pytest-cov
59
+ pytest-xdist
60
+ pre-commit
61
+ mypy
62
+
63
+ [gptq]
64
+ auto-gptq[triton]>=0.6.0
65
+
66
+ [gptqmodel]
67
+ gptqmodel>=1.0.9
68
+
69
+ [hf_transfer]
70
+ hf_transfer
71
+
72
+ [hqq]
73
+ hqq>=0.2.1
74
+
75
+ [ibm_watsonx_ai]
76
+ ibm_watsonx_ai>=1.1.22
77
+
78
+ [ifeval]
79
+ langdetect
80
+ immutabledict
81
+ nltk>=3.9.1
82
+
83
+ [japanese_leaderboard]
84
+ emoji==2.14.0
85
+ neologdn==0.5.3
86
+ fugashi[unidic-lite]
87
+ rouge_score>=0.1.2
88
+
89
+ [mamba]
90
+ mamba_ssm
91
+ causal-conv1d==1.0.2
92
+
93
+ [math]
94
+ sympy>=1.12
95
+ antlr4-python3-runtime==4.11
96
+
97
+ [multilingual]
98
+ nagisa>=0.2.7
99
+ jieba>=0.42.1
100
+ pycountry
101
+
102
+ [neuronx]
103
+ optimum[neuronx]
104
+
105
+ [optimum]
106
+ optimum[openvino]
107
+
108
+ [promptsource]
109
+ promptsource>=0.2.3
110
+
111
+ [sentencepiece]
112
+ sentencepiece>=0.1.98
113
+
114
+ [sparseml]
115
+ sparseml-nightly[llm]>=1.8.0.20240404
116
+
117
+ [testing]
118
+ pytest
119
+ pytest-cov
120
+ pytest-xdist
121
+
122
+ [vllm]
123
+ vllm>=0.4.2
124
+
125
+ [wandb]
126
+ wandb>=0.16.3
127
+ pandas
128
+ numpy
129
+
130
+ [zeno]
131
+ pandas
132
+ zeno-client
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ lm_eval
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_moral_scenarios.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_moral_scenarios"
2
+ "description": "The following are multiple choice questions (with answers) about moral\
3
+ \ scenarios.\n\n"
4
+ "tag": "mmlusr_question_only_humanities_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_moral_scenarios"
7
+ "task_alias": "moral scenarios"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_prehistory.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_prehistory"
2
+ "description": "The following are multiple choice questions (with answers) about prehistory.\n\
3
+ \n"
4
+ "tag": "mmlusr_question_only_humanities_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_prehistory"
7
+ "task_alias": "prehistory"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_professional_medicine.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_professional_medicine"
2
+ "description": "The following are multiple choice questions (with answers) about professional\
3
+ \ medicine.\n\n"
4
+ "tag": "mmlusr_question_only_other_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_professional_medicine"
7
+ "task_alias": "professional medicine"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_public_relations.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_public_relations"
2
+ "description": "The following are multiple choice questions (with answers) about public\
3
+ \ relations.\n\n"
4
+ "tag": "mmlusr_question_only_social_sciences_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_public_relations"
7
+ "task_alias": "public relations"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_sociology.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_sociology"
2
+ "description": "The following are multiple choice questions (with answers) about sociology.\n\
3
+ \n"
4
+ "tag": "mmlusr_question_only_social_sciences_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_sociology"
7
+ "task_alias": "sociology"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_us_foreign_policy.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_us_foreign_policy"
2
+ "description": "The following are multiple choice questions (with answers) about us\
3
+ \ foreign policy.\n\n"
4
+ "tag": "mmlusr_question_only_social_sciences_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_us_foreign_policy"
7
+ "task_alias": "us foreign policy"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_virology.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_virology"
2
+ "description": "The following are multiple choice questions (with answers) about virology.\n\
3
+ \n"
4
+ "tag": "mmlusr_question_only_other_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_virology"
7
+ "task_alias": "virology"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/question_only_world_religions.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "dataset_name": "question_only_world_religions"
2
+ "description": "The following are multiple choice questions (with answers) about world\
3
+ \ religions.\n\n"
4
+ "tag": "mmlusr_question_only_humanities_tasks"
5
+ "include": "_mmlusr_q_yml"
6
+ "task": "mmlusr_question_only_world_religions"
7
+ "task_alias": "world religions"
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmlusr/question_only/utils.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ def process_docs(dataset: datasets.Dataset) -> datasets.Dataset:
5
+ def _helper(doc):
6
+ # Assuming that the 'answer' field in the dataset now contains numbers 0-3 instead of 'A', 'B', 'C', 'D'
7
+ answer_list = ["A", "B", "C", "D"]
8
+ # Convert numeric index to corresponding letter
9
+ answer_index = int(doc["answer"]) # Make sure the answer is an integer
10
+ answer_letter = answer_list[answer_index]
11
+
12
+ out_doc = {
13
+ "questions": doc["question"],
14
+ "choices": [doc["choice1"], doc["choice2"], doc["choice3"], doc["choice4"]],
15
+ "answer": answer_letter, # Include the letter for clarity
16
+ }
17
+ return out_doc
18
+
19
+ return dataset.map(_helper)
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/_tech_and_engineering.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ group: mmmu_val_tech_and_engineering
2
+ group_alias: Tech and Engineering
3
+ task:
4
+ - mmmu_val_agriculture
5
+ - mmmu_val_architecture_and_engineering
6
+ - mmmu_val_computer_science
7
+ - mmmu_val_electronics
8
+ - mmmu_val_energy_and_power
9
+ - mmmu_val_materials
10
+ - mmmu_val_mechanical_engineering
11
+ aggregate_metric_list:
12
+ - metric: acc
13
+ aggregation: mean
14
+ weight_by_size: true
15
+ metadata:
16
+ version: 0.0
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_accounting.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_accounting
2
+ include: _template_yaml
3
+ task_alias: Accounting
4
+ dataset_name: Accounting
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_agriculture.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_agriculture
2
+ include: _template_yaml
3
+ task_alias: Agriculture
4
+ dataset_name: Agriculture
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_architecture_and_engineering.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_architecture_and_engineering
2
+ include: _template_yaml
3
+ task_alias: Architecture and Engineering
4
+ dataset_name: Architecture_and_Engineering
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_art_theory.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_art_theory
2
+ include: _template_yaml
3
+ task_alias: Art Theory
4
+ dataset_name: Art_Theory
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_biology.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_biology
2
+ include: _template_yaml
3
+ task_alias: Biology
4
+ dataset_name: Biology
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_chemistry.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_chemistry
2
+ include: _template_yaml
3
+ task_alias: Chemistry
4
+ dataset_name: Chemistry
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_computer_science.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_computer_science
2
+ include: _template_yaml
3
+ task_alias: Computer Science
4
+ dataset_name: Computer_Science
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_economics.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_economics
2
+ include: _template_yaml
3
+ task_alias: Economics
4
+ dataset_name: Economics
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_electronics.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_electronics
2
+ include: _template_yaml
3
+ task_alias: Electronics
4
+ dataset_name: Electronics
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_finance.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_finance
2
+ include: _template_yaml
3
+ task_alias: Finance
4
+ dataset_name: Finance
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_geography.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_geography
2
+ include: _template_yaml
3
+ task_alias: Geography
4
+ dataset_name: Geography
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_history.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_history
2
+ include: _template_yaml
3
+ task_alias: History
4
+ dataset_name: History
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_manage.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_manage
2
+ include: _template_yaml
3
+ task_alias: Manage
4
+ dataset_name: Manage
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_marketing.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_marketing
2
+ include: _template_yaml
3
+ task_alias: Marketing
4
+ dataset_name: Marketing
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_materials.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_materials
2
+ include: _template_yaml
3
+ task_alias: Materials
4
+ dataset_name: Materials
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_math.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_math
2
+ include: _template_yaml
3
+ task_alias: Math
4
+ dataset_name: Math
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_mechanical_engineering.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_mechanical_engineering
2
+ include: _template_yaml
3
+ task_alias: Mechanical Engineering
4
+ dataset_name: Mechanical_Engineering
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_music.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_music
2
+ include: _template_yaml
3
+ task_alias: Music
4
+ dataset_name: Music
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_pharmacy.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_pharmacy
2
+ include: _template_yaml
3
+ task_alias: Pharmacy
4
+ dataset_name: Pharmacy
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_physics.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_physics
2
+ include: _template_yaml
3
+ task_alias: Physics
4
+ dataset_name: Physics
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_psychology.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_psychology
2
+ include: _template_yaml
3
+ task_alias: Psychology
4
+ dataset_name: Psychology
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_public_health.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_public_health
2
+ include: _template_yaml
3
+ task_alias: Public Health
4
+ dataset_name: Public_Health
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/mmmu_sociology.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ task: mmmu_val_sociology
2
+ include: _template_yaml
3
+ task_alias: Sociology
4
+ dataset_name: Sociology
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/mmmu/utils.py ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ast
2
+ import random
3
+ import re
4
+
5
+ import numpy as np
6
+
7
+
8
+ random.seed(42)
9
+
10
+
11
+ # source for prompt fstrings: https://github.com/MMMU-Benchmark/MMMU/blob/7787d60648c82a9d40acd656fa541a6c74f58995/eval/configs/llava1.5.yaml#L3
12
+ MULTI_CHOICE_EXAMPLE_FORMAT = """{}
13
+
14
+ {}
15
+
16
+ Answer with the option's letter from the given choices directly."""
17
+
18
+
19
+ SHORT_ANS_EXAMPLE_FORMAT = """{}
20
+
21
+ Answer the question using a single word or phrase."""
22
+
23
+ START_CHR = "A"
24
+
25
+
26
+ def doc_to_image(doc):
27
+ # get formatted prompt (incl. multi-choice options) pre-<image {i}> reformatting
28
+ input_text = _doc_to_text(doc)
29
+ # locate <image {i}> instances in input
30
+ image_placeholders = [
31
+ img.replace(" ", "_").replace("<", "").replace(">", "")
32
+ for img in re.findall("<image [1-7]>", input_text)
33
+ ]
34
+
35
+ # collect visuals (can have dupes of a given image or be out of order)
36
+ # E.g. validation_Math_19 contains <image 1> and <image 2> but seen as [<image 1>, <image 2>, <image 1>, <image 1>, <image 2>]
37
+ visuals = [doc[img] for img in image_placeholders]
38
+
39
+ return visuals
40
+
41
+
42
+ def doc_to_text(doc):
43
+ """Get the prompt for a given document."""
44
+
45
+ prompt = _doc_to_text(doc)
46
+
47
+ for i in range(1, 8):
48
+ # replace <image {i}> with <image>. TODO: check this is always the right decision incl. for non-HF models
49
+ prompt = prompt.replace(f"<image {i}>", "<image>")
50
+
51
+ return prompt
52
+
53
+
54
+ def _doc_to_text(doc):
55
+ """Helper--get the prompt for a given document but DO NOT yet replace <image {i}> with <image>."""
56
+
57
+ if doc["question_type"] == "multiple-choice":
58
+ choices_str = ""
59
+
60
+ for i, choice in enumerate(ast.literal_eval(doc["options"])):
61
+ # add (A) {choice1}\n , (B) {choice2}\n , and so on
62
+ # to create the list of formatted choices in the prompt
63
+ choices_str += f"\n({chr(ord(START_CHR) + i)}) {choice}"
64
+
65
+ choices_str = (
66
+ choices_str.lstrip()
67
+ ) # remove the extraneous prepended \n that we added
68
+
69
+ prompt = MULTI_CHOICE_EXAMPLE_FORMAT.format(doc["question"], choices_str)
70
+ else:
71
+ prompt = SHORT_ANS_EXAMPLE_FORMAT.format(doc["question"])
72
+
73
+ return prompt
74
+
75
+
76
+ def process_results(doc, results):
77
+ if doc["question_type"] == "multiple-choice":
78
+ # multichoice logic
79
+ option_strs = ast.literal_eval(doc["options"])
80
+ option_letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]
81
+
82
+ all_choices = option_letters[: len(option_strs)]
83
+ index2ans = {index: ans for index, ans in zip(option_letters, option_strs)}
84
+
85
+ pred = parse_multi_choice_response(results[0], all_choices, index2ans)
86
+ # print(pred, all_choices, index2ans)
87
+ is_correct = eval_multi_choice(doc["answer"], pred)
88
+ else:
89
+ # freeform response handling
90
+ pred = parse_open_response(results[0])
91
+ is_correct = eval_open(doc["answer"], pred)
92
+
93
+ return {"acc": float(is_correct)}
94
+
95
+ # TODO: it would be better if we could use a Filter for this logic.
96
+
97
+
98
+ ### Output parsing and answer selection taken from
99
+ ### https://github.com/MMMU-Benchmark/MMMU/blob/main/eval/utils/data_utils.py
100
+ ### and
101
+ ### https://github.com/MMMU-Benchmark/MMMU/blob/main/eval/utils/eval_utils.py
102
+
103
+
104
+ # ----------- Process Multi-choice -------------
105
+ def parse_multi_choice_response(response, all_choices, index2ans):
106
+ """
107
+ Parse the prediction from the generated response.
108
+ Return the predicted index e.g., A, B, C, D.
109
+ """
110
+ for char in [",", ".", "!", "?", ";", ":", "'"]:
111
+ response = response.strip(char)
112
+ response = " " + response + " " # add space to avoid partial match
113
+
114
+ index_ans = True
115
+ ans_with_brack = False
116
+ candidates = []
117
+ for choice in all_choices: # e.g., (A) (B) (C) (D)
118
+ if f"({choice})" in response:
119
+ candidates.append(choice)
120
+ ans_with_brack = True
121
+
122
+ if len(candidates) == 0:
123
+ for choice in all_choices: # e.g., A B C D
124
+ if f" {choice} " in response:
125
+ candidates.append(choice)
126
+
127
+ # if all above doesn't get candidates, check if the content is larger than 5 tokens and try to parse the example
128
+ if len(candidates) == 0 and len(response.split()) > 5:
129
+ for index, ans in index2ans.items():
130
+ if ans.lower() in response.lower():
131
+ candidates.append(index)
132
+ index_ans = False # it's content ans.
133
+
134
+ if len(candidates) == 0: # still not get answer, randomly choose one.
135
+ pred_index = random.choice(all_choices)
136
+ elif len(candidates) > 1:
137
+ start_indexes = []
138
+ if index_ans:
139
+ if ans_with_brack:
140
+ for can in candidates:
141
+ index = response.rfind(f"({can})")
142
+ start_indexes.append(index) # -1 will be ignored anyway
143
+ # start_indexes = [generated_response.index(f'({can})') for can in candidates]
144
+ else:
145
+ for can in candidates:
146
+ index = response.rfind(f" {can} ")
147
+ start_indexes.append(index)
148
+ else:
149
+ for can in candidates:
150
+ index = response.lower().rfind(index2ans[can].lower())
151
+ start_indexes.append(index)
152
+ # get the last one
153
+ pred_index = candidates[np.argmax(start_indexes)]
154
+ else: # if only one candidate, use it.
155
+ pred_index = candidates[0]
156
+
157
+ # print(response, all_choices, index2ans, pred_index)
158
+
159
+ return pred_index
160
+
161
+
162
+ # ----------- Process Open -------------
163
+ def check_is_number(string):
164
+ """
165
+ Check if the given string a number.
166
+ """
167
+ try:
168
+ float(string.replace(",", ""))
169
+ return True
170
+ except ValueError:
171
+ # check if there's comma inside
172
+ return False
173
+
174
+
175
+ def normalize_str(string):
176
+ """
177
+ Normalize the str to lower case and make them float numbers if possible.
178
+ """
179
+ # check if characters in the string
180
+
181
+ # if number, numerize it.
182
+ string = string.strip()
183
+
184
+ is_number = check_is_number(string)
185
+
186
+ if is_number:
187
+ string = string.replace(",", "")
188
+ string = float(string)
189
+ # leave 2 decimal
190
+ string = round(string, 2)
191
+ return [string]
192
+ else: # it's likely to be a string
193
+ # lower it
194
+ string = string.lower()
195
+ if len(string) == 1:
196
+ return [" " + string, string + " "] # avoid trivial matches
197
+ return [string]
198
+
199
+
200
+ def extract_numbers(string):
201
+ """
202
+ Exact all forms of numbers from a string with regex.
203
+ """
204
+ # Pattern for numbers with commas
205
+ pattern_commas = r"-?\b\d{1,3}(?:,\d{3})+\b"
206
+ # Pattern for scientific notation
207
+ pattern_scientific = r"-?\d+(?:\.\d+)?[eE][+-]?\d+"
208
+ # Pattern for simple numbers without commas
209
+ pattern_simple = r"-?(?:\d+\.\d+|\.\d+|\d+\b)(?![eE][+-]?\d+)(?![,\d])"
210
+
211
+ # Extract numbers with commas
212
+ numbers_with_commas = re.findall(pattern_commas, string)
213
+ # Extract numbers in scientific notation
214
+ numbers_scientific = re.findall(pattern_scientific, string)
215
+ # Extract simple numbers without commas
216
+ numbers_simple = re.findall(pattern_simple, string)
217
+
218
+ # Combine all extracted numbers
219
+ all_numbers = numbers_with_commas + numbers_scientific + numbers_simple
220
+ return all_numbers
221
+
222
+
223
+ def parse_open_response(response):
224
+ """
225
+ Parse the prediction from the generated response.
226
+ Return a list of predicted strings or numbers.
227
+ """
228
+
229
+ # content = content.strip("\n").strip(".").strip(" ")
230
+ def get_key_subresponses(response):
231
+ key_responses = []
232
+ response = response.strip().strip(".").lower()
233
+ sub_responses = re.split(r"\.\s(?=[A-Z])|\n", response)
234
+ indicators_of_keys = [
235
+ "could be ",
236
+ "so ",
237
+ "is ",
238
+ "thus ",
239
+ "therefore ",
240
+ "final ",
241
+ "answer ",
242
+ "result ",
243
+ ]
244
+ key_responses = []
245
+ for index, resp in enumerate(sub_responses):
246
+ # if last one, accept it's an equation (the entire response can be just one sentence with equation)
247
+ if index == len(sub_responses) - 1:
248
+ indicators_of_keys.extend(["="])
249
+ shortest_key_response = None # the shortest response that may contain the answer (tail part of the response)
250
+ for indicator in indicators_of_keys:
251
+ if indicator in resp:
252
+ if not shortest_key_response:
253
+ shortest_key_response = resp.split(indicator)[-1].strip()
254
+ else:
255
+ if len(resp.split(indicator)[-1].strip()) < len(
256
+ shortest_key_response
257
+ ):
258
+ shortest_key_response = resp.split(indicator)[-1].strip()
259
+ # key_responses.append(resp.split(indicator)[1].strip())
260
+
261
+ if shortest_key_response:
262
+ # and it's not trivial
263
+ if shortest_key_response.strip() not in [
264
+ ":",
265
+ ",",
266
+ ".",
267
+ "!",
268
+ "?",
269
+ ";",
270
+ ":",
271
+ "'",
272
+ ]:
273
+ key_responses.append(shortest_key_response)
274
+ if len(key_responses) == 0: # did not found any
275
+ return [response]
276
+ return key_responses
277
+
278
+ # pdb.set_trace()
279
+ key_responses = get_key_subresponses(response)
280
+
281
+ pred_list = key_responses.copy() # keep the original string response
282
+ for resp in key_responses:
283
+ pred_list.extend(extract_numbers(resp))
284
+
285
+ tmp_pred_list = []
286
+ for i in range(len(pred_list)):
287
+ tmp_pred_list.extend(normalize_str(pred_list[i]))
288
+ pred_list = tmp_pred_list
289
+
290
+ # remove duplicates
291
+ pred_list = list(set(pred_list))
292
+
293
+ return pred_list
294
+
295
+
296
+ # ----------- Evaluation -------------
297
+
298
+
299
+ def eval_multi_choice(gold_i, pred_i):
300
+ """
301
+ Evaluate a multiple choice instance.
302
+ """
303
+ correct = False
304
+ # only they are exactly the same, we consider it as correct
305
+ if isinstance(gold_i, list):
306
+ for answer in gold_i:
307
+ if answer == pred_i:
308
+ correct = True
309
+ break
310
+ else: # gold_i is a string
311
+ if gold_i == pred_i:
312
+ correct = True
313
+ return correct
314
+
315
+
316
+ def eval_open(gold_i, pred_i):
317
+ """
318
+ Evaluate an open question instance
319
+ """
320
+ correct = False
321
+ if isinstance(gold_i, list):
322
+ # use float to avoid trivial matches
323
+ norm_answers = []
324
+ for answer in gold_i:
325
+ norm_answers.extend(normalize_str(answer))
326
+ else:
327
+ norm_answers = normalize_str(gold_i)
328
+ for pred in pred_i: # pred is already normalized in parse response phase
329
+ if isinstance(pred, str): # if it's a string, then find if ans in the pred_i
330
+ for norm_ans in norm_answers:
331
+ # only see if the string answer in the string pred
332
+ if isinstance(norm_ans, str) and norm_ans in pred:
333
+ if not correct:
334
+ correct = True
335
+ break
336
+ else: # it's a float number
337
+ if pred in norm_answers:
338
+ if not correct:
339
+ correct = True
340
+ break
341
+ return correct
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/_generate_configs.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import yaml
3
+ from tqdm import tqdm
4
+
5
+
6
+ def main() -> None:
7
+ dataset_path = "EleutherAI/advanced_ai_risk"
8
+ for task in tqdm(datasets.get_dataset_infos(dataset_path).keys()):
9
+ file_name = f"{task}.yaml"
10
+ try:
11
+ with open(f"{file_name}", "w", encoding="utf-8") as f:
12
+ f.write("# Generated by _generate_configs.py\n")
13
+ yaml.dump(
14
+ {
15
+ "include": "_template_yaml",
16
+ "task": f"{dataset_path.split('/')[-1]}_{task}",
17
+ "dataset_name": task,
18
+ },
19
+ f,
20
+ )
21
+ except FileExistsError:
22
+ pass
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/_template_yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tag: advanced_ai_risk
2
+ dataset_path: EleutherAI/advanced_ai_risk
3
+ output_type: multiple_choice
4
+ validation_split: validation
5
+ target_delimiter: ""
6
+ doc_to_text: "Human: {{question}}\n\nAssistant:"
7
+ doc_to_target: 0
8
+ doc_to_choice: "{{[answer_matching_behavior, answer_not_matching_behavior]}}"
9
+ should_decontaminate: true
10
+ doc_to_decontamination_query: "{{sentence_good}} {{sentence_bad}}"
11
+ metric_list:
12
+ - metric: acc
13
+ metadata:
14
+ version: 0.0
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-coordinate-itself.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-coordinate-itself
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-coordinate-itself
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-coordinate-other-ais.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-coordinate-other-ais
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-coordinate-other-ais
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-coordinate-other-versions.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-coordinate-other-versions
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-coordinate-other-versions
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-corrigible-less-HHH.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-corrigible-less-HHH
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-corrigible-less-HHH
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-corrigible-more-HHH.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-corrigible-more-HHH
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-corrigible-more-HHH
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-corrigible-neutral-HHH.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-corrigible-neutral-HHH
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-corrigible-neutral-HHH
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-myopic-reward.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-myopic-reward
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-myopic-reward
lm-quant-toolkit/.deps/lm-evaluation-harness/lm_eval/tasks/model_written_evals/advanced_ai_risk/fewshot-one-box-tendency.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Generated by _generate_configs.py
2
+ dataset_name: fewshot-one-box-tendency
3
+ include: _template_yaml
4
+ task: advanced_ai_risk_fewshot-one-box-tendency