Skip to content

Commit b12ac5b

Browse files
committed
fix(inspect): align GenerateConfig field names with current inspect-ai
- rename CLI/eval_set kwarg 'frequence_penalty' -> 'frequency_penalty' (typo; inspect-ai field name) - rename 'log_probs' -> 'logprobs' (inspect-ai field name) - pass 'response_format' only when the installed inspect-ai still accepts it, warn otherwise (removed in >= 0.3.141) Fixes #1327: a fresh 'pip install lighteval' resolves inspect-ai to the latest release and 'lighteval eval' crashed at startup with a pydantic ValidationError. Verified on inspect-ai 0.3.257: the repro command from the issue now completes.
1 parent 932e1f2 commit b12ac5b

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

src/lighteval/main_inspect.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@
4343

4444
logger = logging.getLogger(__name__)
4545

46+
def _response_format_kwargs(response_format: str | None) -> dict:
47+
"""inspect-ai removed GenerateConfig.response_format (>= 0.3.141).
48+
49+
Pass the flag through only when the installed inspect-ai accepts it, so a
50+
fresh install does not crash at startup with a pydantic ValidationError.
51+
"""
52+
if response_format is None:
53+
return {}
54+
from inspect_ai.model import GenerateConfig
55+
56+
if "response_format" in GenerateConfig.model_fields:
57+
return {"response_format": response_format}
58+
logger.warning(
59+
"--response-format is not supported by the installed inspect-ai (%s); ignoring it.",
60+
getattr(__import__("inspect_ai"), "__version__", "unknown"),
61+
)
62+
return {}
63+
64+
4665

4766
@task
4867
def get_inspect_ai_task(
@@ -267,7 +286,7 @@ def eval( # noqa C901
267286
rich_help_panel=HELP_PANEL_NAME_1,
268287
),
269288
] = None,
270-
frequence_penalty: Annotated[
289+
frequency_penalty: Annotated[
271290
float | None,
272291
Option(
273292
help="Number between -2.0 and 2.0, Penalizes tokens that appear in the text too frequently, reducing repetition.",
@@ -309,7 +328,7 @@ def eval( # noqa C901
309328
rich_help_panel=HELP_PANEL_NAME_1,
310329
),
311330
] = None,
312-
log_probs: Annotated[
331+
logprobs: Annotated[
313332
bool | None,
314333
Option(
315334
help="Returns log probabilities for each token in the generated text", rich_help_panel=HELP_PANEL_NAME_1
@@ -474,19 +493,19 @@ def eval( # noqa C901
474493
temperature=temperature,
475494
top_p=top_p,
476495
top_k=top_k,
477-
frequence_penalty=frequence_penalty,
496+
frequency_penalty=frequency_penalty,
478497
presence_penalty=presence_penalty,
479498
seed=seed,
480499
stop_seqs=stop_seqs,
481500
num_choices=num_choices,
482501
best_of=best_of,
483-
log_probs=log_probs,
502+
logprobs=logprobs,
484503
top_logprobs=top_logprobs,
485504
cache_prompt=cache_prompt,
486505
reasoning_effort=reasoning_effort,
487506
reasoning_tokens=reasoning_tokens,
488507
reasoning_history=reasoning_history,
489-
response_format=response_format,
508+
**_response_format_kwargs(response_format),
490509
parallel_tool_calls=parallel_tool_calls,
491510
max_tool_output=max_tool_output,
492511
internal_tools=internal_tools,

0 commit comments

Comments
 (0)