# allenai/open-instruct architecture

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

- Interactive diagram: https://gitdiagram.com/allenai/open-instruct
- Repository: https://github.com/allenai/open-instruct

## Overview

Main Components to Include:

##### Training Pipeline Components
- SFT (Supervised Fine-Tuning)
- DPO (Direct Preference Optimization)
- RLVR (Reinforcement Learning with Verifiable Rewards)
- Model Architecture Adapters (LoRA, QLoRA)

##### Data Processing Layer
- Dataset Processors
- Data Transformations
- Contamination Check System
- Mix Data Generation

##### Evaluation System
- Multiple Benchmark Evaluations (MATH, BBH, MMLU, etc.)
- Human Evaluation Interface
- Metrics Collection

##### Infrastructure Layer
- Distributed Training Support (DeepSpeed)
- GPU Resource Management
- Docker Containerization
- vLLM Integration

- [Data Layer] → [Training Layer] → [Evaluation Layer]
- ↑
- [Infrastructure Layer]

##### Detailed Component Breakdown

Data Layer:
- [Dataset Processor] → [Transformation Pipeline] → [Mix Data Generator]
- ↓
- [Contamination Checker]

Training Layer:
- [Base Models] → [SFT Pipeline] → [DPO Pipeline] → [RLVR Pipeline]
- ↑               ↑               ↑
- [Parameter-Efficient Training Adapters (LoRA/QLoRA)]

Evaluation Layer:
- [Benchmark Suite] → [Metrics Collector]
- [Human Eval Interface]
- [Safety Evaluations]

##### Key Interactions to Highlight
- Data flow from processors to training pipelines
- Feedback loops from evaluation to training
- Configuration dependencies

##### Implementation Details
- Version compatibility notes
- Distributed training paths

##### Configuration Management
- How config files influence different components
- Where environment variables and Docker settings apply
- Points of customization

This system design should emphasize the project's focus on open-source instruction tuning and post-training of language models, while showing how different components work together to achieve the project's goals.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph DL[Data Layer]
        DP[Dataset Processor]
        DT[Data Transformations]
        CC[Contamination Check]
        MDG[Mix Data Generator]
        DP --> DT
        DT --> MDG
        DP --> CC
    end

    subgraph TL[Training Layer]
        BM[Base Models]
        SFT[SFT Pipeline]
        DPO[DPO Pipeline]
        RLVR[RLVR Pipeline]
        PETA[Parameter-Efficient Training Adapters]
        
        BM --> SFT
        SFT --> DPO
        DPO --> RLVR
        PETA --> SFT
        PETA --> DPO
        PETA --> RLVR
    end

    subgraph EL[Evaluation Layer]
        BS[Benchmark Suite]
        HEI[Human Eval Interface]
        SE[Safety Evaluations]
        MC[Metrics Collector]
        MMLU[MMLU Evaluation]
        TQA[TruthfulQA]
        MATH[Math Evaluation]
        
        BS --> MC
        HEI --> MC
        SE --> MC
        MMLU --> BS
        TQA --> BS
        MATH --> BS
    end

    subgraph IL[Infrastructure Layer]
        DS[DeepSpeed]
        DC[Docker Container]
        VLLM[vLLM Integration]
        CM[Config Management]
    end

    DL --> TL
    TL --> EL
    IL --> TL

    %% Styling
    classDef data fill:#a8d1f0
    classDef training fill:#90EE90
    classDef eval fill:#FFE5B4
    classDef infra fill:#E6E6E6

    class DP,DT,CC,MDG data
    class BM,SFT,DPO,RLVR,PETA training
    class BS,HEI,SE,MC,MMLU,TQA,MATH eval
    class DS,DC,VLLM,CM infra

    %% Click Events
    click DP "https://github.com/allenai/open-instruct/blob/main/open_instruct/dataset_processor.py"
    click DT "https://github.com/allenai/open-instruct/blob/main/open_instruct/dataset_transformation.py"
    click CC "https://github.com/allenai/open-instruct/tree/main/decontamination"
    click MDG "https://github.com/allenai/open-instruct/blob/main/open_instruct/mix_data.py"
    click SFT "https://github.com/allenai/open-instruct/tree/main/configs/train_configs/sft"
    click DPO "https://github.com/allenai/open-instruct/tree/main/configs/train_configs/dpo"
    click RLVR "https://github.com/allenai/open-instruct/tree/main/scripts/train/rlvr"
    click PETA "https://github.com/allenai/open-instruct/tree/main/open_instruct/olmo_adapter"
    click BS "https://github.com/allenai/open-instruct/tree/main/eval"
    click HEI "https://github.com/allenai/open-instruct/tree/main/human_eval"
    click MMLU "https://github.com/allenai/open-instruct/tree/main/eval/mmlu"
    click TQA "https://github.com/allenai/open-instruct/tree/main/eval/truthfulqa"
    click MATH "https://github.com/allenai/open-instruct/tree/main/eval/MATH"
    click DS "https://github.com/allenai/open-instruct/tree/main/configs/ds_configs"
    click DC "https://github.com/allenai/open-instruct/tree/main/Dockerfile"
    click VLLM "https://github.com/allenai/open-instruct/blob/main/open_instruct/vllm_utils.py"
    click CM "https://github.com/allenai/open-instruct/tree/main/configs/train_configs"
```
