# openai/evals architecture

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

- Interactive diagram: https://gitdiagram.com/openai/evals
- Repository: https://github.com/openai/evals

## Overview

##### High-Level Architecture Components

a. Core Components:
- Evaluation Engine
- Registry System
- Completion Functions
- Solvers
- Data Storage
- API Integration Layer

b. Supporting Components:
- CLI Interface
- Logging System
- Configuration Management
- Results Reporting

##### Detailed Component Breakdown

a. Evaluation Engine (evals/eval.py):
- Evaluation Controller
- Task State Manager
- Metrics Calculator
- Results Aggregator

b. Registry System (evals/registry/):
- Eval Registry
- Data Registry
- Solver Registry
- Completion Function Registry

c. Completion Functions (evals/completion_fns/):
- OpenAI API Handler
- LangChain Integration
- Custom Completion Functions
- Chain-of-Thought Processing

d. Solvers (evals/solvers/):
- Base Solver Interface
- Provider-specific Solvers (OpenAI, Anthropic, Google, Together)
- Human CLI Solver
- Nested Solvers (CoT, Few-shot, etc.)

e. Data Management:
- Local Data Storage
- Snowflake Integration
- Git LFS Integration

##### Key Relationships and Data Flow

- User input → CLI Interface → Evaluation Engine
- Evaluation Engine ↔ Registry System
- Evaluation Engine → Completion Functions → External APIs
- Results → Logging System → Storage/Reporting
- Solvers ↔ Completion Functions

##### Implementation Details

a. File Organization:
- Main directory structure (evals/, docs/, examples/)
- Configuration files
- Test infrastructure

b. Integration Points:
- API connectivity
- Database connections
- External tool integration

##### Data flow and transformation paths

Remember to include version information and any relevant dependencies or requirements (Python 3.9+, Git LFS, etc.) in a notes section.

This architecture should be drawn to highlight the system's flexibility in supporting different types of evaluations while maintaining a consistent interface for users and developers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI
        CLI_Main["CLI Interface"]:::cli
        CLI_EvalSet["Eval Set CLI"]:::cli
    end

    subgraph Core["Core Components"]
        EvalEngine["Evaluation Engine"]:::core
        TaskState["Task State Manager"]:::core
        Metrics["Metrics Calculator"]:::core
        Results["Results Aggregator"]:::core
    end

    subgraph Registry["Registry System"]
        EvalReg["Eval Registry"]:::registry
        DataReg["Data Registry"]:::registry
        SolverReg["Solver Registry"]:::registry
        CompFnReg["Completion Function Registry"]:::registry
    end

    subgraph CompFns["Completion Functions"]
        OpenAIHandler["OpenAI Handler"]:::comp
        LangChain["LangChain Integration"]:::comp
        CoT["Chain-of-Thought"]:::comp
        Retrieval["Retrieval"]:::comp
    end

    subgraph Solvers
        BaseSolver["Base Solver Interface"]:::solver
        ProviderSolvers["Provider-specific Solvers"]:::solver
        HumanCLI["Human CLI Solver"]:::solver
        NestedSolvers["Nested Solvers"]:::solver
    end

    subgraph Support["Supporting Systems"]
        Logging["Logging System"]:::support
        APIInteg["API Integration"]:::support
        BaseClasses["Base Classes"]:::support
    end

    subgraph External["External Services"]
        OpenAI_API["OpenAI API"]:::external
        Storage["Data Storage"]:::external
    end

    CLI_Main --> EvalEngine
    CLI_EvalSet --> EvalEngine
    
    EvalEngine --> TaskState
    EvalEngine --> Metrics
    EvalEngine --> Results
    
    EvalEngine <--> Registry
    Registry --> CompFns
    Registry --> Solvers
    
    CompFns --> APIInteg
    APIInteg --> OpenAI_API
    
    Solvers <--> CompFns
    
    Results --> Logging
    Logging --> Storage

    %% Click Events
    click EvalEngine "https://github.com/openai/evals/blob/main/evals/eval.py"
    click EvalReg "https://github.com/openai/evals/tree/main/evals/registry/evals/"
    click DataReg "https://github.com/openai/evals/tree/main/evals/registry/data/"
    click SolverReg "https://github.com/openai/evals/tree/main/evals/registry/solvers/"
    click CompFnReg "https://github.com/openai/evals/tree/main/evals/registry/completion_fns/"
    click OpenAIHandler "https://github.com/openai/evals/blob/main/evals/completion_fns/openai.py"
    click LangChain "https://github.com/openai/evals/blob/main/evals/completion_fns/langchain_llm.py"
    click CoT "https://github.com/openai/evals/blob/main/evals/completion_fns/cot.py"
    click Retrieval "https://github.com/openai/evals/blob/main/evals/completion_fns/retrieval.py"
    click BaseSolver "https://github.com/openai/evals/blob/main/evals/solvers/solver.py"
    click ProviderSolvers "https://github.com/openai/evals/tree/main/evals/solvers/providers/"
    click HumanCLI "https://github.com/openai/evals/blob/main/evals/solvers/human_cli_solver.py"
    click NestedSolvers "https://github.com/openai/evals/tree/main/evals/solvers/nested/"
    click CLI_Main "https://github.com/openai/evals/blob/main/evals/cli/oaieval.py"
    click CLI_EvalSet "https://github.com/openai/evals/blob/main/evals/cli/oaievalset.py"
    click Logging "https://github.com/openai/evals/blob/main/evals/utils/log_utils.py"
    click APIInteg "https://github.com/openai/evals/blob/main/evals/api.py"
    click BaseClasses "https://github.com/openai/evals/blob/main/evals/base.py"
    click Metrics "https://github.com/openai/evals/blob/main/evals/metrics.py"
    click TaskState "https://github.com/openai/evals/blob/main/evals/task_state.py"

    %% Styling
    classDef core fill:#2374ab
    classDef registry fill:#48a9a6
    classDef comp fill:#4ea5d9
    classDef solver fill:#44cfcb
    classDef support fill:#9b5de5
    classDef external fill:#f15bb5
    classDef cli fill:#fee440
```
