# beccabai/multi-agent-data-selection architecture

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

- Interactive diagram: https://gitdiagram.com/beccabai/multi-agent-data-selection
- Repository: https://github.com/beccabai/multi-agent-data-selection

## Overview

##### Project type and purpose
- This is a research‐oriented machine‐learning codebase for “Multi-Agent Collaborative Data Selection for Efficient LLM Pretraining.”
- It implements a multi-agent framework that cooperatively selects which data samples to feed into an LLM pretraining pipeline, with modules for topic classification, selection policies, and checkpointed model training.

##### (minimal) file structure
- At present the repo only contains a README and illustration, but from the README we know there will be code for:
- Model checkpoints and trainers
- BERT Topic Model
- Data labeling and dataset management
- Baseline implementations and collaboration logic

##### Core components
a. Data Storage Layer
- SlimPajama raw data (670 B tokens)
- Labeled subsets (e.g., with topic labels from BERT Topic Classifier)
- Checkpoint store (Hugging Face or S3)
b. Multi-Agent Selection Framework
- Agent instances (each with a selection policy module)
- Communication or coordination bus (e.g., Redis, gRPC or simple in-process message queue)
- Aggregator/Controller that collects agent proposals and resolves conflicts
c. Pretraining Engine
- LLM training loop (e.g., PyTorch/DeepSpeed/Accelerate)
- Data loader that ingests agent-filtered samples
- Evaluation & logging (TensorBoard, MLflow, or WandB)
d. External Services
- Hugging Face Hub for model/dataset hosting
- Monitoring dashboards

##### Relationships and data flow
1. Raw Data → BERT Topic Classifier → Topic-labeled corpus
2. Labeled data shards → Multi-Agent Selection Framework
3. Each Agent reads shards and proposes “next batch” based on its policy
4. Coordinator aggregates proposals → final batch
5. Pretraining Engine consumes final batch → updates model parameters
6. Checkpoints pushed to remote store; evaluation metrics reported

##### Architectural patterns and design principles
- Modular pipeline: separate labeling, selection, training
- Asynchronous multi-agent collaboration: agents operate in parallel and synchronize through a coordinator
- Data-centric flow: storage, labeling, selection → training → checkpointing
- Scalability via distribution (agents can run on different machines)

##### Relevant technologies/frameworks
- Data processing: Hugging Face Datasets, pandas
- Topic modeling: Hugging Face Transformers (BERT)
- Distributed training: PyTorch + DeepSpeed / Accelerate
- IPC/message bus: Redis or gRPC
- Monitoring: WandB / TensorBoard
- Storage: AWS S3 or Hugging Face Hub

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Data Storage Layer"
        RawData["SlimPajama Raw Data (670B tokens)"]:::dataStore
        LabeledData["Topic-labeled Corpus"]:::dataStore
        CheckpointStore["Checkpoint Store\n(HuggingFace/S3)"]:::dataStore
    end

    subgraph "Multi-Agent Selection Framework"
        Classifier["BERT Topic Classifier"]:::process
        AgentsPool(("Agents Pool")):::agent
        subgraph "Agents"
            Agent1(("Agent")):::agent
            Agent2(("Agent")):::agent
            AgentN(("Agent")):::agent
        end
        Bus["Communication Bus\n(Redis/gRPC)"]:::process
        Coordinator["Aggregator / Coordinator"]:::process
    end

    subgraph "Pretraining Engine"
        DataLoader["Data Loader"]:::process
        Trainer["LLM Training Loop\n(PyTorch/DeepSpeed)"]:::process
        EvalLogging["Evaluation & Logging\n(TensorBoard/WandB)"]:::process
    end

    subgraph "External Services"
        HFHub["Hugging Face Hub"]:::service
        Monitoring["Monitoring Dashboards"]:::service
    end

    RawData -->|"raw data"| Classifier
    Classifier -->|"labeled shards"| LabeledData
    LabeledData -->|"load shards"| AgentsPool
    AgentsPool --> Agent1
    AgentsPool --> Agent2
    AgentsPool --> AgentN
    Agent1 -->|"proposal"| Bus
    Agent2 -->|"proposal"| Bus
    AgentN -->|"proposal"| Bus
    Bus --> Coordinator
    Coordinator -->|"final batch"| DataLoader
    DataLoader --> Trainer
    Trainer --> EvalLogging
    Trainer --> CheckpointStore
    CheckpointStore --> HFHub
    EvalLogging --> Monitoring

    classDef dataStore fill:#ADD8E6,stroke:#000,color:#000
    classDef agent fill:#90EE90,stroke:#000,color:#000
    classDef process fill:#FFA500,stroke:#000,color:#000
    classDef service fill:#DDA0DD,stroke:#000,color:#000
```
