# pan2013e/dreval architecture

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

- Interactive diagram: https://gitdiagram.com/pan2013e/dreval
- Repository: https://github.com/pan2013e/dreval

## Overview

##### Project Type & Purpose
- The project is a research evaluation framework meant for replicating experiments on evaluating diverse LLMs (both via OpenAI API and open-source models using vLLM).
- It is structured to handle benchmark data processing, prompt management, model inference, evaluation execution, and concurrent task running.

##### Main Components
a. Data & Configuration Module:
- “data” Directory: Contains benchmark datasets (e.g., DREval_data.jsonl, DREval_tasks.jsonl) which hold evaluation tasks.
- “model_list.txt”: Lists IDs/URLs of the LLM models used.
- Configuration files (generated and manipulated via evaluation.py’s config command).

b. Prompt Management Module:
- “prompts” Directory: Contains various text templates (e.g., cot_* and direct_* files) for constructing prompts.
- “prompt.py”: Reads these templates and builds concrete prompts during evaluation.

c. Evaluation & Execution Engine:
- “evaluation.py”: The main entry point with modes for configuration creation and execution of experiments.
- “execution.py”, “inference.py”, “dynamics.py”: Likely handle different aspects of running the evaluation process (e.g., how inference is run, tasks are dynamically managed, or program behaviors are analyzed).

d. Task and Experiment Control:
- “taskgen.py”: Handles task generation using the benchmark data, creating inputs for evaluation.
- “batch_run.py”: Allows running tasks concurrently, important for scaling experiments.

e. API Server Component:
- “start_server.sh”: A Bash script that starts a local OpenAI-compatible API server powered by the vLLM library. This module interacts with backend inference services and simulates API calls.

f. Supporting & Utility Scripts:
- “dataset.py” & “test.py”: Provide utility functions and testing frameworks that support the main evaluation workflow.
- “model_list.txt” being an important descriptor for model sourcing.

##### Relationships & Data Flow
- The Evaluation Engine (evaluation.py) is the central controller. It reads configuration files, invokes prompt construction (via prompt.py) to prepare prompts based on templates, and then uses the generated prompts with the evaluation backend.
- Data from the “data” directory is loaded by modules responsible for building benchmark tasks, as coordinated by taskgen.py.
- When running evaluations, the system may interact with a local API server (initiated by start_server.sh) that acts as an interface to the underlying LLM engines (via vLLM or OpenAI API).
- Batch_run.py enables concurrent execution, managing parallel tasks for faster experimentation.
- Utility modules (e.g., dataset.py, dynamics.py, etc.) support the core evaluation-loop with additional functionalities like state management and runtime behavior analysis.

##### Architectural Patterns / Design Principles
- Modular Design: Each functional part (data management, prompt generation, execution, API communication) is clearly separated into its own module.
- Separation of Concerns: Frontline evaluation commands, configuration management, and task generation are distinct to simplify testing and experimental reproducibility.
- Extensibility: The prompt management and model interface layers are designed such that new prompt templates or model integrations can be added relatively easily.
- Concurrency: Batch_run.py indicates a design pattern for concurrent or parallel task execution.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data & Configuration Module
    subgraph "Data & Configuration Module"
        DATA_DIR["Data Directory (data/)"]:::core
        MODEL_LIST["Model List (model_list.txt)"]:::core
    end

    %% Prompt Management Module
    subgraph "Prompt Management Module"
        PROMPTS_DIR["Prompts Directory (prompts/)"]:::core
        PROMPT_BUILDER["Prompt Builder (prompt.py)"]:::core
    end

    %% Evaluation & Execution Engine
    subgraph "Evaluation & Execution Engine"
        EVAL["Evaluation (evaluation.py)"]:::core
        EXEC["Execution (execution.py)"]:::core
        INF["Inference (inference.py)"]:::core
        DYN["Dynamics (dynamics.py)"]:::core
    end

    %% Task and Experiment Control
    subgraph "Task and Experiment Control"
        TASK_GEN["Task Generator (taskgen.py)"]:::core
        BATCH_RUNNER["Batch Runner (batch_run.py)"]:::core
    end

    %% API Server Component
    subgraph "API Server Component"
        API_SERVER["Local API Server (start_server.sh)"]:::core
    end

    %% Supporting & Utility Scripts
    subgraph "Supporting & Utility Scripts"
        DATASET["Dataset Utility (dataset.py)"]:::support
        TEST_UTIL["Test Utility (test.py)"]:::support
    end

    %% External Dependency
    ExternalLLM["External: LLM Engines"]:::external

    %% Data Flow Connections
    DATA_DIR -->|"provides data"| TASK_GEN
    MODEL_LIST -->|"lists models"| TASK_GEN
    PROMPT_BUILDER -->|"builds prompts"| EVAL
    TASK_GEN -->|"generates tasks"| EVAL
    EVAL -->|"triggers concurrent run"| BATCH_RUNNER
    EVAL -->|"invokes API"| API_SERVER
    API_SERVER -->|"calls"| ExternalLLM
    DATASET -->|"supports"| EVAL
    TEST_UTIL -->|"supports"| EVAL

    %% Internal Evaluation Engine Components Dependencies
    EVAL -->|"delegates execution"| EXEC
    EVAL -->|"handles inference"| INF
    EVAL -->|"analyzes dynamics"| DYN

    %% Click Events
    click DATA_DIR "https://github.com/pan2013e/dreval/tree/main/data/"
    click MODEL_LIST "https://github.com/pan2013e/dreval/blob/main/model_list.txt"
    click PROMPTS_DIR "https://github.com/pan2013e/dreval/tree/main/prompts/"
    click PROMPT_BUILDER "https://github.com/pan2013e/dreval/blob/main/prompt.py"
    click EVAL "https://github.com/pan2013e/dreval/blob/main/evaluation.py"
    click EXEC "https://github.com/pan2013e/dreval/blob/main/execution.py"
    click INF "https://github.com/pan2013e/dreval/blob/main/inference.py"
    click DYN "https://github.com/pan2013e/dreval/blob/main/dynamics.py"
    click TASK_GEN "https://github.com/pan2013e/dreval/blob/main/taskgen.py"
    click BATCH_RUNNER "https://github.com/pan2013e/dreval/blob/main/batch_run.py"
    click API_SERVER "https://github.com/pan2013e/dreval/blob/main/start_server.sh"
    click DATASET "https://github.com/pan2013e/dreval/blob/main/dataset.py"
    click TEST_UTIL "https://github.com/pan2013e/dreval/blob/main/test.py"

    %% Styles
    classDef core fill:#bbf,stroke:#333,stroke-width:2px;
    classDef support fill:#ffc,stroke:#333,stroke-width:2px;
    classDef external fill:#f96,stroke:#333,stroke-width:2px;
```
