Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/lighteval/main_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@
logger = logging.getLogger(__name__)


def _response_format_kwargs(response_format: str | None) -> dict:
"""inspect-ai removed GenerateConfig.response_format (>= 0.3.141).

Pass the flag through only when the installed inspect-ai accepts it, so a
fresh install does not crash at startup with a pydantic ValidationError.
"""
if response_format is None:
return {}
from inspect_ai.model import GenerateConfig

if "response_format" in GenerateConfig.model_fields:
return {"response_format": response_format}
logger.warning(
"--response-format is not supported by the installed inspect-ai (%s); ignoring it.",
getattr(__import__("inspect_ai"), "__version__", "unknown"),
)
return {}


@task
def get_inspect_ai_task(
lighteval_task_config: LightevalTaskConfig,
Expand Down Expand Up @@ -267,7 +286,7 @@ def eval( # noqa C901
rich_help_panel=HELP_PANEL_NAME_1,
),
] = None,
frequence_penalty: Annotated[
frequency_penalty: Annotated[
float | None,
Option(
help="Number between -2.0 and 2.0, Penalizes tokens that appear in the text too frequently, reducing repetition.",
Expand Down Expand Up @@ -309,7 +328,7 @@ def eval( # noqa C901
rich_help_panel=HELP_PANEL_NAME_1,
),
] = None,
log_probs: Annotated[
logprobs: Annotated[
bool | None,
Option(
help="Returns log probabilities for each token in the generated text", rich_help_panel=HELP_PANEL_NAME_1
Expand Down Expand Up @@ -474,19 +493,19 @@ def eval( # noqa C901
temperature=temperature,
top_p=top_p,
top_k=top_k,
frequence_penalty=frequence_penalty,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty,
seed=seed,
stop_seqs=stop_seqs,
num_choices=num_choices,
best_of=best_of,
log_probs=log_probs,
logprobs=logprobs,
top_logprobs=top_logprobs,
cache_prompt=cache_prompt,
reasoning_effort=reasoning_effort,
reasoning_tokens=reasoning_tokens,
reasoning_history=reasoning_history,
response_format=response_format,
**_response_format_kwargs(response_format),
parallel_tool_calls=parallel_tool_calls,
max_tool_output=max_tool_output,
internal_tools=internal_tools,
Expand Down