Understand the CRUXEval benchmark construction process
mainThe CRUXEval benchmark is contained in cruxeval.jsonl and is constructed through a three-stage pipeline:
Data Generation: Functions and test inputs are generated using Code Llama 34B. The process uses prompts from
data_generating_prompt.jsonl(generated bygenerate_function_prompts.py) which request a Python function using a specific standard library function (fromstr,dict, orlist) along with 5 test inputs. Diversity is improved using few-shot examples fromdiverse_fewshot_examples.py.Filtering: Generations are filtered via
filter/analyze_ops.pyto ensure problems are short, low-complexity, and solvable by humans in about a minute. Criteria include:- Compile time: Code length between 75-300 characters, all arguments used, no syntax errors, and valid
assert f(input) == outputstatements. - Runtime: Execution under 2 seconds, no uncaught exceptions, no floating point operations or true division, and restricted argument sizes (integer arguments $\leq 3$, string/list argument lengths $\leq 3$).
- Code Quality: No imports (e.g.,
os,random), must be deterministic, and must not have side effects (e.g., modifying__builtins__).
- Compile time: Code length between 75-300 characters, all arguments used, no syntax errors, and valid
Dataset Selection: 800 samples are randomly selected from the filtered set to form the final benchmark.
The final dataset is available as cruxeval.jsonl or on HuggingFace Datasets.