How scicode-bench/scicode works
Project Type & Purpose
• SciCode is a Python benchmarking library and CLI tool for evaluating language models on scientific coding tasks.
• It provides:
• A core package (src/scicode) with submodules for parsing problems, generating model code, comparing results, and logging.
• Evaluation scripts and data under eval/.
• A CLI entry point for end-to-end runs.
• Integration with the inspect_ai framework and deprecated two-step scripts.
Key Architectural Components
a. Core Package (src/scicode)
• parse: Reads problem definitions and test cases (parse/parse.py).
• gen: Orchestrates model code generation (gen/models.py).
• compare: Runs and grades generated code against gold tests (compare/cmp.py).
• utils: Logging and common helpers.
• CLI: Exposed via pyproject.toml entry point (invokes parse→gen→compare).
b. Data Layer (eval/data)
• JSONL or HDF5 datasets of problems and numeric tests.
c. Evaluation Scripts (eval/scripts & eval/inspect_ai)
• inspect_ai adapter: wraps SciCode evaluation in that framework.
• Legacy scripts: gencode.py to generate outputs, test_generated_code.py to validate.
d. External Services
• Language-model APIs (e.g., OpenAI) called by gen/models.py or via inspect_ai.
e. Tests (tests/)
• Unit test for CLI and sample data checks.
Data Flow & Interactions
1) CLI receives user input (model name, temperature, data path).
2) Parser loads problems and optional background from data store.
3) Generator submodule sends prompts to chosen LM API (or local stub) and retrieves code.
4) Comparator executes generated code safely against test cases, computes metrics.
5) Results logged and optionally pushed to leaderboard or stored.
Architectural Patterns & Principles
• Modular pipeline: clear separation of parsing, generation, comparison.
• Plugin-style model integration: interchangeable model backends via gen/models.py or inspect_ai.
• Data-driven evaluation: problems and test definitions are externalized.
• CLI-first design: single entry point orchestrating the pipeline.