# bigcode-project/bigcodebench architecture

> Architecture diagram of the GitHub repository bigcode-project/bigcodebench, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bigcode-project/bigcodebench
- Repository: https://github.com/bigcode-project/bigcodebench

## Overview

##### Project Type and Purpose
- BigCodeBench is an open-source Python benchmarking toolkit and CLI for evaluating code generation capabilities of large language models (LLMs).
- It provides commands to generate code samples (`bigcodebench.generate`), remotely or locally execute those samples (`bigcodebench.evaluate`), sanitize outputs (`bigcodebench.sanitize`/`syncheck`), and aggregate/analyze results.

##### File Structure Analysis
- Top-level components:
- bigcodebench/           ← core Python package
- analysis/               ← post-evaluation scripts for result aggregation
- decontamination/        ← code-overlap checking modules and data
- Docker/ & sandbox-templates/ ← container and sandbox configs
- tests/                  ← unit tests for sanitizers
- tools/                  ← migration scripts for prior versions
- CLI wrappers: run.sh, release.sh
- Within bigcodebench/:
- gen/util/               ← provider adapters for OpenAI, Anthropic, Google, HF, Mistral, vLLM, E2B
- eval/                   ← evaluation logic, oracles, utilities
- data/                   ← dataset loader and utilities
- sanitize.py / syncheck.py ← sanitization pipelines
- inspect.py              ← helper to inspect provider responses

