andylizf commited on
Commit
596a7dd
·
verified ·
1 Parent(s): 5229d52

Add files using upload-large-folder tool

Browse files
Files changed (48) hide show
  1. .gitignore +17 -0
  2. LICENSE +9 -0
  3. README.md +41 -0
  4. environment.yml +23 -0
  5. environment_cpu.yml +21 -0
  6. rag-evaluation-harness/.ruff_cache/.gitignore +2 -0
  7. rag-evaluation-harness/.ruff_cache/0.9.3/12497227915877661989 +0 -0
  8. rag-evaluation-harness/.ruff_cache/0.9.3/13009521113904868118 +0 -0
  9. rag-evaluation-harness/.ruff_cache/0.9.3/13018255539392570457 +0 -0
  10. rag-evaluation-harness/.ruff_cache/0.9.3/13260690385340709809 +0 -0
  11. rag-evaluation-harness/.ruff_cache/0.9.3/14258240626412663540 +0 -0
  12. rag-evaluation-harness/.ruff_cache/0.9.3/15315625201596957191 +0 -0
  13. rag-evaluation-harness/.ruff_cache/0.9.3/16235238253187924481 +0 -0
  14. rag-evaluation-harness/.ruff_cache/0.9.3/17287004733396064123 +0 -0
  15. rag-evaluation-harness/.ruff_cache/0.9.3/17738703691150684628 +0 -0
  16. rag-evaluation-harness/.ruff_cache/0.9.3/18289216023326981818 +0 -0
  17. rag-evaluation-harness/.ruff_cache/0.9.3/2824316663215431511 +0 -0
  18. rag-evaluation-harness/.ruff_cache/0.9.3/3339812563487441321 +0 -0
  19. rag-evaluation-harness/.ruff_cache/0.9.3/4137547663692349761 +0 -0
  20. rag-evaluation-harness/.ruff_cache/0.9.3/4535488150702217992 +0 -0
  21. rag-evaluation-harness/.ruff_cache/0.9.3/4953005745711364485 +0 -0
  22. rag-evaluation-harness/.ruff_cache/0.9.3/5322625832671211361 +0 -0
  23. rag-evaluation-harness/.ruff_cache/0.9.3/6253952776861180621 +0 -0
  24. rag-evaluation-harness/.ruff_cache/0.9.3/6567089652757018024 +0 -0
  25. rag-evaluation-harness/.ruff_cache/0.9.3/9372526017794670499 +0 -0
  26. rag-evaluation-harness/.ruff_cache/CACHEDIR.TAG +1 -0
  27. rag-evaluation-harness/CODEOWNERS +1 -0
  28. rag-evaluation-harness/README.md +561 -0
  29. rag-evaluation-harness/lm_eval/evaluator.py +921 -0
  30. rag-evaluation-harness/lm_eval/tasks/anli/anli_r1.yaml +26 -0
  31. rag-evaluation-harness/lm_eval/tasks/anli/anli_r2.yaml +5 -0
  32. rag-evaluation-harness/lm_eval/tasks/csatqa/csatqa_li.yaml +3 -0
  33. rag-evaluation-harness/lm_eval/tasks/csatqa/utils.py +20 -0
  34. rag-evaluation-harness/lm_eval/tasks/french_bench/french_bench_multifquad.yaml +34 -0
  35. rag-evaluation-harness/lm_eval/tasks/xnli/xnli_ar.yaml +7 -0
  36. rag-evaluation-harness/lm_eval/tasks/xnli/xnli_bg.yaml +7 -0
  37. rag-evaluation-harness/lm_eval/tasks/xnli/xnli_es.yaml +7 -0
  38. rag-evaluation-harness/lm_eval/tasks/xnli/xnli_tr.yaml +7 -0
  39. rag-evaluation-harness/lm_eval/tasks/xnli/xnli_ur.yaml +7 -0
  40. rag-evaluation-harness/mypy.ini +29 -0
  41. rag-evaluation-harness/pyproject.toml +109 -0
  42. rag-evaluation-harness/setup.py +5 -0
  43. recall_acc_results/_a/.gitignore +1 -0
  44. recall_acc_results/_a/_b/recall_acc_results_Llama-3.2-1B-Instruct_dpr_nlist8192.json +94 -0
  45. recall_acc_results/_a/real/recall_acc_results_Llama-3.1-8B-Instruct_rpj_wiki_nlist8192.json +88 -0
  46. recall_acc_results/_a/real/recall_acc_results_Llama-3.2-1B-Instruct_dpr_nlist8192.json +98 -0
  47. recall_acc_results/_a/real/recall_acc_results_Llama-3.2-1B-Instruct_rpj_wiki_nlist8192.json +39 -0
  48. recall_acc_results/_a/valid/recall_acc_results_Llama-3.2-1B_dpr_nlist8192.json +97 -0
