Fix TypeError in real_toxicity_prompts due to None choices

Open Beginner friendly
#1,140 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

Start with the real_toxicity_prompts task initialization and the Pipeline.evaluate() reproduction described in the issue, then trace how Doc fields reach get_golds. Confirm the task initializes choices and gold_index as empty lists and rerun the provided pipeline to verify evaluation completes without the TypeError.

Written by the indexing model from the issue text.

Description

Describe the bug

The real_toxicity_prompts evaluation fails with a TypeError because choices and gold_index are initialized to None in the Doc object. Internal Lighteval logic (e.g. get_golds) expects these fields to be iterable (lists) even for purely generative tasks without predefined choices.

To Reproduce

task = "real_toxicity_prompts|5"

pipeline = Pipeline(
    tasks=task,
    pipeline_parameters=pipeline_params,
    evaluation_tracker=evaluation_tracker,
    model_config=model_config,
)

pipeline.evaluate()
pipeline.save_and_push_results()
pipeline.show_results()
    140 # We init tasks first to fail fast if one is badly defined
    141 self._init_random_seeds()
--> 142 self._init_tasks_and_requests(tasks=tasks)
    144 self.model_config = model_config
    145 self.accelerator, self.parallel_context = self._init_parallelism_manager()
...
    221 for gold_ix in gold_indices:
--> 222     golds.extend(as_list(self.choices[gold_ix]))
    223 return golds

TypeError: 'NoneType' object is not subscriptable

Expected behavior

choices and gold_index should be initialized to empty lists [] instead of None.

Version info

  • OS: mac
  • Lighteval version: main (local development)
Dominant language
Python
Stars
2.5k
Forks
557
Avg merge
1d 6h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from huggingface/lighteval

All issues in huggingface/lighteval

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.