# allenai/chime architecture

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

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

## Overview

Key Components to Include:

##### Core Processing Pipeline
- Main component should be represented by a large container labeled "CHIME Pipeline"

##### Major System Components
a. Data Input Layer
- Input from Cochrane Library (raw_source_data.csv)
- Claims generation process

b. Hierarchy Generation Module
- To Claude-2 LLM API
- Hierarchy construction process
- Output to raw_generated_hierarchy.csv

c. Fine-tuning Components
- Parent-child relation prediction
- Sibling coherence prediction
- Claim-category relevance prediction
- Connection to FlanT5 models

d. LLM Prediction Layer
- Separate section for LLM prediction tasks
- Integration with fine-tuned models

##### External Dependencies
- OpenAI API integration
- Claude API integration
- SciSpacy model connection

- Input Data → Hierarchy Generation → Fine-tuning/Prediction → Output

##### Technical Details
- Three main datasets:
- chime-parent-child-relation
- chime-sibling-coherence
- chime-claim-category
- Fine-tuned model: flan-t5-large-claim-category

##### Infrastructure Layer
- Conda environment container
- Required environment variables
- Model storage/access points

Remember to include version information and note that the system processes 472 out of 474 hierarchies successfully, which might be relevant for error handling visualization.

This architecture should be represented in a way that emphasizes CHIME's primary goal of supporting literature review through LLM-assisted hierarchical organization, while making the technical implementation clear to other engineers who might need to work with or maintain the system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        direction TB
        A[Process]:::process --> B[(Database)]:::database
        C[["API/Service"]]:::api --> D{{"LLM Model"}}:::llm
        E[["External Integration"]]:::external
    end

    subgraph "Data Input Layer"
        direction TB
        RawData[(Raw Source Data)]:::database
        GenHierarchy[(Generated Hierarchy)]:::database
        DataSplit[(Data Split Config)]:::database
    end

    subgraph "Core Processing Pipeline"
        direction TB
        MainOrch[Main Orchestrator]:::process
        HierarchyParser[Hierarchy Parser]:::process
        Analysis[Analysis Component]:::process
    end

    subgraph "LLM Integration"
        direction TB
        LLMApi[LLM API Handler]:::api
        PromptLib[Prompt Library]:::process
        Utils[Utility Functions]:::process
    end

    subgraph "External Services"
        direction TB
        Claude[["Claude-2 API"]]:::external
        OpenAI[["OpenAI API"]]:::external
        SciSpacy[["SciSpacy Model"]]:::external
    end

    subgraph "Fine-tuning Components"
        direction TB
        Task2Fine[Task 2 Fine-tuning]:::process
        Task3Fine[Task 3 Fine-tuning]:::process
    end

    subgraph "Prediction Layer"
        direction TB
        Task2Pred[Task 2 Prediction]:::process
        Task3Pred[Task 3 Prediction]:::process
        FlanT5{{"FlanT5 Model"}}:::llm
    end

    RawData --> MainOrch
    MainOrch --> HierarchyParser
    HierarchyParser --> Analysis
    MainOrch --> GenHierarchy
    DataSplit --> Task2Fine
    DataSplit --> Task3Fine

    LLMApi --> Claude
    LLMApi --> OpenAI
    MainOrch --> LLMApi
    PromptLib --> LLMApi
    Utils --> MainOrch

    Task2Fine --> FlanT5
    Task3Fine --> FlanT5
    FlanT5 --> Task2Pred
    FlanT5 --> Task3Pred

    classDef process fill:#2374ab
    classDef database fill:#417b5a
    classDef api fill:#9b6b43
    classDef llm fill:#7d387d
    classDef external fill:#555555

    click MainOrch "https://github.com/allenai/chime/blob/main/chime/src/hierarchical_category_construction.py"
    click HierarchyParser "https://github.com/allenai/chime/blob/main/chime/src/parse_hierachy.py"
    click Analysis "https://github.com/allenai/chime/blob/main/chime/src/hierachy_analysis.py"
    click RawData "https://github.com/allenai/chime/blob/main/resources/raw_source_data.csv"
    click GenHierarchy "https://github.com/allenai/chime/blob/main/resources/raw_generated_hierarchy.csv"
    click DataSplit "https://github.com/allenai/chime/blob/main/resources/data_split.csv"
    click Task2Fine "https://github.com/allenai/chime/blob/main/chime/src/flanT5/finetune_task2.py"
    click Task3Fine "https://github.com/allenai/chime/blob/main/chime/src/flanT5/finetune_task3.py"
    click Task2Pred "https://github.com/allenai/chime/blob/main/chime/src/llm_prediction/LLM_prediction_task2.py"
    click Task3Pred "https://github.com/allenai/chime/blob/main/chime/src/llm_prediction/LLM_prediction_task3.py"
    click LLMApi "https://github.com/allenai/chime/blob/main/chime/src/lm_api.py"
    click PromptLib "https://github.com/allenai/chime/blob/main/chime/src/prompt_library.py"
    click Utils "https://github.com/allenai/chime/blob/main/chime/src/utils.py"
```
