Skip to content

Commit 5b7ca62

Browse files
authored
run all hf providers with :all (#1039)
* run all hf-providers * add example * remove uneeded params
1 parent b5cbd91 commit 5b7ca62

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

docs/source/inspect-ai.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ lighteval eval \
4040
"lighteval|gpqa:diamond|0"
4141
```
4242

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+
4350
4. Evaluate a vLLM or SGLang model.
4451

4552
```bash

src/lighteval/main_inspect.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from collections import defaultdict
2525
from typing import Literal
2626

27+
import requests
2728
from huggingface_hub import HfApi
2829
from inspect_ai import Epochs, Task, task
2930
from inspect_ai import eval_set as inspect_ai_eval_set
@@ -182,13 +183,31 @@ def _format_metric_cell(data: dict, col: str, metric: str, stderr_metric: str) -
182183
return "-"
183184

184185

186+
def _get_huggingface_providers(model_id: str):
187+
model_id = model_id.replace("hf-inference-providers/", "").replace(":all", "")
188+
url = f"https://huggingface.co/api/models/{model_id}"
189+
params = {"expand[]": "inferenceProviderMapping"}
190+
response = requests.get(url, params=params)
191+
response.raise_for_status() # raise exception for HTTP errors
192+
data = response.json()
193+
# Extract provider mapping if available
194+
providers = data.get("inferenceProviderMapping", {})
195+
196+
live_providers = []
197+
for provider, info in providers.items():
198+
if info.get("status") == "live":
199+
live_providers.append(provider)
200+
201+
return live_providers
202+
203+
185204
HELP_PANEL_NAME_1 = "Modeling Parameters"
186205
HELP_PANEL_NAME_2 = "Task Parameters"
187206
HELP_PANEL_NAME_3 = "Connection and parallelization parameters"
188207
HELP_PANEL_NAME_4 = "Logging parameters"
189208

190209

191-
def eval(
210+
def eval( # noqa C901
192211
models: Annotated[list[str], Argument(help="Models to evaluate")],
193212
tasks: Annotated[str, Argument(help="Tasks to evaluate")],
194213
# model arguments
@@ -404,6 +423,11 @@ def eval(
404423
else:
405424
model_args = {}
406425

426+
for model in models:
427+
if model.split("/")[0] == "hf-inference-providers" and model.split(":")[-1] == "all":
428+
providers = _get_huggingface_providers(model)
429+
models = [f"{model.replace(':all', '')}:{provider}" for provider in providers]
430+
407431
success, logs = inspect_ai_eval_set(
408432
inspect_ai_tasks,
409433
model=models,

0 commit comments

Comments
 (0)