Skip to content

Commit d621dce

Browse files
committed
Merge upstream huggingface/lighteval main into merge_hf_main
Upstream refactor splits src/lighteval/tasks into per-task files under src/lighteval/tasks/tasks/ and src/lighteval/tasks/multilingual/tasks/, drops default_tasks.py / default_prompts.py / multilingual/tasks.py, and removes the suite field from LightevalTaskConfig. Port our edits to the new structure: - tasks/gsm_plus.py: generation_size 16384 - tasks/gsm8k.py: generation_size 2048 - tasks/mgsm.py: hf_revision, suffix exact_match + expr_gold_metric, language-specific stop sequences for all 11 subsets - tasks/piqa.py: switch to lighteval/piqa mirror - tasks/siqa.py: pin hf_revision - tasks/mmlu_pro.py: fix upstream's hardcoded ABCD letters so the prompt uses dynamic letters based on the number of options; add a parallel mmlu_pro_raw task exposing the handmade prompt (no inspect_ai) - tasks/ruler.py: new home for the ruler prompt helper - tasks/advbench.py: move here from community_tasks/ - multilingual/tasks/mathalea.py: move here from community_tasks/ - multilingual/tasks/french.py: keep jzhang86/fr_ifeval fallback and the generative GPQA-fr-diamond variant with prompt_gpqa_fr_instruct Other conflict resolutions: - pyproject.toml: take upstream unpinned transformers, vllm>=0.11.0, new inspect-ai and openai deps - vllm_model.py: keep max_seq_len_to_capture fallback, Mistral eos_token guard, prefix-cache None-skip in logprob loop, and skip_reading_prefix_cache via guarded attribute assignment; adopt upstream's build_vllm_token_prompts helper - llm_as_judge.py: keep max_model_len=65536, adopt upstream's api_key/base_url litellm pass-through - lighteval_task.py: preserve name/data_dir fallback in load_dataset while picking up upstream's data_files support; keep partial args detail in __str__ for deterministic cache hashing - cache_management.py: adopt name-only task_to_configs lookup; keep regex that strips function memory addresses for hash determinism
2 parents 481d9bd + 10b9104 commit d621dce

260 files changed