.gitignore ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ raw_data/
2
+ scaling_out/
3
+ scaling_out_old/
4
+ sanity_check/
5
+ demo/indices/
6
+ # .vscode/
7
+ *.log
8
+ *pycache*
9
+ outputs/
10
+ *.pkl
11
+ .history/
12
+ scripts/
13
+ lm_eval.egg-info/
14
+ demo/experiment_results/**/*.json
15
+ *.jsonl
16
+ *.sh
17
+ *.txt
LICENSE ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Rulin Shao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Core
2
+
3
+ `python ./demo/retrieval_demo.py` The main entrypoint.
4
+
5
+ `python ./demo/generation_demo.py`
6
+
7
+ `python ./demo/evaluation_demo.py`
8
+
9
+ ## Script
10
+
11
+ `python ./demo/generation_experiment.py {diff_k, diff_dp}` to see how different k and different dp sizes affect the generation time and ttft (if not batch mode). See #8, result figures in #9 and #15.
12
+
13
+ `python ./demo/validate_equivalence.py {sglang, vllm}` to generate answers and evaluate based on the prompts and retrieved passages in `scaling_out/retrieved_results/facebook/contriever-msmarco/fineweb_edu_1m_datastore-256_chunk_size-1of1_shards/top_3/0/nq_open_retrieved_results.jsonl`. See #6 and #10.
14
+
15
+ `python ./demo/test_serve.py` to test the serve demo. You should open a server by `python ./demo/retrieval_demo.py serve` first. And currently the test_serve:main is sending requests in a pattern to show the breakdowns of different index types. We might change it in the future to test more scenarios. See #7 and #8.
16
+
17
+ ## Install DiskANN
18
+
19
+ First build the project as [DiskANN/README.md](DiskANN/README.md). Use CMake to build the project, and the result will be in `./DiskANN/build/`.
20
+
21
+ ```bash
22
+ pip install -e .
23
+ ```
24
+
25
+ ## Restrict the RAM
26
+
27
+ ```bash
28
+ sudo mkdir -p /sys/fs/cgroup/memory/16gb
29
+ sudo mkdir -p /sys/fs/cgroup/memory/32gb
30
+ ```
31
+
32
+ ```bash
33
+ sudo sh -c 'echo 16000000000 > /sys/fs/cgroup/memory/16gb/memory.limit_in_bytes'
34
+ sudo sh -c 'echo 16000000000 > /sys/fs/cgroup/memory/16gb/memory.memsw.limit_in_bytes'
35
+ sudo sh -c 'echo 32000000000 > /sys/fs/cgroup/memory/32gb/memory.limit_in_bytes'
36
+ sudo sh -c 'echo 32000000000 > /sys/fs/cgroup/memory/32gb/memory.memsw.limit_in_bytes'
37
+ ```
38
+
39
+ ```bash
40
+ sudo sh -c 'echo $$ > /sys/fs/cgroup/memory/32gb/cgroup.procs && /home/ubuntu/miniconda3/envs/scaling/bin/python demo/retrieval_demo.py --skip-passages --skip-embeddings --domain rpj_wiki --search-only --load-indices ivf_disk'
41
+ ```
environment.yml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: scaling
2
+ channels:
3
+ - pytorch
4
+ - nvidia
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - python=3.11
9
+ - numpy
10
+ - faiss-gpu=1.8.0
11
+ - openjdk=17
12
+
13
+ - pip:
14
+ - omegaconf
15
+ - hydra-core
16
+ - torch
17
+ - tqdm
18
+ - transformers
19
+ - sentence_transformers
20
+ - pyserini
21
+ - datasketch
22
+ - torch
23
+ - vllm
environment_cpu.yml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: scaling_cpu
2
+ channels:
3
+ - pytorch
4
+ - nvidia
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - python=3.11
9
+ - numpy
10
+ - pytorch
11
+ - cpuonly
12
+ - faiss-cpu=1.8.0
13
+
14
+ - pip:
15
+ - omegaconf
16
+ - hydra-core
17
+ - tqdm
18
+ - transformers
19
+ - sentence_transformers
20
+ - pyserini
21
+ - datasketch
rag-evaluation-harness/.ruff_cache/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Automatically created by ruff.
2
+ *
rag-evaluation-harness/.ruff_cache/0.9.3/12497227915877661989 ADDED
Binary file (137 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/13009521113904868118 ADDED
Binary file (145 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/13018255539392570457 ADDED
Binary file (157 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/13260690385340709809 ADDED
Binary file (150 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/14258240626412663540 ADDED
Binary file (149 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/15315625201596957191 ADDED
Binary file (998 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/16235238253187924481 ADDED
Binary file (186 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/17287004733396064123 ADDED
Binary file (132 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/17738703691150684628 ADDED
Binary file (142 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/18289216023326981818 ADDED
Binary file (143 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/2824316663215431511 ADDED
Binary file (135 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/3339812563487441321 ADDED
Binary file (140 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/4137547663692349761 ADDED
Binary file (139 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/4535488150702217992 ADDED
Binary file (1.97 kB). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/4953005745711364485 ADDED
Binary file (134 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/5322625832671211361 ADDED
Binary file (150 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/6253952776861180621 ADDED
Binary file (173 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/6567089652757018024 ADDED
Binary file (134 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/0.9.3/9372526017794670499 ADDED
Binary file (137 Bytes). View file
 
rag-evaluation-harness/.ruff_cache/CACHEDIR.TAG ADDED
@@ -0,0 +1 @@
 
 
1
+ Signature: 8a477f597d28d172789f06886806bc55
rag-evaluation-harness/CODEOWNERS ADDED
@@ -0,0 +1 @@
 
 
1
+ * @haileyschoelkopf @lintangsutawika
rag-evaluation-harness/README.md ADDED
@@ -0,0 +1,561 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Retrieval Augmented Generation (RAG) Evaluation Harness
2
+ Adapted From [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness)
3
+
4
+ This repository supports RAG evaluation on all downstream tasks supported in lm-evaluation-harnesses as of Jun 10, 2024.
5
+
6
+ ## Installation
7
+ ```bash
8
+ git clone https://github.com/RulinShao/rag-evaluation-harness.git
9
+ cd rag-evaluation-harness
10
+ conda create -n lm-eval python=3.11
11
+ pip install -e .
12
+ ```
13
+ To use with VLLMs, also install
14
+ ```bash
15
+ pip install lm_eval[vllm]
16
+ ```
17
+
18
+ ## Basic Usage
19
+ We provide an example script to evaluate HuggingFace model with retrieval augmentation. Please refer to the below full documentation for LM-only evaluation and advanced usage.
20
+
21
+ #### Step 1: Prepare retrieved documents.
22
+ Users can easily obtain all evaluation inputs without few-shot demonstration, i.e., queries, by running
23
+ ```bash
24
+ lm_eval --tasks "triviaqa" --inputs_save_dir "inputs" --save_inputs_only
25
+ ```
26
+ This will save the inputs of TriviaQA in `inputs/triviaqa.jsonl` in a format of
27
+ ```json
28
+ {"query": "Question: Who was the man behind The Chipmunks??\nAnswer:"}
29
+ {"query": "Question: Which Lloyd Webber musical premiered in the US on 10th December 1993??\nAnswer:"}
30
+ ...
31
+ ```
32
+ These inputs can be used as queries for retrieval.
33
+ We assume retrieval is done offline before evaluation. Please save your retrieval augmentations in a jsonl file, in a format of
34
+ ```json
35
+ {
36
+ "query": "Question: Who was the man behind The Chipmunks??\nAnswer:",
37
+ "ctxs": [
38
+ {"retrieval text": "Doc_0"},
39
+ {"retrieval text": "Doc_1"},
40
+ ...
41
+ ]
42
+ }
43
+ ...
44
+ ```
45
+ where `ctxs` is a list of retrieved documents from the most relevant to the least relevant that will be used for evaluation.
46
+
47
+ #### Step 2: Evaluation.
48
+ To run evaluation with the retrieved documents obatined at step 1:
49
+ ```bash
50
+ MODEL_NAME_OR_PATH="meta-llama/Meta-Llama-3-8B"
51
+ TASK="triviaqa"
52
+ RETRIEVED_DOCS=/path/to/your/jsonl # JSONL file obtained in Step 1
53
+
54
+ lm_eval --model hf \
55
+ --model_args pretrained=$MODEL_NAME_OR_PATH \
56
+ --tasks $TASK \
57
+ --device cuda:0 \
58
+ --batch_size auto \
59
+ --retrieval_file $RETRIEVED_DOCS \
60
+ --concat_k 1
61
+ ```
62
+ where `concat_k` specifies the number of documents that will be prepended in context when running evaluation. Set `concat_k=0` will degrade it to LM-only evaluation.
63
+
64
+ Note: we use a simple prompt format for retrieval-augmented evaluation, where we prepend the retrieved documents before the input and few-shot examples in reverse order, i.e., `<DOC_k>...<DOC_0><FEWSHOT_m>...<FEWSHOT_0><QUESTION>`. Users can personalize their prompt format by modifying [this line](https://github.com/RulinShao/RAG-evaluation-harnesses/blob/main/lm_eval/evaluator.py#L500).
65
+
66
+ ## Q&A
67
+ **Q: What tasks have been supported?**
68
+
69
+ A: We refer to [this section](https://github.com/RulinShao/RAG-evaluation-harnesses#user-guide) to review a full list of supported tasks. We have benchmarked MMLU, TriviaQA, Natural Questions, MedQA, etc. with retrieval augmentations using this repository. If you run into issue with any other task, please file an issue ticket and we will work on it.
70
+
71
+ **Q: Can I add new evaluation tasks?**
72
+
73
+ A: Yes! Lm-evaluation-harnesses support convenient integration of new tasks. You can add new tasks with HF datasets simply by defining a new configuration yaml file in [this folder](https://github.com/RulinShao/RAG-evaluation-harnesses/tree/main/lm_eval/tasks). We welcome PRs to supplement more tasks for RAG evaluation.
74
+
75
+ **Q: I got OOM, what should I do?**
76
+
77
+ A: If you are evaluating a large model, we recommend to use VLLM and turn on model parallelism. We refer to [this section](https://github.com/RulinShao/RAG-evaluation-harnesses/tree/main#tensor--data-parallel-and-optimized-inference-with-vllm) for more details.
78
+
79
+
80
+ # Language Model Evaluation Harness
81
+
82
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10256836.svg)](https://doi.org/10.5281/zenodo.10256836)
83
+
84
+ ## Announcement
85
+ **A new v0.4.0 release of lm-evaluation-harness is available** !
86
+
87
+ New updates and features include:
88
+
89
+ - Internal refactoring
90
+ - Config-based task creation and configuration
91
+ - Easier import and sharing of externally-defined task config YAMLs
92
+ - Support for Jinja2 prompt design, easy modification of prompts + prompt imports from Promptsource
93
+ - More advanced configuration options, including output post-processing, answer extraction, and multiple LM generations per document, configurable fewshot settings, and more
94
+ - Speedups and new modeling libraries supported, including: faster data-parallel HF model usage, vLLM support, MPS support with HuggingFace, and more
95
+ - Logging and usability changes
96
+ - New tasks including CoT BIG-Bench-Hard, Belebele, user-defined task groupings, and more
97
+
98
+ Please see our updated documentation pages in `docs/` for more details.
99
+
100
+ 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)!
101
+
102
+ ## Overview
103
+
104
+ This project provides a unified framework to test generative language models on a large number of different evaluation tasks.
105
+
106
+ **Features:**
107
+ - Over 60 standard academic benchmarks for LLMs, with hundreds of subtasks and variants implemented.
108
+ - Support for models loaded via [transformers](https://github.com/huggingface/transformers/) (including quantization via [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.
109
+ - Support for fast and memory-efficient inference with [vLLM](https://github.com/vllm-project/vllm).
110
+ - Support for commercial APIs including [OpenAI](https://openai.com), and [TextSynth](https://textsynth.com/).
111
+ - Support for evaluation on adapters (e.g. LoRA) supported in [HuggingFace's PEFT library](https://github.com/huggingface/peft).
112
+ - Support for local models and benchmarks.
113
+ - Evaluation with publicly available prompts ensures reproducibility and comparability between papers.
114
+ - Easy support for custom prompts and evaluation metrics.
115
+
116
+ 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.
117
+
118
+ ## Install
119
+
120
+ To install the `lm-eval` package from the github repository, run:
121
+
122
+ ```bash
123
+ git clone https://github.com/EleutherAI/lm-evaluation-harness
124
+ cd lm-evaluation-harness
125
+ pip install -e .
126
+ ```
127
+
128
+ We also provide a number of optional dependencies for extended functionality. A detailed table is available at the end of this document.
129
+
130
+ ## Basic Usage
131
+ ### User Guide
132
+
133
+ 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`.
134
+
135
+ 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).
136
+
137
+ ### Hugging Face `transformers`
138
+
139
+ 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):
140
+
141
+ ```bash
142
+ lm_eval --model hf \
143
+ --model_args pretrained=EleutherAI/gpt-j-6B \
144
+ --tasks hellaswag \
145
+ --device cuda:0 \
146
+ --batch_size 8
147
+ ```
148
+
149
+ 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:
150
+
151
+ ```bash
152
+ lm_eval --model hf \
153
+ --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
154
+ --tasks lambada_openai,hellaswag \
155
+ --device cuda:0 \
156
+ --batch_size 8
157
+ ```
158
+
159
+ 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.
160
+
161
+ 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:
162
+
163
+ ```bash
164
+ lm_eval --model hf \
165
+ --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
166
+ --tasks lambada_openai,hellaswag \
167
+ --device cuda:0 \
168
+ --batch_size auto:4
169
+ ```
170
+
171
+ > [!Note]
172
+ > 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`
173
+
174
+ #### Multi-GPU Evaluation with Hugging Face `accelerate`
175
+
176
+ We support two main ways of using Hugging Face's [accelerate 🚀](https://github.com/huggingface/accelerate) library for multi-GPU evaluation.
177
+
178
+ To perform *data-parallel evaluation* (where each GPU loads a **separate full copy** of the model), we leverage the `accelerate` launcher as follows:
179
+
180
+ ```
181
+ accelerate launch -m lm_eval --model hf \
182
+ --tasks lambada_openai,arc_easy \
183
+ --batch_size 16
184
+ ```
185
+ (or via `accelerate launch --no-python lm_eval`).
186
+
187
+ 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.
188
+
189
+ **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.
190
+
191
+ The second way of using `accelerate` for multi-GPU evaluation is when your model is *too large to fit on a single GPU.*
192
+
193
+ In this setting, run the library *outside of the `accelerate` launcher*, but passing `parallelize=True` to `--model_args` as follows:
194
+
195
+ ```
196
+ lm_eval --model hf \
197
+ --tasks lambada_openai,arc_easy \
198
+ --model_args parallelize=True \
199
+ --batch_size 16
200
+ ```
201
+
202
+ This means that your model's weights will be split across all available GPUs.
203
+
204
+ For more advanced users or even larger models, we allow for the following arguments when `parallelize=True` as well:
205
+ - `device_map_option`: How to split model weights across available GPUs. defaults to "auto".
206
+ - `max_memory_per_gpu`: the max GPU memory to use per GPU in loading the model.
207
+ - `max_cpu_memory`: the max amount of CPU memory to use when offloading the model weights to RAM.
208
+ - `offload_folder`: a folder where model weights will be offloaded to disk if needed.
209
+
210
+ These two options (`accelerate launch` and `parallelize=True`) are mutually exclusive.
211
+
212
+ **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).**
213
+
214
+ ### NVIDIA `nemo` models
215
+
216
+ [NVIDIA NeMo Framework](https://github.com/NVIDIA/NeMo) is a generative AI framework built for researchers and pytorch developers working on language models.
217
+
218
+ 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).
219
+
220
+ 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`.
221
+
222
+ Run a `nemo` model on one GPU:
223
+ ```bash
224
+ lm_eval --model nemo_lm \
225
+ --model_args path=<path_to_nemo_model> \
226
+ --tasks hellaswag \
227
+ --batch_size 32
228
+ ```
229
+
230
+ 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:
231
+
232
+ ```
233
+ mkdir MY_MODEL
234
+ tar -xvf MY_MODEL.nemo -c MY_MODEL
235
+ ```
236
+
237
+ #### Multi-GPU evaluation with NVIDIA `nemo` models
238
+
239
+ By default, only one GPU is used. But we do support either data replication or tensor/pipeline parallelism during evaluation, on one node.
240
+
241
+ 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:
242
+ ```bash
243
+ torchrun --nproc-per-node=8 --no-python lm_eval \
244
+ --model nemo_lm \
245
+ --model_args path=<path_to_nemo_model>,devices=8 \
246
+ --tasks hellaswag \
247
+ --batch_size 32
248
+ ```
249
+
250
+ 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:
251
+ ```bash
252
+ torchrun --nproc-per-node=4 --no-python lm_eval \
253
+ --model nemo_lm \
254
+ --model_args path=<path_to_nemo_model>,devices=4,tensor_model_parallel_size=2,pipeline_model_parallel_size=2 \
255
+ --tasks hellaswag \
256
+ --batch_size 32
257
+ ```
258
+ 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.
259
+
260
+ Not supported yet: multi-node evaluation and combinations of data replication with tensor or pipeline parallelism.
261
+
262
+ ### Tensor + Data Parallel and Optimized Inference with `vLLM`
263
+
264
+ 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:
265
+
266
+ ```bash
267
+ lm_eval --model vllm \
268
+ --model_args pretrained={model_name},tensor_parallel_size={GPUs_per_model},dtype=auto,gpu_memory_utilization=0.8,data_parallel_size={model_replicas} \
269
+ --tasks lambada_openai \
270
+ --batch_size auto
271
+ ```
272
+ 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.
273
+
274
+ 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.
275
+
276
+ > [!Tip]
277
+ > For fastest performance, we recommend using `--batch_size auto` for vLLM whenever possible, to leverage its continuous batching functionality!
278
+
279
+ > [!Tip]
280
+ > 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.
281
+
282
+ ### Model APIs and Inference Servers
283
+
284
+ 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.
285
+
286
+ To call a hosted model, use:
287
+
288
+ ```bash
289
+ export OPENAI_API_KEY=YOUR_KEY_HERE
290
+ lm_eval --model openai-completions \
291
+ --model_args model=davinci \
292
+ --tasks lambada_openai,hellaswag
293
+ ```
294
+
295
+ We also support using your own local inference server with servers that mirror the OpenAI Completions and ChatCompletions APIs.
296
+
297
+ ```bash
298
+ lm_eval --model local-chat-completions --tasks gsm8k --model_args model=facebook/opt-125m,base_url=http://{yourip}:8000/v1
299
+ ```
300
+ Note that for externally hosted models, configs such as `--device` and `--batch_size` 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.
301
+
302
+ | API or Inference Server | Implemented? | `--model <xxx>` name | Models supported: | Request Types: |
303
+ |---------------------------------------------------------------------------------------------------------------------------|---------------------------------|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|------------------------------------------------------------|
304
+ | OpenAI Completions | :heavy_check_mark: | `openai-completions`, `local-completions` | All OpenAI Completions API models | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
305
+ | 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) |
306
+ | Anthropic | :heavy_check_mark: | `anthropic` | [Supported Anthropic Engines](https://docs.anthropic.com/claude/reference/selecting-a-model) | `generate_until` (no logprobs) |
307
+ | 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) |
308
+ | Textsynth | :heavy_check_mark: | `textsynth` | [All supported engines](https://textsynth.com/documentation.html#engines) | `generate_until`, `loglikelihood`, `loglikelihood_rolling` |
309
+ | 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` |
310
+ | [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) |
311
+ | 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` |
312
+ | 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` |
313
+ | Huggingface Optimum (Causal LMs) | ✔️ | `openvino` | Any decoder-only AutoModelForCausalLM converted with Huggingface Optimum into OpenVINO™ Intermediate Representation (IR) format | `generate_until`, `loglikelihood`, `loglikelihood_rolling` | ... |
314
+ | 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` | ... |
315
+ | [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` | ... |
316
+ | [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` | ... |
317
+ | Your local inference server! | :heavy_check_mark: | `local-completions` or `local-chat-completions` (using `openai-chat-completions` model type) | Any server address that accepts GET requests using HF models and mirror's OpenAI's Completions or ChatCompletions interface | `generate_until` | | ... |
318
+
319
+ 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`.
320
+
321
+ 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).
322
+
323
+ > [!Note]
324
+ > 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.
325
+
326
+
327
+ ### Other Frameworks
328
+
329
+ 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).
330
+
331
+ 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).
332
+
333
+ ### Additional Features
334
+ > [!Note]
335
+ > 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.
336
+
337
+ 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.**
338
+
339
+ > [!Note]
340
+ > You can inspect what the LM inputs look like by running the following command:
341
+ > ```bash
342
+ > python write_out.py \
343
+ > --tasks <task1,task2,...> \
344
+ > --num_fewshot 5 \
345
+ > --num_examples 10 \
346
+ > --output_base_path /path/to/output/folder
347
+ > ```
348
+ > This will write out one text file for each task.
349
+
350
+ 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:
351
+
352
+ ```bash
353
+ lm_eval --model openai \
354
+ --model_args engine=davinci \
355
+ --tasks lambada_openai,hellaswag \
356
+ --check_integrity
357
+ ```
358
+
359
+ ## Advanced Usage Tips
360
+
361
+ 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:
362
+ ```bash
363
+ lm_eval --model hf \
364
+ --model_args pretrained=EleutherAI/gpt-j-6b,parallelize=True,load_in_4bit=True,peft=nomic-ai/gpt4all-j-lora \
365
+ --tasks openbookqa,arc_easy,winogrande,hellaswag,arc_challenge,piqa,boolq \
366
+ --device cuda:0
367
+ ```
368
+
369
+ 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:
370
+ ```bash
371
+ lm_eval --model hf \
372
+ --model_args pretrained=Ejafa/llama_7B,delta=lmsys/vicuna-7b-delta-v1.1 \
373
+ --tasks hellaswag
374
+ ```
375
+
376
+ [GPTQ](https://github.com/PanQiWei/AutoGPTQ) quantized models can be loaded by specifying their file names in `,autogptq=NAME` (or `,autogptq=True` for default names) in the `model_args` argument:
377
+
378
+ ```bash
379
+ lm_eval --model hf \
380
+ --model_args pretrained=model-name-or-path,autogptq=model.safetensors,gptq_use_triton=True \
381
+ --tasks hellaswag
382
+ ```
383
+
384
+ We support wildcards in task names, for example you can run all of the machine-translated lambada tasks via `--task lambada_openai_mt_*`.
385
+
386
+ ## Saving Results
387
+
388
+ To save evaluation results provide an `--output_path`. We also support logging model responses with the `--log_samples` flag for post-hoc analysis.
389
+
390
+ 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.
391
+
392
+ 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:
393
+
394
+ ```bash
395
+ lm_eval --model hf \
396
+ --model_args pretrained=model-name-or-path,autogptq=model.safetensors,gptq_use_triton=True \
397
+ --tasks hellaswag \
398
+ --log_samples \
399
+ --output_path results \
400
+ --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 \
401
+ ```
402
+
403
+ This allows you to easily download the results and samples from the Hub, using:
404
+ ```python
405
+ from datasets import load_dataset
406
+
407
+ load_dataset("EleutherAI/lm-eval-results-private", "hellaswag", "latest")
408
+ ```
409
+
410
+ 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!
411
+
412
+ ## Visualizing Results
413
+
414
+ You can seamlessly visualize and analyze the results of your evaluation harness runs using both Weights & Biases (W&B) and Zeno.
415
+
416
+ ### Zeno
417
+
418
+ You can use [Zeno](https://zenoml.com) to visualize the results of your eval harness runs.
419
+
420
+ 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).
421
+ Add this key as an environment variable:
422
+
423
+ ```bash
424
+ export ZENO_API_KEY=[your api key]
425
+ ```
426
+
427
+ You'll also need to install the `lm_eval[zeno]` package extra.
428
+
429
+ To visualize the results, run the eval harness with the `log_samples` and `output_path` flags.
430
+ We expect `output_path` to contain multiple folders that represent individual model names.
431
+ You can thus run your evaluation on any number of tasks and models and upload all of the results as projects on Zeno.
432
+
433
+ ```bash
434
+ lm_eval \
435
+ --model hf \
436
+ --model_args pretrained=EleutherAI/gpt-j-6B \
437
+ --tasks hellaswag \
438
+ --device cuda:0 \
439
+ --batch_size 8 \
440
+ --log_samples \
441
+ --output_path output/gpt-j-6B
442
+ ```
443
+
444
+ Then, you can upload the resulting data using the `zeno_visualize` script:
445
+
446
+ ```bash
447
+ python scripts/zeno_visualize.py \
448
+ --data_path output \
449
+ --project_name "Eleuther Project"
450
+ ```
451
+
452
+ This will use all subfolders in `data_path` as different models and upload all tasks within these model folders to Zeno.
453
+ 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.
454
+
455
+ You can find an example of this workflow in [examples/visualize-zeno.ipynb](examples/visualize-zeno.ipynb).
456
+
457
+ ### Weights and Biases
458
+
459
+ 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.
460
+
461
+ The integration provide functionalities
462
+
463
+ - to automatically log the evaluation results,
464
+ - log the samples as W&B Tables for easy visualization,
465
+ - log the `results.json` file as an artifact for version control,
466
+ - log the `<task_name>_eval_samples.json` file if the samples are logged,
467
+ - generate a comprehensive report for analysis and visualization with all the important metric,
468
+ - log task and cli specific configs,
469
+ - and more out of the box like the command used to run the evaluation, GPU/CPU counts, timestamp, etc.
470
+
471
+ First you'll need to install the lm_eval[wandb] package extra. Do `pip install lm_eval[wandb]`.
472
+
473
+ 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.
474
+
475
+ 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.
476
+
477
+ ```bash
478
+ lm_eval \
479
+ --model hf \
480
+ --model_args pretrained=microsoft/phi-2,trust_remote_code=True \
481
+ --tasks hellaswag,mmlu_abstract_algebra \
482
+ --device cuda:0 \
483
+ --batch_size 8 \
484
+ --output_path output/phi-2 \
485
+ --limit 10 \
486
+ --wandb_args project=lm-eval-harness-integration \
487
+ --log_samples
488
+ ```
489
+
490
+ 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.
491
+
492
+ ## How to Contribute or Learn More?
493
+
494
+ 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.
495
+
496
+ ### Implementing new tasks
497
+
498
+ To implement a new task in the eval harness, see [this guide](./docs/new_task_guide.md).
499
+
500
+ In general, we follow this priority list for addressing concerns about prompting and other eval details:
501
+ 1. If there is widespread agreement among people who train LLMs, use the agreed upon procedure.
502
+ 2. If there is a clear and unambiguous official implementation, use that procedure.
503
+ 3. If there is widespread agreement among people who evaluate LLMs, use the agreed upon procedure.
504
+ 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.
505
+
506
+ These are guidelines and not rules, and can be overruled in special circumstances.
507
+
508
+ 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.
509
+
510
+ ### Support
511
+
512
+ 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!
513
+
514
+ ## Optional Extras
515
+ Extras dependencies can be installed via `pip install -e ".[NAME]"`
516
+
517
+ | Name | Use |
518
+ |---------------|---------------------------------------|
519
+ | anthropic | For using Anthropic's models |
520
+ | deepsparse | For running NM's DeepSparse models |
521
+ | dev | For linting PRs and contributions |
522
+ | gptq | For loading models with GPTQ |
523
+ | hf_transfer | For speeding up HF Hub file downloads |
524
+ | ifeval | For running the IFEval task |
525
+ | neuronx | For running on AWS inf2 instances |
526
+ | mamba | For loading Mamba SSM models |
527
+ | math | For running math task answer checking |
528
+ | multilingual | For multilingual tokenizers |
529
+ | openai | For using OpenAI's models |
530
+ | optimum | For running Intel OpenVINO models |
531
+ | promptsource | For using PromptSource prompts |
532
+ | sentencepiece | For using the sentencepiece tokenizer |
533
+ | sparseml | For using NM's SparseML models |
534
+ | testing | For running library test suite |
535
+ | unitxt | For IBM's unitxt dataset tasks |
536
+ | vllm | For loading models with vLLM |
537
+ | zeno | For visualizing results with Zeno |
538
+ |---------------|---------------------------------------|
539
+ | all | Loads all extras (not recommended) |
540
+
541
+ ## Cite as
542
+
543
+ ```
544
+ @article{shao2024scaling,
545
+ title={Scaling Retrieval-Based Language Models with a Trillion-Token Datastore},
546
+ author={Shao, Rulin and He, Jacqueline and Asai, Akari and Shi, Weijia and Dettmers, Tim and Min, Sewon and Zettlemoyer, Luke and Koh, Pang Wei},
547
+ journal={arXiv preprint arXiv:2407.12854},
548
+ year={2024}
549
+ }
550
+
551
+ @misc{eval-harness,
552
+ 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},
553
+ title = {A framework for few-shot language model evaluation},
554
+ month = 12,
555
+ year = 2023,
556
+ publisher = {Zenodo},
557
+ version = {v0.4.0},
558
+ doi = {10.5281/zenodo.10256836},
559
+ url = {https://zenodo.org/records/10256836}
560
+ }
561
+ ```
rag-evaluation-harness/lm_eval/evaluator.py ADDED
@@ -0,0 +1,921 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import itertools
3
+ import json
4
+ import jsonlines
5
+ import logging
6
+ import random
7
+ import time
8
+ from collections import defaultdict
9
+ from typing import TYPE_CHECKING, List, Optional, Union
10
+
11
+ import numpy as np
12
+ import torch
13
+
14
+ import lm_eval.api.metrics
15
+ import lm_eval.api.registry
16
+ import lm_eval.models
17
+ from lm_eval.caching.cache import delete_cache
18
+ from lm_eval.evaluator_utils import (
19
+ consolidate_results,
20
+ get_sample_size,
21
+ get_task_list,
22
+ prepare_print_tasks,
23
+ print_writeout,
24
+ run_task_tests,
25
+ )
26
+ from lm_eval.loggers import EvaluationTracker
27
+ from lm_eval.loggers.utils import add_env_info, get_git_commit_hash
28
+ from lm_eval.tasks import TaskManager, get_task_dict
29
+ from lm_eval.utils import (
30
+ eval_logger,
31
+ handle_non_serializable,
32
+ hash_string,
33
+ positional_deprecated,
34
+ simple_parse_args_string,
35
+ )
36
+
37
+
38
+ if TYPE_CHECKING:
39
+ from lm_eval.api.model import LM
40
+ from lm_eval.tasks import Task
41
+
42
+
43
+ @positional_deprecated
44
+ def simple_evaluate(
45
+ model,
46
+ model_args: Optional[Union[str, dict]] = None,
47
+ tasks: Optional[List[Union[str, dict, object]]] = None,
48
+ num_fewshot: Optional[int] = None,
49
+ batch_size: Optional[int] = None,
50
+ max_batch_size: Optional[int] = None,
51
+ device: Optional[str] = None,
52
+ use_cache: Optional[str] = None,
53
+ cache_requests: bool = False,
54
+ rewrite_requests_cache: bool = False,
55
+ delete_requests_cache: bool = False,
56
+ limit: Optional[Union[int, float]] = None,
57
+ bootstrap_iters: int = 100000,
58
+ check_integrity: bool = False,
59
+ write_out: bool = False,
60
+ log_samples: bool = True,
61
+ evaluation_tracker: Optional[EvaluationTracker] = None,
62
+ system_instruction: Optional[str] = None,
63
+ apply_chat_template: bool = False,
64
+ fewshot_as_multiturn: bool = False,
65
+ gen_kwargs: Optional[str] = None,
66
+ task_manager: Optional[TaskManager] = None,
67
+ verbosity: str = "INFO",
68
+ predict_only: bool = False,
69
+ random_seed: int = 0,
70
+ numpy_random_seed: int = 1234,
71
+ torch_random_seed: int = 1234,
72
+ fewshot_random_seed: int = 1234,
73
+ retrieval_args: dict = {},
74
+ ):
75
+ """Instantiate and evaluate a model on a list of tasks.
76
+
77
+ :param model: Union[str, LM]
78
+ Name of model or LM object, see lm_eval.models.get_model
79
+ :param model_args: Optional[str, dict]
80
+ String or dict arguments for each model class, see LM.create_from_arg_string and LM.create_from_arg_object.
81
+ Ignored if `model` argument is a LM object.
82
+ :param tasks: list[Union[str, dict, Task]]
83
+ List of task names or Task objects. Task objects will be taken to have name task.EVAL_HARNESS_NAME if defined and type(task).__name__ otherwise.
84
+ :param num_fewshot: int
85
+ Number of examples in few-shot context
86
+ :param batch_size: int or str, optional
87
+ Batch size for model
88
+ :param max_batch_size: int, optional
89
+ Maximal batch size to try with automatic batch size detection
90
+ :param device: str, optional
91
+ PyTorch device (e.g. "cpu" or "cuda:0") for running models
92
+ :param use_cache: str, optional
93
+ A path to a sqlite db file for caching model responses. `None` if not caching.
94
+ :param cache_requests: bool, optional
95
+ Speed up evaluation by caching the building of dataset requests. `None` if not caching.
96
+ :param rewrite_requests_cache: bool, optional
97
+ Rewrites all of the request cache if set to `True`. `None` if not desired.
98
+ :param delete_requests_cache: bool, optional
99
+ Deletes all of the request cache if set to `True`. `None` if not desired.
100
+ :param limit: int or float, optional
101
+ Limit the number of examples per task (only use this for testing), If <1, limit is a percentage of the total number of examples.
102
+ :param bootstrap_iters:
103
+ Number of iterations for bootstrap statistics, used when calculating stderrs. set to 0 for no stderr calculations to be performed.
104
+ :param check_integrity: bool
105
+ Whether to run the relevant part of the test suite for the tasks
106
+ :param write_out: bool
107
+ If True, write out an example document and model input for checking task integrity
108
+ :param log_samples: bool
109
+ If True, write out all model outputs and documents for per-sample measurement and post-hoc analysis
110
+ :param system_instruction: str
111
+ System instruction to be applied to the prompt
112
+ :param apply_chat_template: bool
113
+ If True, apply chat template to the prompt
114
+ :param fewshot_as_multiturn: bool
115
+ Whether to provide the fewshot examples as a multiturn conversation or a single user turn.
116
+ :param gen_kwargs: str
117
+ String arguments for model generation
118
+ Ignored for all tasks with loglikelihood output_type
119
+ :param predict_only: bool
120
+ If true only model outputs will be generated and returned. Metrics will not be evaluated
121
+ :param random_seed: int
122
+ Random seed for python's random module. If set to None, the seed will not be set.
123
+ :param numpy_random_seed: int
124
+ Random seed for numpy. If set to None, the seed will not be set.
125
+ :param torch_random_seed: int
126
+ Random seed for torch. If set to None, the seed will not be set.
127
+ :param fewshot_random_seed: int
128
+ Random seed for fewshot sampler random generator. If set to None, the seed of generator will be set to None.
129
+
130
+ :return
131
+ Dictionary of results
132
+
133
+ """
134
+ # os pid print and then sllep 30s
135
+ eval_logger.setLevel(getattr(logging, f"{verbosity}"))
136
+ start_date = time.time()
137
+
138
+ if delete_requests_cache:
139
+ eval_logger.info("Deleting requests cache...")
140
+ delete_cache()
141
+
142
+ seed_message = []
143
+ if random_seed is not None:
144
+ # See https://github.com/EleutherAI/lm-evaluation-harness/pull/1412
145
+ seed_message.append(f"Setting random seed to {random_seed}")
146
+ random.seed(random_seed)
147
+
148
+ if numpy_random_seed is not None:
149
+ seed_message.append(f"Setting numpy seed to {numpy_random_seed}")
150
+ np.random.seed(numpy_random_seed)
151
+
152
+ if torch_random_seed is not None:
153
+ seed_message.append(f"Setting torch manual seed to {torch_random_seed}")
154
+ torch.manual_seed(torch_random_seed)
155
+
156
+ if seed_message:
157
+ eval_logger.info(" | ".join(seed_message))
158
+
159
+ if tasks is None:
160
+ tasks = []
161
+ if len(tasks) == 0:
162
+ raise ValueError(
163
+ "No tasks specified, or no tasks found. Please verify the task names."
164
+ )
165
+
166
+ if gen_kwargs is not None:
167
+ gen_kwargs = simple_parse_args_string(gen_kwargs)
168
+ eval_logger.warning(
169
+ "generation_kwargs specified through cli, these settings will update set parameters in yaml tasks. "
170
+ "Ensure 'do_sample=True' for non-greedy decoding!"
171
+ )
172
+ if gen_kwargs == "":
173
+ gen_kwargs = None
174
+
175
+ if isinstance(model, str):
176
+ if retrieval_args["save_inputs_only"] and not model_args:
177
+ model = "hf"
178
+ model_args = "pretrained=openai-community/gpt2" # load a very small model that will not be used
179
+
180
+ if model_args is None:
181
+ eval_logger.warning("model_args not specified. Using defaults.")
182
+ model_args = ""
183
+
184
+ if isinstance(model_args, dict):
185
+ eval_logger.info(
186
+ f"Initializing {model} model, with arguments: {model_args}"
187
+ )
188
+ lm = lm_eval.api.registry.get_model(model).create_from_arg_obj(
189
+ model_args,
190
+ {
191
+ "batch_size": batch_size,
192
+ "max_batch_size": max_batch_size,
193
+ "device": device,
194
+ },
195
+ )
196
+
197
+ else:
198
+ eval_logger.info(
199
+ f"Initializing {model} model, with arguments: {simple_parse_args_string(model_args)}"
200
+ )
201
+ lm = lm_eval.api.registry.get_model(model).create_from_arg_string(
202
+ model_args,
203
+ {
204
+ "batch_size": batch_size,
205
+ "max_batch_size": max_batch_size,
206
+ "device": device,
207
+ },
208
+ )
209
+ else:
210
+ if not isinstance(model, lm_eval.api.model.LM):
211
+ raise TypeError
212
+ eval_logger.info("Using pre-initialized model")
213
+ lm = model
214
+
215
+ if use_cache is not None:
216
+ eval_logger.info(f"Using cache at {use_cache + '_rank' + str(lm.rank) + '.db'}")
217
+ lm = lm_eval.api.model.CachingLM(
218
+ lm,
219
+ use_cache
220
+ # each rank receives a different cache db.
221
+ # necessary to avoid multiple writes to cache at once
222
+ + "_rank"
223
+ + str(lm.rank)
224
+ + ".db",
225
+ )
226
+
227
+ if task_manager is None:
228
+ task_manager = TaskManager(verbosity)
229
+
230
+ task_dict = get_task_dict(tasks, task_manager)
231
+ for task_name in task_dict.keys():
232
+ task_obj = task_dict[task_name]
233
+ if isinstance(task_obj, tuple):
234
+ _, task_obj = task_obj
235
+ if task_obj is None:
236
+ continue
237
+
238
+ if task_obj.get_config("output_type") == "generate_until":
239
+ if gen_kwargs is not None:
240
+ task_obj.set_config(
241
+ key="generation_kwargs", value=gen_kwargs, update=True
242
+ )
243
+
244
+ if predict_only:
245
+ log_samples = True
246
+ eval_logger.info(
247
+ f"Processing {task_name} in output-only mode. Metrics will not be calculated!"
248
+ )
249
+ # we have to change the class properties post-hoc. This is pretty hacky.
250
+ task_obj.override_metric(metric_name="bypass")
251
+
252
+ # override tasks' fewshot values to the provided num_fewshot arg value
253
+ # except if tasks have it set to 0 manually in their configs--then we should never overwrite that
254
+ if num_fewshot is not None:
255
+ if (default_num_fewshot := task_obj.get_config("num_fewshot")) == 0:
256
+ eval_logger.info(
257
+ f"num_fewshot has been set to 0 for {task_name} in its config. Manual configuration will be ignored."
258
+ )
259
+ else:
260
+ eval_logger.warning(
261
+ f"Overwriting default num_fewshot of {task_name} from {default_num_fewshot} to {num_fewshot}"
262
+ )
263
+ task_obj.set_config(key="num_fewshot", value=num_fewshot)
264
+ else:
265
+ # if num_fewshot not provided, and the task does not define a default one, default to 0
266
+ if (default_num_fewshot := task_obj.get_config("num_fewshot")) is None:
267
+ task_obj.set_config(key="num_fewshot", value=0)
268
+ # fewshot_random_seed set for tasks, even with a default num_fewshot (e.g. in the YAML file)
269
+ task_obj.set_fewshot_seed(seed=fewshot_random_seed)
270
+ eval_logger.info(
271
+ f"Setting fewshot random generator seed to {fewshot_random_seed}"
272
+ )
273
+
274
+ if check_integrity:
275
+ run_task_tests(task_list=tasks)
276
+
277
+ if evaluation_tracker is not None:
278
+ evaluation_tracker.general_config_tracker.log_experiment_args(
279
+ model_source=model,
280
+ model_args=model_args,
281
+ system_instruction=system_instruction,
282
+ chat_template=lm.chat_template if apply_chat_template else None,
283
+ )
284
+
285
+ results = evaluate(
286
+ lm=lm,
287
+ task_dict=task_dict,
288
+ limit=limit,
289
+ cache_requests=cache_requests,
290
+ rewrite_requests_cache=rewrite_requests_cache,
291
+ bootstrap_iters=bootstrap_iters,
292
+ write_out=write_out,
293
+ log_samples=log_samples,
294
+ system_instruction=system_instruction,
295
+ apply_chat_template=apply_chat_template,
296
+ fewshot_as_multiturn=fewshot_as_multiturn,
297
+ verbosity=verbosity,
298
+ retrieval_args=retrieval_args,
299
+ )
300
+
301
+ if lm.rank == 0 and results is not None:
302
+ if isinstance(model, str):
303
+ model_name = model
304
+ elif hasattr(model, "config") and hasattr(model.config, "_name_or_path"):
305
+ model_name = model.config._name_or_path
306
+ else:
307
+ model_name = type(model).__name__
308
+
309
+ # add info about the model and few shot config
310
+ results["config"] = {
311
+ "model": model_name,
312
+ "model_args": model_args,
313
+ }
314
+ # add more detailed model info if available
315
+ if isinstance(lm, lm_eval.models.huggingface.HFLM):
316
+ results["config"].update(lm.get_model_info())
317
+ # add info about execution
318
+ results["config"].update(
319
+ {
320
+ "batch_size": batch_size,
321
+ "batch_sizes": (
322
+ list(lm.batch_sizes.values()) if hasattr(lm, "batch_sizes") else []
323
+ ),
324
+ "device": device,
325
+ "use_cache": use_cache,
326
+ "limit": limit,
327
+ "bootstrap_iters": bootstrap_iters,
328
+ "gen_kwargs": gen_kwargs,
329
+ "random_seed": random_seed,
330
+ "numpy_seed": numpy_random_seed,
331
+ "torch_seed": torch_random_seed,
332
+ "fewshot_seed": fewshot_random_seed,
333
+ }
334
+ )
335
+ results["git_hash"] = get_git_commit_hash()
336
+ results["date"] = start_date
337
+ add_env_info(results) # additional environment info to results
338
+ return results
339
+ else:
340
+ return None
341
+
342
+
343
+ @positional_deprecated
344
+ def evaluate(
345
+ lm: "LM",
346
+ task_dict,
347
+ limit: Optional[int] = None,
348
+ cache_requests: bool = False,
349
+ rewrite_requests_cache: bool = False,
350
+ bootstrap_iters: Optional[int] = 100000,
351
+ write_out: bool = False,
352
+ log_samples: bool = True,
353
+ system_instruction: Optional[str] = None,
354
+ apply_chat_template: bool = False,
355
+ fewshot_as_multiturn: bool = False,
356
+ verbosity: str = "INFO",
357
+ retrieval_args: dict = {},
358
+ ):
359
+ """Instantiate and evaluate a model on a list of tasks.
360
+
361
+ :param lm: obj
362
+ Language Model
363
+ :param task_dict: dict[str, Task]
364
+ Dictionary of tasks. Tasks will be taken to have name type(task).config.task .
365
+ :param limit: int, optional
366
+ Limit the number of examples per task (only use this for testing)
367
+ :param bootstrap_iters:
368
+ Number of iterations for bootstrap statistics, used when calculating stderr. Set to 0 for skipping all stderr calculations.
369
+ :param write_out: bool
370
+ If True, write out an example document and model input for checking task integrity
371
+ :param log_samples: bool
372
+ If True, write out all model outputs and documents for per-sample measurement and post-hoc analysis
373
+ :param system_instruction: str
374
+ System instruction to be applied to the prompt
375
+ :param apply_chat_template: bool
376
+ If True, apply chat template to the prompt
377
+ :param fewshot_as_multiturn: bool
378
+ Whether to provide the fewshot examples as a multiturn conversation or a single user turn.
379
+ :return
380
+ Dictionary of results
381
+ """
382
+
383
+ eval_logger.setLevel(getattr(logging, f"{verbosity}"))
384
+
385
+ # tracks all Instances/requests a model must generate output on.
386
+ requests = defaultdict(list)
387
+ # stores the amount to pad out reqs per req. type so that
388
+ # number of fwd passes per distributed rank is equal
389
+ padding_requests = defaultdict(int)
390
+
391
+ # get lists of group hierarchy and each type of request
392
+ task_hierarchy, eval_tasks = get_task_list(task_dict)
393
+ if not log_samples:
394
+ if not all(
395
+ "bypass" not in getattr(task_output.task, "_metric_fn_list", {}).keys()
396
+ for task_output in eval_tasks
397
+ ):
398
+ raise ValueError("log_samples must be True for 'bypass' metric-only tasks")
399
+
400
+ # hash the retrieval results first
401
+ if retrieval_args["retrieval_file"]:
402
+ logging.info(
403
+ f"Hashing the retrieval documents once for {len(eval_tasks)} tasks"
404
+ )
405
+ hashed_retrieval_results = hash_retrieval_results(
406
+ retrieval_args["retrieval_file"], retrieval_args["concat_k"], None
407
+ )
408
+
409
+ for task_output in eval_tasks:
410
+ task: Task = task_output.task
411
+ limit = get_sample_size(task, limit)
412
+ task.build_all_requests(
413
+ limit=limit,
414
+ rank=lm.rank,
415
+ world_size=lm.world_size,
416
+ cache_requests=cache_requests,
417
+ rewrite_requests_cache=rewrite_requests_cache,
418
+ system_instruction=system_instruction,
419
+ apply_chat_template=apply_chat_template,
420
+ fewshot_as_multiturn=fewshot_as_multiturn,
421
+ lm=lm,
422
+ )
423
+ eval_logger.debug(
424
+ f"Task: {task_output.task_name}; number of requests on this rank: {len(task.instances)}"
425
+ )
426
+ if write_out:
427
+ print_writeout(task)
428
+ # aggregate Instances by LM method requested to get output.
429
+ for instance in task.instances:
430
+ reqtype = instance.request_type
431
+ requests[reqtype].append(instance)
432
+
433
+ if lm.world_size > 1:
434
+ instances_rnk = torch.tensor(len(task._instances), device=lm.device)
435
+ gathered_item = (
436
+ lm.accelerator.gather(instances_rnk).cpu().detach().numpy().tolist()
437
+ )
438
+ # "multiple_choice" task types dispatch (several) "loglikelihood" request types
439
+ reqtype = (
440
+ "loglikelihood"
441
+ if task.OUTPUT_TYPE == "multiple_choice"
442
+ else task.OUTPUT_TYPE
443
+ )
444
+ # compute number of pseudo-batches to pad with (FSDP/DDP require even batches among ranks)
445
+ numpad = max(gathered_item) - gathered_item[lm.rank]
446
+ # todo: may not account for padding in cases like SquadV2 which has multiple req types
447
+ padding_requests[reqtype] += numpad
448
+
449
+ # save inputs for retrieval
450
+ output_dir = retrieval_args["inputs_save_dir"]
451
+ os.makedirs(output_dir, exist_ok=True)
452
+ save_file = os.path.join(output_dir, f"{task_output.task_name}.jsonl")
453
+ eval_logger.info(
454
+ f"Saving inputs for retrieval\n\tTask: {task_output.task_name}\n\tPath {save_file}."
455
+ )
456
+ if not os.path.exists(save_file) or retrieval_args["overwrite_saved_inputs"]:
457
+ with open(save_file, "w") as fout:
458
+ for instance in task.instances:
459
+ prompt_end = instance.arguments[0]
460
+ fout.write(
461
+ json.dumps(
462
+ {"query": extract_question_from_fewshot_prompt(prompt_end)}
463
+ )
464
+ + "\n"
465
+ )
466
+
467
+ # save answers for analysis
468
+ if retrieval_args["answer_save_dir"]:
469
+ answer_save_dir = retrieval_args["answer_save_dir"]
470
+ os.makedirs(answer_save_dir, exist_ok=True)
471
+ save_file = os.path.join(answer_save_dir, f"{task_output.task_name}.jsonl")
472
+ eval_logger.info(
473
+ f"Saving inputs and answers for retrieval\n\tTask: {task_output.task_name}\n\tPath {save_file}."
474
+ )
475
+ if (
476
+ not os.path.exists(save_file)
477
+ or retrieval_args["overwrite_saved_inputs"]
478
+ ):
479
+ with open(save_file, "w") as fout:
480
+ for instance in task.instances:
481
+ prompt_end = instance.arguments[0]
482
+ if instance.request_type == "loglikelihood":
483
+ answer = extract_answer_from_loglikelihood_task(
484
+ instance.arguments[0], instance.arguments[1]
485
+ )
486
+ else:
487
+ if "answer" in instance.doc:
488
+ answer = instance.doc["answer"]
489
+ elif "answers" in instance.doc:
490
+ answer = instance.doc["answers"]
491
+ else:
492
+ raise AttributeError
493
+ fout.write(
494
+ json.dumps({"query": prompt_end, "answer": answer}) + "\n"
495
+ )
496
+
497
+ # skip evaluation is save_inputs_only is True
498
+ if retrieval_args["save_inputs_only"]:
499
+ continue
500
+
501
+ # prepend retrieved documents if any
502
+ logging.info(f"Retrieval arguments: {retrieval_args}")
503
+
504
+ if retrieval_args["retrieval_file"] or retrieval_args["retrieval_dir"]:
505
+ if retrieval_args["retrieval_dir"]:
506
+ subtask_retrieval_file = f"{retrieval_args['retrieval_dir']}/{task_output.task_name}_retrieved_results.jsonl"
507
+ assert os.path.exists(subtask_retrieval_file), (
508
+ f"retrieval path does not exist: {subtask_retrieval_file}"
509
+ )
510
+ hashed_retrieval_results = hash_retrieval_results(
511
+ subtask_retrieval_file, retrieval_args["concat_k"], task
512
+ )
513
+ # assert len(task.instances) == len(hashed_retrieval_results), f'length mismatch between task data ({len(task.instances)}) and retrieval data ({len(hashed_retrieval_results)})'
514
+
515
+ for i, instance in enumerate(task.instances):
516
+ prompt_end = instance.arguments[0]
517
+ query = extract_question_from_fewshot_prompt(prompt_end)
518
+ if query in hashed_retrieval_results:
519
+ prompt_retrieval = hashed_retrieval_results[query]
520
+ else:
521
+ import sys
522
+
523
+ if sys.stdin.isatty():
524
+ print(f"Query not found in", task)
525
+ continue
526
+ else:
527
+ raise RuntimeError
528
+ # prompt_retrieval = hashed_retrieval_results[task._config.description + query]
529
+
530
+ prompt = prompt_retrieval + prompt_end
531
+ if retrieval_args["additional_system_prompt"]:
532
+ prompt = (
533
+ prompt_retrieval
534
+ + "\n\n"
535
+ + retrieval_args["additional_system_prompt"]
536
+ + prompt
537
+ )
538
+ if i == 0:
539
+ print(f"Sample prompt:\n{prompt}")
540
+ task.instances[i].arguments = (prompt, *instance.arguments[1:])
541
+
542
+ elif retrieval_args["additional_system_prompt"]:
543
+ for i, instance in enumerate(task.instances):
544
+ prompt = (
545
+ retrieval_args["additional_system_prompt"] + instance.arguments[0]
546
+ )
547
+ task.instances[i].arguments = (prompt, *instance.arguments[1:])
548
+
549
+ if lm.world_size > 1:
550
+ instances_rnk = torch.tensor(len(task._instances), device=lm.device)
551
+ gathered_item = (
552
+ lm.accelerator.gather(instances_rnk).cpu().detach().numpy().tolist()
553
+ )
554
+ # "multiple_choice" task types dispatch (several) "loglikelihood" request types
555
+ reqtype = (
556
+ "loglikelihood"
557
+ if task.OUTPUT_TYPE == "multiple_choice"
558
+ else task.OUTPUT_TYPE
559
+ )
560
+ # compute number of pseudo-batches to pad with (FSDP/DDP require even batches among ranks)
561
+ numpad = max(gathered_item) - gathered_item[lm.rank]
562
+ # todo: may not account for padding in cases like SquadV2 which has multiple req types
563
+ padding_requests[reqtype] += numpad
564
+
565
+ # Skip evaluation is save_inputs_only is True
566
+ if retrieval_args["save_inputs_only"]:
567
+ logging.info("Skipping evaluation because save_inputs_only is set to True...")
568
+ return None
569
+
570
+ ### Run LM on inputs, get all outputs ###
571
+ # execute each type of request
572
+ for reqtype, reqs in requests.items():
573
+ eval_logger.info(f"Running {reqtype} requests")
574
+ # create `K` copies of each request `req` based off `K = req.repeats`
575
+ cloned_reqs = []
576
+ for req in reqs:
577
+ cloned_reqs.extend([req] * req.repeats)
578
+
579
+ if (lm.world_size > 1) and (padding_requests[reqtype] > 0):
580
+ for _ in range(padding_requests[reqtype]):
581
+ cloned_reqs.extend([req] * req.repeats)
582
+
583
+ # run requests through model
584
+ ## real gen here!!!
585
+ resps = getattr(lm, reqtype)(cloned_reqs)
586
+
587
+ # put responses from model into a list of length K for each request.
588
+ for x, req in zip(resps, cloned_reqs):
589
+ req.resps.append(x)
590
+
591
+ with open("lm_eval_record.jsonl", "w") as f:
592
+ for req, x in zip(cloned_reqs, resps):
593
+ f.write(
594
+ json.dumps(
595
+ {
596
+ "prompt": req.arguments[0],
597
+ "response": x,
598
+ }
599
+ )
600
+ + "\n"
601
+ )
602
+
603
+ if lm.world_size > 1:
604
+ lm.accelerator.wait_for_everyone()
605
+
606
+ RANK = lm.rank
607
+ WORLD_SIZE = lm.world_size
608
+ ### Postprocess outputs ###
609
+ # TODO: del model here, maybe (idea: allow user to specify device of e.g. reward model separately)
610
+ for task_output in eval_tasks:
611
+ task = task_output.task
612
+ task.apply_filters()
613
+
614
+ ### Collect values of metrics on all datapoints ###
615
+ # # unpack results and sort back in order and return control to Task
616
+ # TODO: make it possible to use a different metric per filter
617
+ # Pre-process task.instances to group by doc_id
618
+ instances_by_doc_id = defaultdict(list)
619
+ for instance in task.instances:
620
+ instances_by_doc_id[instance.doc_id].append(instance)
621
+ # Sort instances within each group
622
+ for instances in instances_by_doc_id.values():
623
+ instances.sort(key=lambda x: x.idx)
624
+ # iterate over different filters used
625
+ for filter_key in task.instances[0].filtered_resps.keys():
626
+ doc_iterator = task.doc_iterator(
627
+ rank=RANK, limit=limit, world_size=WORLD_SIZE
628
+ )
629
+ for doc_id, doc in doc_iterator:
630
+ requests = instances_by_doc_id[doc_id]
631
+ metrics = task.process_results(
632
+ doc, [req.filtered_resps[filter_key] for req in requests]
633
+ )
634
+ if log_samples:
635
+ target = task.doc_to_target(doc)
636
+ example = {
637
+ "doc_id": doc_id,
638
+ "doc": doc,
639
+ "target": target,
640
+ "arguments": [req.args for req in requests],
641
+ "resps": [req.resps for req in requests],
642
+ "filtered_resps": [
643
+ req.filtered_resps[filter_key] for req in requests
644
+ ],
645
+ "doc_hash": hash_string(
646
+ json.dumps(
647
+ requests[0].doc,
648
+ indent=2,
649
+ default=handle_non_serializable,
650
+ ensure_ascii=False,
651
+ )
652
+ ),
653
+ "prompt_hash": hash_string(requests[0].arguments[0]),
654
+ "target_hash": hash_string(str(target)),
655
+ }
656
+ example.update(metrics)
657
+ task_output.logged_samples.append(example)
658
+ for metric, value in metrics.items():
659
+ task_output.sample_metrics[(metric, filter_key)].append(value)
660
+
661
+ if WORLD_SIZE > 1:
662
+ # if multigpu, then gather data across all ranks to rank 0
663
+ # first gather logged samples across all ranks
664
+ for task_output in eval_tasks:
665
+ if log_samples:
666
+ # for task_name, task_samples in list(samples.items()):
667
+ full_samples = [None] * WORLD_SIZE if RANK == 0 else None
668
+ torch.distributed.gather_object(
669
+ obj=task_output.logged_samples,
670
+ object_gather_list=full_samples,
671
+ dst=0,
672
+ )
673
+
674
+ if RANK == 0:
675
+ task_output.logged_samples = list(
676
+ itertools.chain.from_iterable(full_samples)
677
+ )
678
+
679
+ # then collect metrics across all ranks
680
+ for metrics in task_output.sample_metrics:
681
+ metric_list = [None] * WORLD_SIZE if RANK == 0 else None
682
+ torch.distributed.gather_object(
683
+ obj=task_output.sample_metrics[metrics],
684
+ object_gather_list=metric_list,
685
+ dst=0,
686
+ )
687
+ if RANK == 0:
688
+ task_output.sample_metrics[metrics] = list(
689
+ itertools.chain.from_iterable(metric_list)
690
+ )
691
+
692
+ if RANK == 0:
693
+ ### Aggregate results over all datapoints ###
694
+ # aggregate results ; run bootstrap CIs
695
+ for task_output in eval_tasks:
696
+ task_output.calculate_aggregate_metric(bootstrap_iters=bootstrap_iters)
697
+ (
698
+ results,
699
+ samples,
700
+ configs,
701
+ versions,
702
+ num_fewshot,
703
+ higher_is_better,
704
+ ) = consolidate_results(eval_tasks)
705
+
706
+ ### Calculate group metrics ###
707
+ if bool(results):
708
+ for group, task_list in reversed(task_hierarchy.items()):
709
+ if len(task_list) == 0:
710
+ # task_hierarchy entries are either
711
+ # `group_name: [subtask1, subtask2, ...]`
712
+ # or `task_name: []`.
713
+ # we only want to operate on groups here.
714
+ continue
715
+
716
+ # collect all higher_is_better values for metrics
717
+ # in the group's subtasks.
718
+ # TODO: clean this up ; unify with the below metric_list loop?
719
+ _higher_is_better = {}
720
+ for task in task_list:
721
+ for m, h in higher_is_better[task].items():
722
+ if m not in _higher_is_better.keys():
723
+ _higher_is_better[m] = h
724
+ if (
725
+ m in _higher_is_better
726
+ and _higher_is_better[m] is not None
727
+ and _higher_is_better[m] != h
728
+ ):
729
+ eval_logger.warning(
730
+ f"Higher_is_better values for metric {m} in group {group} are not consistent. Defaulting to None."
731
+ )
732
+ _higher_is_better[m] = None
733
+ higher_is_better[group] = _higher_is_better
734
+
735
+ # collect all metric keys used by a subtask in the group.
736
+ metric_list = list(
737
+ {
738
+ key
739
+ for task in task_list
740
+ for key in results[task].keys()
741
+ if "_stderr" not in key and key not in ["alias", "samples"]
742
+ }
743
+ )
744
+ for metric in metric_list:
745
+ stderr = "_stderr,".join(metric.split(","))
746
+
747
+ # gather metrics, sizes, and stderrs from subtasks
748
+ metrics = [
749
+ results[task][metric]
750
+ for task in task_list
751
+ if metric in results[task]
752
+ ] # TODO: copy?
753
+ stderrs = [
754
+ results[task][stderr]
755
+ for task in task_list
756
+ if stderr in results[task]
757
+ ]
758
+ sizes = [
759
+ results[task]["samples"]
760
+ for task in task_list
761
+ if metric in results[task]
762
+ ]
763
+
764
+ # compute group's pooled metric and stderr
765
+ results[group][metric] = (
766
+ lm_eval.api.metrics.aggregate_subtask_metrics(metrics, sizes)
767
+ )
768
+ # TODO: calculate grouped metric using aggregation fn
769
+ if "N/A" in stderrs:
770
+ results[group][stderr] = "N/A"
771
+ else:
772
+ results[group][stderr] = (
773
+ lm_eval.api.metrics.pooled_sample_stderr(stderrs, sizes)
774
+ )
775
+ # TODO: allow GroupConfigs to choose which variance formula is used, for back-compatibility
776
+ # To use the old (likely incorrect) variance formula, comment out the above and uncomment this line:
777
+ # results[group][stderr] = lm_eval.api.metrics.combined_sample_stderr(stderrs, sizes, metrics=metrics)
778
+
779
+ results[group]["samples"] = sum(sizes)
780
+
781
+ results_agg = defaultdict(dict)
782
+ groups_agg = defaultdict(dict)
783
+ all_tasks_list = list(task_hierarchy.keys())
784
+ while True:
785
+ add_tasks_list = list(k for k in results_agg.keys())
786
+ left_tasks_list = sorted(list(set(all_tasks_list) - set(add_tasks_list)))
787
+ if len(left_tasks_list) == 0:
788
+ break
789
+
790
+ _task_hierarchy = {
791
+ k: v for k, v in task_hierarchy.items() if k in left_tasks_list
792
+ }
793
+ _results_agg, _groups_agg = prepare_print_tasks(_task_hierarchy, results)
794
+
795
+ results_agg = {**results_agg, **_results_agg}
796
+ groups_agg = {**groups_agg, **_groups_agg}
797
+
798
+ for group_name, task_list in task_hierarchy.items():
799
+ if task_list:
800
+ num_fewshot[group_name] = num_fewshot[
801
+ task_list[0]
802
+ ] # TODO: validate this
803
+
804
+ results_dict = {
805
+ "results": dict(results_agg.items()),
806
+ **({"groups": dict(groups_agg.items())} if bool(groups_agg) else {}),
807
+ "group_subtasks": dict(reversed(task_hierarchy.items())),
808
+ "configs": dict(sorted(configs.items())),
809
+ "versions": dict(sorted(versions.items())),
810
+ "n-shot": dict(sorted(num_fewshot.items())),
811
+ "n-doc": {
812
+ k: retrieval_args["concat_k"]
813
+ for k in dict(sorted(num_fewshot.items())).keys()
814
+ },
815
+ "higher_is_better": dict(sorted(higher_is_better.items())),
816
+ "n-samples": {
817
+ task_output.task_name: {
818
+ "original": len(task_output.task.eval_docs),
819
+ "effective": min(
820
+ limit if limit else len(task_output.task.eval_docs),
821
+ len(task_output.task.eval_docs),
822
+ ),
823
+ }
824
+ for task_output in eval_tasks
825
+ },
826
+ }
827
+ if log_samples:
828
+ results_dict["samples"] = dict(samples)
829
+
830
+ return results_dict
831
+
832
+ else:
833
+ return None
834
+
835
+
836
+ def request_caching_arg_to_dict(cache_requests: str) -> dict:
837
+ request_caching_args = {
838
+ "cache_requests": cache_requests in {"true", "refresh"},
839
+ "rewrite_requests_cache": cache_requests == "refresh",
840
+ "delete_requests_cache": cache_requests == "delete",
841
+ }
842
+
843
+ return request_caching_args
844
+
845
+
846
+ def load_jsonlines(file):
847
+ with jsonlines.open(file, "r") as jsonl_f:
848
+ lst = [obj for obj in jsonl_f]
849
+ return lst
850
+
851
+
852
+ def extract_question_from_fewshot_prompt(prompt):
853
+ """
854
+ Extract the 0-shot question from fewshot example.
855
+ We split by '\n\n' because it is the default fewshot delimiter.
856
+ Please make sure all future tasks use '\n\n' as the fewshot delimiter.
857
+ """
858
+ return prompt.split("\n\n")[-1]
859
+
860
+
861
+ def hash_retrieval_results(
862
+ test_jsonl_with_retrieval: str = "",
863
+ concat_k: int = 1,
864
+ task=None,
865
+ ):
866
+ hashed_results = {}
867
+ qa_data = load_jsonlines(test_jsonl_with_retrieval)
868
+ for data in qa_data:
869
+ assert "question" or "raw_query" or "query" in data
870
+ if "raw_query" in data or "query" in data:
871
+ raw_query = data["raw_query"] if "raw_query" in data else data["query"]
872
+ # hotfix: remove system prompt in the original query based on '\n\n' to align the extracted query in the few-shot setting.
873
+ raw_query = extract_question_from_fewshot_prompt(raw_query)
874
+ else:
875
+ query = data["question"]
876
+ raw_query = task._config.description + task.doc_to_text({"question": query})
877
+
878
+ k_ctx = ""
879
+ for i in range(concat_k):
880
+ try:
881
+ # todo: unify the key name
882
+ k_ctx = (
883
+ data["ctxs"][i]["retrieval text"] + k_ctx
884
+ if "retrieval text" in data["ctxs"][i].keys()
885
+ else data["ctxs"][i]["text"] + k_ctx
886
+ )
887
+ except:
888
+ print(f"No enough documents to prepend! Added {i} documents only.")
889
+
890
+ try:
891
+ assert (
892
+ raw_query not in hashed_results.keys()
893
+ or k_ctx == hashed_results[raw_query]
894
+ )
895
+ except:
896
+ print(
897
+ f"\n\nMismatched:\nQuery:{raw_query}\nHashed Doc:{hashed_results[raw_query]}\nNew Doc:{k_ctx}"
898
+ )
899
+ # assert raw_query not in hashed_results, f'query already in hashed results: {raw_query}'
900
+ hashed_results[raw_query] = k_ctx
901
+ return hashed_results
902
+
903
+
904
+ def extract_answer_from_loglikelihood_task(input_text, answer_label):
905
+ # Split the input into question and answer parts
906
+ parts = input_text.split("Answer:")
907
+ question_part = parts[0]
908
+
909
+ # Normalize the answer label to remove extra spaces
910
+ answer_label = answer_label.strip()
911
+
912
+ # Split the question part further to isolate answer choices
913
+ answer_choices = question_part.split("\n")
914
+ answer_choices = [choice.strip() for choice in answer_choices if choice.strip()]
915
+
916
+ # Find the answer choice that matches the answer label
917
+ for choice in answer_choices:
918
+ if choice.startswith(answer_label):
919
+ return choice
920
+
921
+ return "Answer not found"
rag-evaluation-harness/lm_eval/tasks/anli/anli_r1.yaml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ group:
2
+ - anli
3
+ task: anli_r1
4
+ dataset_path: anli
5
+ dataset_name: null
6
+ output_type: multiple_choice
7
+ training_split: train_r1
8
+ validation_split: dev_r1
9
+ test_split: test_r1
10
+ doc_to_text: "{{premise}}\nQuestion: {{hypothesis}} True, False, or Neither?\nAnswer:"
11
+ # True = entailment
12
+ # False = contradiction
13
+ # Neither = neutral
14
+ doc_to_target: "{{['True', 'Neither', 'False'][label]}}"
15
+ doc_to_choice:
16
+ - "True"
17
+ - "Neither"
18
+ - "False"
19
+ should_decontaminate: true
20
+ doc_to_decontamination_query: premise
21
+ metric_list:
22
+ - metric: acc
23
+ aggregation: mean
24
+ higher_is_better: true
25
+ metadata:
26
+ version: 1.0
rag-evaluation-harness/lm_eval/tasks/anli/anli_r2.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ include: anli_r1.yaml
2
+ task: anli_r2
3
+ training_split: train_r2
4
+ validation_split: dev_r2
5
+ test_split: test_r2
rag-evaluation-harness/lm_eval/tasks/csatqa/csatqa_li.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "dataset_name": "LI"
2
+ "include": "_default_csatqa_yaml"
3
+ "task": "csatqa_li"
rag-evaluation-harness/lm_eval/tasks/csatqa/utils.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ def process_docs(dataset: datasets.Dataset) -> datasets.Dataset:
5
+ def _process_doc(doc):
6
+ instruction = f"""다음을 읽고 정답으로 알맞은 것을 고르시요.
7
+ ### Context: {doc["context"]}
8
+ ### Question: {doc["question"]}
9
+ ### Options:
10
+ (1) {doc["option#1"]}\n(2) {doc["option#2"]}\n(3) {doc["option#3"]}\n(4) {doc["option#4"]}\n(5) {doc["option#5"]}
11
+ ### Answer: 주어진 문제의 정답은"""
12
+
13
+ out_doc = {
14
+ "question": instruction,
15
+ "choices": ["(1)", "(2)", "(3)", "(4)", "(5)"],
16
+ "gold": int(doc["gold"]) - 1,
17
+ }
18
+ return out_doc
19
+
20
+ return dataset.map(_process_doc)
rag-evaluation-harness/lm_eval/tasks/french_bench/french_bench_multifquad.yaml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include: "_default_template_yaml"
2
+ group:
3
+ - french_bench
4
+ - french_bench_gen
5
+ description: "D'après l'information dans le contexte donné, donne la réponse à la question en citant quelques extraits du contexte."
6
+ task: french_bench_multifquad
7
+ dataset_path: manu/multifquad_test
8
+ output_type: generate_until
9
+ validation_split: valid
10
+ test_split: test
11
+ fewshot_split: valid
12
+ doc_to_text: "\nContexte: {{context}}\n\nQuestion: {{question}}\n\nRéponse:"
13
+ doc_to_target: "{{', '.join(answers.text)}}"
14
+ target_delimiter: " "
15
+ should_decontaminate: true
16
+ doc_to_decontamination_query: context
17
+ generation_kwargs:
18
+ until:
19
+ - "\n"
20
+ # filter_list:
21
+ # - name: remove_whitespace
22
+ # filter:
23
+ # - function: remove_whitespace
24
+ # - function: take_first
25
+ metric_list:
26
+ - metric: !function utils.exact
27
+ aggregation: mean
28
+ higher_is_better: true
29
+ - metric: !function utils.f1
30
+ aggregation: mean
31
+ higher_is_better: true
32
+ - metric: !function utils.rouge1
33
+ higher_is_better: true
34
+ aggregation: !function utils.rouge1_agg
rag-evaluation-harness/lm_eval/tasks/xnli/xnli_ar.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: ar
3
+ doc_to_choice: '{{[premise+", صحيح? نعم, "+hypothesis,premise+", صحيح? لذا, "+hypothesis,premise+",
4
+ صحيح? رقم, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_ar
rag-evaluation-harness/lm_eval/tasks/xnli/xnli_bg.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: bg
3
+ doc_to_choice: '{{[premise+", правилно? да, "+hypothesis,premise+", правилно? така,
4
+ "+hypothesis,premise+", правилно? не, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_bg
rag-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
rag-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
rag-evaluation-harness/lm_eval/tasks/xnli/xnli_ur.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: ur
3
+ doc_to_choice: '{{[premise+", صحیح? جی ہاں, "+hypothesis,premise+", صحیح? اس لئے,
4
+ "+hypothesis,premise+", صحیح? نہیں, "+hypothesis]}}'
5
+ doc_to_text: ''
6
+ include: xnli_common_yaml
7
+ task: xnli_ur
rag-evaluation-harness/mypy.ini ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [mypy]
2
+ python_version = 3.8
3
+ show_traceback = True
4
+ check_untyped_defs = True
5
+ no_implicit_reexport = True
6
+ warn_unreachable = True
7
+ warn_unused_configs = True
8
+ warn_unused_ignores = True
9
+ warn_redundant_casts = True
10
+
11
+ # We ignore errors everywhere to gradually add type annotations
12
+
13
+ [mypy-lm_eval.*]
14
+ ignore_errors = True
15
+
16
+ [mypy-lm_eval.api.*]
17
+ ignore_errors = True
18
+
19
+ [mypy-lm_eval.prompts.*]
20
+ ignore_errors = True
21
+
22
+ [mypy-lm_eval.models.*]
23
+ ignore_errors = True
24
+
25
+ [mypy-scripts.*]
26
+ ignore_errors = True
27
+
28
+ [mypy-main]
29
+ ignore_errors = True
rag-evaluation-harness/pyproject.toml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools>=40.8.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "lm_eval"
7
+ version = "0.4.2"
8
+ authors = [
9
+ {name="EleutherAI", email="[email protected]"}
10
+ ]
11
+ description = "A framework for evaluating language models"
12
+ readme = "README.md"
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ requires-python = ">=3.8"
20
+ license = { "text" = "MIT" }
21
+ dependencies = [
22
+ "accelerate>=0.26.0",
23
+ "evaluate",
24
+ "datasets>=2.16.0",
25
+ "evaluate>=0.4.0",
26
+ "jsonlines",
27
+ "numexpr",
28
+ "peft>=0.2.0",
29
+ "pybind11>=2.6.2",
30
+ "pytablewriter",
31
+ "rouge-score>=0.0.4",
32
+ "sacrebleu>=1.5.0",
33
+ "scikit-learn>=0.24.1",
34
+ "sqlitedict",
35
+ "torch>=1.8",
36
+ "tqdm-multiprocess",
37
+ "transformers>=4.1",
38
+ "zstandard",
39
+ "dill",
40
+ "word2number",
41
+ "more_itertools",
42
+ ]
43
+
44
+ [tool.setuptools.packages.find]
45
+ include = ["lm_eval*"]
46
+
47
+ # required to include yaml files in pip installation
48
+ [tool.setuptools.package-data]
49
+ lm_eval = ["**/*.yaml", "tasks/**/*"]
50
+
51
+ [project.scripts]
52
+ lm-eval = "lm_eval.__main__:cli_evaluate"
53
+ lm_eval = "lm_eval.__main__:cli_evaluate"
54
+
55
+ [project.urls]
56
+ Homepage = "https://github.com/EleutherAI/lm-evaluation-harness"
57
+ Repository = "https://github.com/EleutherAI/lm-evaluation-harness"
58
+
59
+ [project.optional-dependencies]
60
+ anthropic = ["anthropic"]
61
+ dev = ["pytest", "pytest-cov", "pytest-xdist", "pre-commit", "mypy"]
62
+ deepsparse = ["deepsparse-nightly[llm]>=1.8.0.20240404"]
63
+ gptq = ["auto-gptq[triton]>=0.6.0"]
64
+ hf_transfer = ["hf_transfer"]
65
+ ifeval = ["langdetect", "immutabledict"]
66
+ neuronx = ["optimum[neuronx]"]
67
+ mamba = ["mamba_ssm", "causal-conv1d==1.0.2"]
68
+ math = ["sympy>=1.12", "antlr4-python3-runtime==4.11"]
69
+ multilingual = ["nagisa>=0.2.7", "jieba>=0.42.1", "pycountry"]
70
+ openai = ["openai==1.3.9", "tiktoken"]
71
+ optimum = ["optimum[openvino]"]
72
+ promptsource = ["promptsource>=0.2.3"]
73
+ sentencepiece = ["sentencepiece>=0.1.98"]
74
+ sparseml = ["sparseml-nightly[llm]>=1.8.0.20240404"]
75
+ testing = ["pytest", "pytest-cov", "pytest-xdist"]
76
+ vllm = ["vllm>=0.4.2"]
77
+ zeno = ["pandas", "zeno-client"]
78
+ wandb = ["wandb>=0.16.3", "pandas", "numpy"]
79
+ unitxt = ["unitxt"]
80
+ all = [
81
+ "lm_eval[anthropic]",
82
+ "lm_eval[dev]",
83
+ "lm_eval[deepsparse]",
84
+ "lm_eval[gptq]",
85
+ "lm_eval[hf_transfer]",
86
+ "lm_eval[ifeval]",
87
+ "lm_eval[mamba]",
88
+ "lm_eval[math]",
89
+ "lm_eval[multilingual]",
90
+ "lm_eval[openai]",
91
+ "lm_eval[promptsource]",
92
+ "lm_eval[sentencepiece]",
93
+ "lm_eval[sparseml]",
94
+ "lm_eval[testing]",
95
+ "lm_eval[vllm]",
96
+ "lm_eval[zeno]",
97
+ "lm_eval[wandb]",
98
+ "lm_eval[unitxt]"
99
+ ]
100
+
101
+ [tool.ruff.lint]
102
+ extend-select = ["I"]
103
+
104
+ [tool.ruff.lint.isort]
105
+ lines-after-imports = 2
106
+ known-first-party = ["lm_eval"]
107
+
108
+ [tool.ruff.lint.extend-per-file-ignores]
109
+ "__init__.py" = ["F401","F402","F403"]
rag-evaluation-harness/setup.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import setuptools
2
+
3
+
4
+ # This is to make sure that the package supports editable installs
5
+ setuptools.setup()
recall_acc_results/_a/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *
recall_acc_results/_a/_b/recall_acc_results_Llama-3.2-1B-Instruct_dpr_nlist8192.json ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nprobe_values": [
3
+ 0,
4
+ 4,
5
+ 8,
6
+ 16,
7
+ 32,
8
+ 48,
9
+ 64,
10
+ 96,
11
+ 128,
12
+ 192,
13
+ 256,
14
+ 384,
15
+ 512,
16
+ 768,
17
+ 1024
18
+ ],
19
+ "recalls": [
20
+ 0.0,
21
+ 0.0,
22
+ 0.0,
23
+ 0.0,
24
+ 0.0,
25
+ 0.0,
26
+ 0.0,
27
+ 0.0,
28
+ 0.0,
29
+ 0.0,
30
+ 0.0,
31
+ 0.0,
32
+ 0.0,
33
+ 0.0,
34
+ 0.0
35
+ ],
36
+ "f1_scores": [
37
+ 0.21769386490478573,
38
+ 0.25655656373673,
39
+ 0.26277393056489584,
40
+ 0.2666075931737789,
41
+ 0.2689541813918884,
42
+ 0.27178377562037465,
43
+ 0.2708846495803003,
44
+ 0.27046785538697377,
45
+ 0.27381786243096806,
46
+ 0.2747022079299461,
47
+ 0.27639020598913533,
48
+ 0.2767040841700495,
49
+ 0.2769265901958796,
50
+ 0.2773986181520763,
51
+ 0.27761378156668565
52
+ ],
53
+ "exact_match_scores": [
54
+ 0.1556786703601108,
55
+ 0.18476454293628808,
56
+ 0.19113573407202217,
57
+ 0.1930747922437673,
58
+ 0.19473684210526315,
59
+ 0.1961218836565097,
60
+ 0.19529085872576177,
61
+ 0.19529085872576177,
62
+ 0.19806094182825484,
63
+ 0.19889196675900278,
64
+ 0.20055401662049863,
65
+ 0.2002770083102493,
66
+ 0.20055401662049863,
67
+ 0.2002770083102493,
68
+ 0.20055401662049863
69
+ ],
70
+ "parameters": {
71
+ "nlist": 8192,
72
+ "domain": "dpr",
73
+ "task": "nq",
74
+ "model": "meta-llama/Llama-3.2-1B-Instruct",
75
+ "engine": "vllm"
76
+ },
77
+ "search_times": [
78
+ 0.0,
79
+ 1.8302443027496338,
80
+ 1.9399559497833252,
81
+ 2.2174618244171143,
82
+ 2.652435779571533,
83
+ 3.1330487728118896,
84
+ 3.292360782623291,
85
+ 3.9053852558135986,
86
+ 4.548843622207642,
87
+ 6.490998268127441,
88
+ 7.144783973693848,
89
+ 9.334285020828247,
90
+ 12.308050870895386,
91
+ 16.292457580566406,
92
+ 21.412838220596313
93
+ ]
94
+ }
recall_acc_results/_a/real/recall_acc_results_Llama-3.1-8B-Instruct_rpj_wiki_nlist8192.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nprobe_values": [
3
+ 0,
4
+ 4,
5
+ 8,
6
+ 16,
7
+ 32,
8
+ 48,
9
+ 64,
10
+ 96,
11
+ 128,
12
+ 192,
13
+ 256,
14
+ 2048,
15
+ 4096
16
+ ],
17
+ "recalls": [
18
+ 1.0,
19
+ 0.0,
20
+ 0.5670360110803324,
21
+ 0.684118190212373,
22
+ 0.7736842105263158,
23
+ 0.851892890120037,
24
+ 0.881809787626962,
25
+ 0.9027700831024931,
26
+ 0.9239150507848568,
27
+ 0.9374884579870728,
28
+ 0.951708217913204,
29
+ 0.9598337950138505,
30
+ 0.9867959372114496,
31
+ 0.9901200369344413
32
+ ],
33
+ "f1_scores": [
34
+ 0.4786705586086418,
35
+ 0.40470335934772955,
36
+ 0.43794170876894184,
37
+ 0.44503321604744245,
38
+ 0.45646277758469844,
39
+ 0.4631313161455936,
40
+ 0.4664465840616437,
41
+ 0.47055412199309693,
42
+ 0.4725633654427836,
43
+ 0.47337743829635387,
44
+ 0.4730561125835718,
45
+ 0.47221922222452073,
46
+ 0.47681121143073507,
47
+ 0.4770792813443116
48
+ ],
49
+ "exact_match_scores": [
50
+ 0.36426592797783935,
51
+ 0.3060941828254848,
52
+ 0.3332409972299169,
53
+ 0.3376731301939058,
54
+ 0.34542936288088644,
55
+ 0.3493074792243767,
56
+ 0.35290858725761776,
57
+ 0.35678670360110804,
58
+ 0.35789473684210527,
59
+ 0.3595567867036011,
60
+ 0.360387811634349,
61
+ 0.3592797783933518,
62
+ 0.36398891966759,
63
+ 0.3631578947368421
64
+ ],
65
+ "parameters": {
66
+ "nlist": 8192,
67
+ "domain": "rpj_wiki",
68
+ "task": "nq",
69
+ "model": "meta-llama/Llama-3.1-8B-Instruct",
70
+ "engine": "sglang"
71
+ },
72
+ "search_times": [
73
+ 0.010169744491577148,
74
+ 0.0,
75
+ 0.16394424438476562,
76
+ 0.21286225318908691,
77
+ 0.3131523132324219,
78
+ 0.7416322231292725,
79
+ 1.0397512912750244,
80
+ 1.2900450229644775,
81
+ 1.7838373184204102,
82
+ 2.216383934020996,
83
+ 1.9432766437530518,
84
+ 4.186463356018066,
85
+ 27.881035566329956,
86
+ 46.320849657058716
87
+ ]
88
+ }
recall_acc_results/_a/real/recall_acc_results_Llama-3.2-1B-Instruct_dpr_nlist8192.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nprobe_values": [
3
+ 0,
4
+ 4,
5
+ 8,
6
+ 16,
7
+ 32,
8
+ 48,
9
+ 64,
10
+ 96,
11
+ 128,
12
+ 192,
13
+ 256,
14
+ 384,
15
+ 512,
16
+ 768,
17
+ 1024
18
+ ],
19
+ "recalls": [
20
+ 1.0,
21
+ 0.0,
22
+ 0.6291782086795936,
23
+ 0.7152354570637119,
24
+ 0.7860572483841182,
25
+ 0.8456140350877193,
26
+ 0.8770083102493075,
27
+ 0.894921514312096,
28
+ 0.9179132040627885,
29
+ 0.9318559556786704,
30
+ 0.9501385041551247,
31
+ 0.960387811634349,
32
+ 0.9738688827331488,
33
+ 0.979870729455217,
34
+ 0.9875346260387812,
35
+ 0.9914127423822715
36
+ ],
37
+ "f1_scores": [
38
+ 0.27881974601047416,
39
+ 0.21561311967926722,
40
+ 0.2567006766234114,
41
+ 0.2630800747764499,
42
+ 0.2685084250046297,
43
+ 0.27092383361616285,
44
+ 0.27419806877566505,
45
+ 0.2730051004635831,
46
+ 0.27191109831575466,
47
+ 0.2750768353845801,
48
+ 0.27610190757308717,
49
+ 0.2780203696805667,
50
+ 0.27792227294812094,
51
+ 0.2781271355310397,
52
+ 0.2786307045194937,
53
+ 0.2791007792277955
54
+ ],
55
+ "exact_match_scores": [
56
+ 0.20193905817174515,
57
+ 0.15401662049861495,
58
+ 0.1853185595567867,
59
+ 0.19141274238227146,
60
+ 0.19501385041551247,
61
+ 0.19667590027700832,
62
+ 0.19833795013850417,
63
+ 0.19722991689750694,
64
+ 0.19667590027700832,
65
+ 0.19916897506925207,
66
+ 0.2,
67
+ 0.20166204986149586,
68
+ 0.20166204986149586,
69
+ 0.20166204986149586,
70
+ 0.20138504155124654,
71
+ 0.20193905817174515
72
+ ],
73
+ "parameters": {
74
+ "nlist": 8192,
75
+ "domain": "dpr",
76
+ "task": "nq",
77
+ "model": "meta-llama/Llama-3.2-1B-Instruct",
78
+ "engine": "sglang"
79
+ },
80
+ "search_times": [
81
+ 0.2925705909729004,
82
+ 0.0,
83
+ 1.9018418788909912,
84
+ 1.887054443359375,
85
+ 2.3637545108795166,
86
+ 2.95737361907959,
87
+ 3.161799669265747,
88
+ 3.739989757537842,
89
+ 4.95138692855835,
90
+ 6.247658729553223,
91
+ 6.502671003341675,
92
+ 7.629181861877441,
93
+ 10.550214290618896,
94
+ 13.077433586120605,
95
+ 17.176400184631348,
96
+ 21.692492246627808
97
+ ]
98
+ }
recall_acc_results/_a/real/recall_acc_results_Llama-3.2-1B-Instruct_rpj_wiki_nlist8192.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nprobe_values": [
3
+ 384,
4
+ 512,
5
+ 768,
6
+ 1024
7
+ ],
8
+ "recalls": [
9
+ 0.9915974145891044,
10
+ 0.9946445060018467,
11
+ 0.9965835641735918,
12
+ 0.9975069252077562
13
+ ],
14
+ "f1_scores": [
15
+ 0.3697835728581248,
16
+ 0.3701804713083109,
17
+ 0.3699405513600644,
18
+ 0.3694831723007625
19
+ ],
20
+ "exact_match_scores": [
21
+ 0.2692520775623269,
22
+ 0.2698060941828255,
23
+ 0.2698060941828255,
24
+ 0.2698060941828255
25
+ ],
26
+ "parameters": {
27
+ "nlist": 8192,
28
+ "domain": "rpj_wiki",
29
+ "task": "nq",
30
+ "model": "meta-llama/Llama-3.2-1B-Instruct",
31
+ "engine": "sglang"
32
+ },
33
+ "search_times": [
34
+ 827.3021464347839,
35
+ 2753.4918179512024,
36
+ 934.9543120861053,
37
+ 991.6539351940155
38
+ ]
39
+ }
recall_acc_results/_a/valid/recall_acc_results_Llama-3.2-1B_dpr_nlist8192.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nprobe_values": [
3
+ 0,
4
+ 4,
5
+ 8,
6
+ 16,
7
+ 32,
8
+ 48,
9
+ 64,
10
+ 96,
11
+ 128,
12
+ 192,
13
+ 256,
14
+ 384,
15
+ 512,
16
+ 768,
17
+ 1024
18
+ ],
19
+ "recalls": [
20
+ 1.0,
21
+ 0.0,
22
+ 0.6291782086795936,
23
+ 0.7152354570637119,
24
+ 0.7860572483841182,
25
+ 0.8456140350877193,
26
+ 0.8770083102493075,
27
+ 0.894921514312096,
28
+ 0.9179132040627885,
29
+ 0.9318559556786704,
30
+ 0.9501385041551247,
31
+ 0.960387811634349,
32
+ 0.9738688827331488,
33
+ 0.979870729455217,
34
+ 0.9875346260387812,
35
+ 0.9914127423822715
36
+ ],
37
+ "f1_scores": [
38
+ 0.2557521385990972,
39
+ 0.1781030368195021,
40
+ 0.2311241753690697,
41
+ 0.23319314466009197,
42
+ 0.23806248676137007,
43
+ 0.24238545934267358,
44
+ 0.24551399451683797,
45
+ 0.2464275695961469,
46
+ 0.24845445240371594,
47
+ 0.2504595681524961,
48
+ 0.2513924187737124,
49
+ 0.25451953400729516,
50
+ 0.2551967753562816,
51
+ 0.25548462312214937,
52
+ 0.25601382270551143,
53
+ 0.256212682348643
54
+ ],
55
+ "exact_match_scores": [
56
+ 0.18227146814404432,
57
+ 0.12132963988919668,
58
+ 0.16066481994459833,
59
+ 0.16149584487534627,
60
+ 0.1664819944598338,
61
+ 0.1703601108033241,
62
+ 0.17202216066481996,
63
+ 0.17229916897506925,
64
+ 0.1739612188365651,
65
+ 0.17534626038781165,
66
+ 0.17617728531855956,
67
+ 0.17977839335180054,
68
+ 0.1811634349030471,
69
+ 0.1814404432132964,
70
+ 0.1817174515235457,
71
+ 0.1817174515235457
72
+ ],
73
+ "parameters": {
74
+ "nlist": 8192,
75
+ "domain": "dpr",
76
+ "task": "nq",
77
+ "model": "meta-llama/Llama-3.2-1B",
78
+ "engine": "sglang"
79
+ },
80
+ "search_times": [
81
+ 0.0,
82
+ 1.907364845275879,
83
+ 1.9229207038879395,
84
+ 7.183107614517212,
85
+ 2.8659842014312744,
86
+ 3.249828338623047,
87
+ 3.6830973625183105,
88
+ 4.328709602355957,
89
+ 5.444960832595825,
90
+ 6.922391653060913,
91
+ 8.49331521987915,
92
+ 11.494524240493774,
93
+ 12.845796346664429,
94
+ 18.03567910194397,
95
+ 21.74203062057495
96
+ ]
97
+ }