Skip to content

Return no attempts when a probe's prompt set is empty - #2035

Open
eeshsaxena wants to merge 1 commit into
NVIDIA:mainfrom
eeshsaxena:fix/probe-empty-prompt-set-2026
Open

Return no attempts when a probe's prompt set is empty#2035
eeshsaxena wants to merge 1 commit into
NVIDIA:mainfrom
eeshsaxena:fix/probe-empty-prompt-set-2026

Conversation

@eeshsaxena

Copy link
Copy Markdown

Fixes #2026

Problem

Probe.probe() in garak/probes/base.py uses len(prompts) for the preparation progress bar and then indexes prompts[0] to decide whether prompts are plain strings:

preparation_bar = tqdm.tqdm(total=len(prompts), ...)   # fine with 0
if isinstance(prompts[0], str):                          # IndexError when empty

An empty prompt set (including one emptied by translation under some langproviders) reaches the subscript and raises IndexError: list index out of range deep in the run, rather than simply producing zero attempts. This is observed on main via tests/probes/test_probes.py::test_probe_prompt_translation[...SystemPromptExtraction].

Fix

Return an empty attempt list (with a warning naming the probe) when the prompt set is empty, before the prompts[0] check.

Test

Added test_probe_empty_prompt_set_returns_no_attempts, which loads probes.test.Test, empties its prompts, and asserts probe() returns no attempts. It fails with IndexError before this change and passes after.

Probe.probe() used len(prompts) for the preparation progress bar but then
indexed prompts[0] to detect string prompts. An empty prompt set (for
example one emptied by translation under some langproviders) reached the
subscript and raised IndexError deep in the run instead of producing zero
attempts.

Return an empty attempt list (with a warning) when the prompt set is empty,
before the prompts[0] check. Adds a regression test.

Signed-off-by: eeshsaxena <eeshsaxena@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Probe.probe() raises IndexError when the prompt set is empty (translation can produce an empty set)

1 participant