##### Key README Insights
- Multi-backend support (vLLM, OpenAI, Anthropic, Google, HF, E2B) via adapter modules
- Remote evaluation via a Hugging Face Gradio space or an E2B sandbox
- Docker images specialized for generation, evaluation, and Gradio UI
- Result files and pass@k statistics saved locally

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        G["bigcodebench.generate"]:::cli
        E["bigcodebench.evaluate"]:::cli
        I["bigcodebench.inspect"]:::cli
        S1["bigcodebench.sanitize"]:::cli
        S2["bigcodebench.syncheck"]:::cli
    end

    %% Core Library
    subgraph "BigCodeBench Package"
        GEN["Generation Module\n(bigcodebench/gen/)"]:::core
        EVAL["Evaluation Module\n(bigcodebench/eval/)"]:::core
        DATA["Data Loader\n(bigcodebench/data/)"]:::core
    end

    %% Decontamination
    subgraph "Decontamination"
        NGRAM["n_gram_check.py"]:::decon
        TXT["Overlap Datasets"]:::decon
    end

    %% Provider Adapters
    subgraph "Provider Adapters"
        ORU["openai_request.py"]:::provider
        OA["openai.py Adapter"]:::provider
        ANU["anthropic_request.py"]:::provider
        AA["anthropic.py Adapter"]:::provider
        GRU["google_request.py"]:::provider
        GA["google.py Adapter"]:::provider
        HRU["hf_inference_request.py"]:::provider
        HA["hf_inference.py Adapter"]:::provider
        MRU["mistral_request.py"]:::provider
        MA["mistral.py Adapter"]:::provider
        VLLM["vllm.py Adapter"]:::provider
        PB["base.py"]:::provider
        PU["utility.py"]:::provider
    end

    %% External Services
    subgraph "External Services"
        OAAPI["OpenAI API"]:::external
        APAI["Anthropic API"]:::external
        GAAPI["Google AI API"]:::external
        HFAPI["HF Inference API"]:::external
        MAPI["Mistral API"]:::external
        VAPI["vLLM Local"]:::external
        E2B["E2B Sandbox"]:::external
        GRAD["Hugging Face Gradio"]:::external
        LOCAL["Local Execution"]:::external
    end

    %% Docker Environments
    subgraph "Docker Environments"
        DGEN["Generate.Dockerfile"]:::docker
        DEVAL["Evaluate.Dockerfile"]:::docker
        DGRAD["Gradio.Dockerfile"]:::docker
    end

    %% Data Storage
    subgraph "Data Storage"
        RESULTS["bcb_results/"]:::storage
        DSRC["Dataset Files"]:::storage
    end

    %% Analysis Tools
    subgraph "Analysis Scripts"
        SUB["bcb_subset.py"]:::analysis
        GET["get_results.py"]:::analysis
        AUT["utils.py"]:::analysis
    end

    %% Tests
    subgraph "Tests"
        TESTS["tests/"]:::tests
    end

    %% Connections
    G -->|uses| GEN
    E -->|uses| EVAL
    I -->|inspects via| GEN
    GEN -->|loads tasks| DATA
    DATA -->|filters| NGRAM
    NGRAM -->|uses| TXT

    %% Generation flow
    GEN -->|calls util| ORU
    ORU -->|inherits| PB
    ORU -->|calls| OAAPI
    OA -->|adapts calls| OAAPI

    GEN -->|calls util| ANU
    ANU -->|inherits| PB
    ANU -->|calls| APAI
    AA -->|adapts calls| APAI

    GEN -->|calls util| GRU
    GRU -->|inherits| PB
    GRU -->|calls| GAAPI
    GA -->|adapts calls| GAAPI

    GEN -->|calls util| HRU
    HRU -->|inherits| PB
    HRU -->|calls| HFAPI
    HA -->|adapts calls| HFAPI

    GEN -->|calls util| MRU
    MRU -->|inherits| PB
    MRU -->|calls| MAPI
    MA -->|adapts calls| MAPI

    GEN -->|calls| VLLM
    VLLM -->|interacts| VAPI

    GEN -->|calls| PU

    %% Evaluation flow
    EVAL -->|executes on| GRAD
    EVAL -->|executes on| E2B
    EVAL -->|executes on| LOCAL

    %% Docker linkages
    DGEN -->|builds env| GRAD
    DEVAL -->|builds env| E2B
    DGRAD -->|builds env| GRAD

    %% Sanitization and Storage
    EVAL -->|produces| S1
    EVAL -->|produces| S2
    S1 -->|cleans| RESULTS
    S2 -->|checks| RESULTS

    %% Analysis
    RESULTS -->|aggregates| SUB
    RESULTS -->|loads| GET
    SUB -->|uses| AUT
    GET -->|uses| AUT

    %% Tests
    TESTS -->|validates| S1
    TESTS -->|validates| S2

    %% Class Definitions
    classDef cli fill:#D2B4DE,stroke:#000,color:#000;
    classDef core fill:#AED6F1,stroke:#000,color:#000;
    classDef provider fill:#ABEBC6,stroke:#000,color:#000;
    classDef external fill:#F5B041,stroke:#000,color:#000;
    classDef docker fill:#F8C471,stroke:#000,color:#000;
    classDef storage fill:#D5D8DC,stroke:#000,color:#000;
    classDef analysis fill:#F0B27A,stroke:#000,color:#000;
    classDef decon fill:#64E5FF,stroke:#000,color:#000;
    classDef tests fill:#CCD1D1,stroke:#000,color:#000;

    %% Click Events
    click G "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/generate.py"
    click E "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/evaluate.py"
    click I "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/inspect.py"
    click S1 "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/sanitize.py"
    click S2 "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/syncheck.py"

    click GEN "https://github.com/bigcode-project/bigcodebench/tree/main/bigcodebench/gen/"
    click EVAL "https://github.com/bigcode-project/bigcodebench/tree/main/bigcodebench/eval/"
    click DATA "https://github.com/bigcode-project/bigcodebench/tree/main/bigcodebench/data/"

    click ORU "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/gen/util/openai_request.py"
    click OA "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/openai.py"
    click ANU "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/gen/util/anthropic_request.py"
    click AA "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/anthropic.py"
    click GRU "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/gen/util/google_request.py"
    click GA "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/google.py"
    click HRU "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/gen/util/hf_inference_request.py"
    click HA "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/hf_inference.py"
    click MRU "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/gen/util/mistral_request.py"
    click MA "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/mistral.py"
    click VLLM "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/vllm.py"
    click PB "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/base.py"
    click PU "https://github.com/bigcode-project/bigcodebench/blob/main/bigcodebench/provider/utility.py"

    click DGEN "https://github.com/bigcode-project/bigcodebench/blob/main/Docker/Generate.Dockerfile"
    click DEVAL "https://github.com/bigcode-project/bigcodebench/blob/main/Docker/Evaluate.Dockerfile"
    click DGRAD "https://github.com/bigcode-project/bigcodebench/blob/main/Docker/Gradio.Dockerfile"
    click E2B "https://github.com/bigcode-project/bigcodebench/blob/main/sandbox-templates/e2b.Dockerfile"
    click GRAD "https://github.com/bigcode-project/bigcodebench/blob/main/sandbox-templates/e2b.toml"

    click SUB "https://github.com/bigcode-project/bigcodebench/blob/main/analysis/bcb_subset.py"
    click GET "https://github.com/bigcode-project/bigcodebench/blob/main/analysis/get_results.py"
    click AUT "https://github.com/bigcode-project/bigcodebench/blob/main/analysis/utils.py"

    click NGRAM "https://github.com/bigcode-project/bigcodebench/blob/main/decontamination/n_gram_check.py"
```
