Skip to content

Fix LiveCodeBench crashes with type safety and list conversion #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dkimds
Copy link

@dkimds dkimds commented Jul 1, 2025

Summary

Fixes #136 by adding robust type checking and ensuring dataset is properly converted to list format.

Problem Solved

LiveCodeBench variants could crash or behave unexpectedly due to:

  • Dataset iteration issues when not converted to list
  • Missing type validation causing runtime errors

Changes

Files Modified:

  • eval/chat_benchmarks/LiveCodeBench/eval_instruct.py
  • eval/chat_benchmarks/LiveCodeBenchv5/eval_instruct.py
  • eval/chat_benchmarks/LiveCodeBenchv5_official/eval_instruct.py

Key Improvements:

  1. Explicit list conversion: examples = list(examples_dataset)
  2. Type safety: Added isinstance(example, dict) checks
  3. Error logging: Non-dict examples logged and skipped instead of crashing

Code Changes

# Before
examples_dataset = self.load_questions()
for idx, example in enumerate(examples_dataset):
    # Could crash if example is not dict

# After  
examples = list(self.load_questions())
for idx, example in enumerate(examples):
    if not isinstance(example, dict):
        self.logger.error(f"Example {idx} not dict: {type(example)}")
        continue
    # Safe to process

## Testing
```bash
# Test all LiveCodeBench variants work without crashes
python -m eval.eval --model hf --tasks LiveCodeBench --debug --model_args "pretrained=microsoft/DialoGPT-medium"
python -m eval.eval --model hf --tasks LiveCodeBenchv5 --debug --model_args "pretrained=microsoft/DialoGPT-medium"

Impact

✅ Prevents runtime crashes from type mismatches
✅ More robust error handling and logging
✅ Better debugging experience
✅ No functional changes to working cases

LiveCodeBench, LiveCodeBenchv5, LiveCodeBenchv5_official
@dkimds
Copy link
Author

dkimds commented Jul 4, 2025

Hi @neginraoof, could you please take a quick look at my PR when you have time? Thanks!

@dkimds dkimds changed the title fix: add type check and list conversion for LiveCodeBenchs Fix LiveCodeBench crashes with type safety and list conversion Jul 8, 2025
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.

LiveCodeBench crashes on iteration due to dataset type inconsistency
1 participant