Lines changed: 41464 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: PR Style Bot
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
style:
12+
uses: huggingface/huggingface_hub/.github/workflows/style-bot-action.yml@e000c1c89c65aee188041723456ac3a479416d4c # main
13+
with:
14+
python_quality_dependencies: "[quality]"
15+
secrets:
16+
bot_token: ${{ secrets.HF_STYLE_BOT_ACTION }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: vLLM Main Branch Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * 1' # Every Monday at 2 AM UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test_vllm_main:
13+
name: Test with vLLM main branch
14+
runs-on: 'aws-g4dn-2xlarge-use1-public-80'
15+
continue-on-error: true
16+
17+
steps:
18+
- name: Install Git LFS
19+
run: |
20+
if ! command -v git-lfs &> /dev/null; then
21+
sudo apt-get update && sudo apt-get install -y git-lfs
22+
git lfs install
23+
fi
24+
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
lfs: true
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v5
32+
with:
33+
enable-cache: true
34+
35+
- name: Install the project
36+
run: uv sync --extra dev-gpu
37+
38+
- name: Install Python development headers
39+
run: sudo apt-get update && sudo apt-get install -y python3.12-dev
40+
41+
- name: Cache CUDA Toolkit
42+
id: cache-cuda
43+
uses: actions/cache@v4
44+
with:
45+
path: /usr/local/cuda-12.8
46+
key: cuda-toolkit-12-8-${{ runner.os }}
47+
48+
- name: Install CUDA Toolkit
49+
if: steps.cache-cuda.outputs.cache-hit != 'true'
50+
run: |
51+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
52+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
53+
sudo apt-get update
54+
sudo apt-get install -y cuda-toolkit-12-8
55+
56+
- name: Setup CUDA environment
57+
run: |
58+
echo "CUDA_HOME=/usr/local/cuda-12.8" >> $GITHUB_ENV
59+
echo "/usr/local/cuda-12.8/bin" >> $GITHUB_PATH
60+
61+
- name: Verify CUDA
62+
run: |
63+
nvidia-smi
64+
nvcc --version
65+
66+
- name: Install vLLM from main branch
67+
run: |
68+
uv pip uninstall -y vllm || true
69+
uv pip install git+https://github.com/vllm-project/vllm.git@main
70+
71+
- name: Get vLLM version
72+
id: vllm-info
73+
run: |
74+
VERSION=$(uv run python -c "import vllm; print(vllm.__version__)")
75+
echo "version=$VERSION" >> $GITHUB_OUTPUT
76+
echo "Testing vLLM version: $VERSION"
77+
78+
- name: Run tests
79+
run: uv run pytest --disable-pytest-warnings --runslow -v -s tests/slow_tests/test_vllm_model.py

docs/source/inspect-ai.mdx

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Evaluate your model with Inspect-AI
2+
3+
Pick the right benchmarks with our benchmark finder:
4+
Search by language, task type, dataset name, or keywords.
5+
6+
> [!WARNING]
7+
> Not all tasks are compatible with inspect-ai's API as of yet, we are working on converting all of them !
8+
9+
10+
<iframe
11+
src="https://openevals-open-benchmark-index.hf.space"
12+
frameborder="0"
13+
width="850"
14+
height="450"
15+
></iframe>
16+
17+
Once you've chosen a benchmark, run it with `lighteval eval`. Below are examples for common setups.
18+
19+
### Examples
20+
21+
1. Evaluate a model via Hugging Face Inference Providers.
22+
23+
```bash
24+
lighteval eval "hf-inference-providers/openai/gpt-oss-20b" gpqa:diamond
25+
```
26+
27+
2. Run multiple evals at the same time.
28+
29+
```bash
30+
lighteval eval "hf-inference-providers/openai/gpt-oss-20b" gpqa:diamond,aime25
31+
```
32+
33+
3. Compare providers for the same model.
34+
35+
```bash
36+
lighteval eval \
37+
hf-inference-providers/openai/gpt-oss-20b:fireworks-ai \
38+
hf-inference-providers/openai/gpt-oss-20b:together \
39+
hf-inference-providers/openai/gpt-oss-20b:nebius \
40+
gpqa:diamond
41+
```
42+
43+
You can also compare every providers serving one model in one line:
44+
45+
```bash
46+
hf-inference-providers/openai/gpt-oss-20b:all \
47+
"lighteval|gpqa:diamond|0"
48+
```
49+
50+
4. Evaluate a vLLM or SGLang model.
51+
52+
```bash
53+
lighteval eval vllm/HuggingFaceTB/SmolLM-135M-Instruct gpqa:diamond
54+
```
55+
56+
5. See the impact of few-shot on your model.
57+
58+
```bash
59+
lighteval eval hf-inference-providers/openai/gpt-oss-20b "gsm8k|0,gsm8k|5"
60+
```
61+
62+
6. Optimize custom server connections.
63+
64+
```bash
65+
lighteval eval hf-inference-providers/openai/gpt-oss-20b gsm8k \
66+
--max-connections 50 \
67+
--timeout 30 \
68+
--retry-on-error 1 \
69+
--max-retries 1 \
70+
--max-samples 10
71+
```
72+
73+
7. Use multiple epochs for more reliable results.
74+
75+
```bash
76+
lighteval eval hf-inference-providers/openai/gpt-oss-20b aime25 --epochs 16 --epochs-reducer "pass_at_4"
77+
```
78+
79+
8. Push to the Hub to share results.
80+
81+
```bash
82+
lighteval eval hf-inference-providers/openai/gpt-oss-20b hle \
83+
--bundle-dir gpt-oss-bundle \
84+
--repo-id OpenEvals/evals \
85+
--max-samples 100
86+
```
87+
88+
Resulting Space:
89+
90+
<iframe
91+
src="https://openevals-evals.static.hf.space"
92+
frameborder="0"
93+
width="850"
94+
height="450"
95+
></iframe>
96+
97+
9. Change model behaviour
98+
99+
You can use any argument defined in inspect-ai's API.
100+
101+
```bash
102+
lighteval eval hf-inference-providers/openai/gpt-oss-20b aime25 --temperature 0.1
103+
```
104+
105+
10. Use model-args to use any inference provider specific argument.
106+
107+
```bash
108+
lighteval eval google/gemini-2.5-pro aime25 --model-args location=us-east5
109+
```
110+
111+
```bash
112+
lighteval eval openai/gpt-4o gpqa:diamond --model-args service_tier=flex,client_timeout=1200
113+
```
114+
115+
116+
LightEval prints a per-model results table:
117+
118+
```
119+
Completed all tasks in 'lighteval-logs' successfully
120+
121+
| Model |gpqa|gpqa:diamond|
122+
|---------------------------------------|---:|-----------:|
123+
|vllm/HuggingFaceTB/SmolLM-135M-Instruct|0.01| 0.01|
124+
125+
results saved to lighteval-logs
126+
run "inspect view --log-dir lighteval-logs" to view the results
127+
```

docs/source/offline-evaluation.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Offline evaluation using local data files
2+
3+
If you are prototyping a task based on files that are not yet hosted on the
4+
Hub, you can take advantage of the `hf_data_files` argument to point lighteval
5+
at local JSON/CSV resources. This makes it easy to evaluate datasets that live
6+
in your repo or that are generated on the fly.
7+
8+
Internally, `hf_data_files` is passed directly to the `data_files` parameter of `datasets.load_dataset` ([docs]((https://huggingface.co/docs/datasets/en/package_reference/loading_methods#datasets.load_dataset))).
9+
10+
See [adding a custom task](adding-a-custom-task) for more information on how to create a custom task.
11+
12+
```python
13+
from pathlib import Path
14+
15+
from lighteval.metrics import Metrics
16+
from lighteval.tasks.lighteval_task import LightevalTaskConfig
17+
from lighteval.tasks.requests import Doc
18+
19+
20+
def local_prompt(line: dict, task_name: str) -> Doc:
21+
return Doc(
22+
task_name=task_name,
23+
query=line["question"],
24+
choices=line["choices"],
25+
gold_index=line["answer"]
26+
)
27+
28+
29+
local_data = Path(__file__).parent / "samples" / "faq.jsonl"
30+
31+
local_task = LightevalTaskConfig(
32+
name="faq_eval",
33+
prompt_function=local_prompt,
34+
hf_repo="json", # Built-in streaming loader for json/jsonl files
35+
hf_subset="default",
36+
hf_data_files=str(local_data), # Can also be a dict mapping split names to paths
37+
evaluation_splits=["train"],
38+
metrics=[Metrics.ACCURACY],
39+
)
40+
```
41+
42+
Once the config is registered in `TASKS_TABLE`, running the task with
43+
`--custom-tasks path/to/your_file.py` will automatically load the local data
44+
files. You can also pass a dictionary to `hf_data_files` (e.g.
45+
`{"train": "train.jsonl", "validation": "val.jsonl"}`) to expose multiple
46+
splits.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# MIT License
2+
3+
# Copyright (c) 2024 The HuggingFace Team
4+
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
import json
24+
import logging
25+
import tempfile
26+
from functools import partial
27+
from pathlib import Path
28+
29+
from custom_yourbench_task_mcq import yourbench_prompt
30+
from datasets import Dataset, DatasetDict
31+
32+
from lighteval.metrics.metrics import Metrics
33+
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
34+
35+
36+
logger = logging.getLogger(__name__)
37+
38+
save_dir = str(tempfile.mkdtemp())
39+
40+
ds = DatasetDict(
41+
{
42+
"train": Dataset.from_dict(
43+
{
44+
"question": ["What is 2+2?", "Capital of France?"],
45+
"choices": [["1", "2", "3", "4"], ["Paris", "Berlin", "Rome", "Madrid"]],
46+
"gold": [[3], [0]],
47+
}
48+
)
49+
}
50+
)
51+
52+
53+
CustomTaskConfig = partial(
54+
LightevalTaskConfig,
55+
prompt_function=yourbench_prompt,
56+
hf_avail_splits=["train"],
57+
evaluation_splits=["train"],
58+
few_shots_split=None,
59+
few_shots_select=None,
60+
generation_size=16,
61+
metrics=[Metrics.gpqa_instruct_metric],
62+
version=0,
63+
)
64+
65+
# Example 1: save to disk (huggingface format) ####
66+
67+
ds.save_to_disk(save_dir)
68+
69+
yourbench_mcq = CustomTaskConfig(
70+
name="tiny_mcqa_dataset",
71+
hf_repo="arrow",
72+
hf_subset="default",
73+
hf_data_files=f"{save_dir}/**/*.arrow",
74+
)
75+
76+
task = LightevalTask(yourbench_mcq)
77+
eval_docs = task.eval_docs()
78+
79+
print("\n>>READING TASK FROM ARROW<<")
80+
for doc in eval_docs:
81+
print(doc)
82+
83+
84+
# Example 2: jsonlines format ####
85+
86+
jsonl_path = Path(save_dir) / "train.jsonl"
87+
with open(jsonl_path, "w") as f:
88+
for row in ds["train"]:
89+
f.write(json.dumps(row) + "\n")
90+
91+
yourbench_mcq = CustomTaskConfig(
92+
name="tiny_mcqa_dataset",
93+
hf_repo="json",
94+
hf_subset="default",
95+
hf_data_files=str(jsonl_path),
96+
)
97+
98+
task = LightevalTask(yourbench_mcq)
99+
eval_docs = task.eval_docs()
100+
101+
print("\n>>READING TASK FROM JSONLINES<<")
102+
for doc in eval_docs:
103+
print(doc)
104+
105+
# TASKS_TABLE = [yourbench_mcq]

0 commit comments

Comments
 (0)