# wenhuchen/time-sensitive-qa architecture

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

- Interactive diagram: https://gitdiagram.com/wenhuchen/time-sensitive-qa
- Repository: https://github.com/wenhuchen/time-sensitive-qa

## Overview

- BigBird – an extractive QA baseline (using a modified transformer model)
- Fusion-in-Decoder (FiD) – a generative QA baseline

##### Major Components
a. Dataset Layer:
- Top-level “dataset” directory that contains raw data files (annotated and synthesized training/dev/test JSON and YAML files).
- That the datasets are used both in training and evaluation, and some files are compressed (gzip) or annotated.
b. BigBird Module:
- “BigBird” directory containing its own configuration file (config.yaml), dataset subfolder with YAML files, and main.py which handles training/evaluation via command line arguments (with hydra/omegaconf).
c. FiD Module:
- “FiD” directory, which similarly contains its own configuration (config.yaml), dataset data, main.py for running training/evaluation, and model.py that likely encapsulates model instantiation for fusion-in-decoder.
d. Auxiliary/Supporting Components:
- “utils.py” file if it has helper functions.
- External notebook “Process.ipynb” that might be used for analysis or prototyping.
- External dependencies (e.g., the Open-Domain Retriever linked to DrQA, as mentioned in the README) and the specifications for different transformer libraries and PyTorch versions.

##### Relationships and Data Flow
a. Dataset Preparation:
b. Configuration and Initialization:
- Both QA modules read their own configuration (YAML/omegaconf-based) as well as command-line parameters (where hydra is used). Represent configuration as an input flowing into the QA modules.
c. Model Training and Evaluation:
- That each of these scripts accepts parameters like model checkpoint selection (from NQ or TriviaQA) and dataset selection (“hard”, “easy”, human_ versions).
d. External Dependencies:
- External libraries (Transformers, PyTorch, hydra, omegaconf) as part of the underlying infrastructure supporting both modules.

##### Architectural Patterns
- Separation of Concerns: The design clearly separates data management (dataset folder) from model-specific implementations (BigBird and FiD directories).
- Modularity: Each model baseline is self-contained with independent configuration and dataset subdirectories.
- Dependency Injection: Use of hydra and omegaconf indicates that configurations are injected at runtime which makes the system flexible.
- Environment Isolation: Notice that separate Conda environments are expected for BigBird and FiD, which can be highlighted by drawing distinct environment boundaries around these components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Dataset Layer
    DS["Dataset (raw JSON/YAML files)"]:::data

    %% BigBird Module Subgraph
    subgraph "BigBird Module"
        BB_Config["BigBird Config (config.yaml)"]:::config
        BB_Data["BigBird Dataset (YAML files)"]:::data
        BB_Main["BigBird Engine (main.py)"]:::engine
    end

    %% FiD Module Subgraph
    subgraph "FiD Module"
        FiD_Config["FiD Config (config.yaml)"]:::config
        FiD_Data["FiD Dataset (data files)"]:::data
        FiD_Main["FiD Engine (main.py)"]:::engine
        FiD_Model["FiD Model (model.py)"]:::model
    end

    %% Auxiliary and Analysis Components
    AUX["Auxiliary Utilities (utils.py)"]:::aux
    NB["Analysis Notebook (Process.ipynb)"]:::aux

    %% External Dependencies
    EXT["External Dependencies (Transformers, PyTorch, hydra, omegaconf, Retriever)"]:::external

    %% Command-line Interface / Config Injection (common for both modules)
    CLI["Command-Line Interface (CLI & Config Injection)"]:::cli

    %% Model Checkpoints Source (e.g., NQ/TriviaQA)
    CK["Model Checkpoints (NQ/TriviaQA)"]:::checkpoint

    %% Data Flow
    DS -->|"feeds"| BB_Data
    DS -->|"feeds"| FiD_Data

    %% Config Flow
    BB_Config -->|"injects"| BB_Main
    FiD_Config -->|"injects"| FiD_Main

    %% CLI Flow
    CLI -->|"triggers"| BB_Main
    CLI -->|"triggers"| FiD_Main

    %% Model Checkpoints Flow
    CK -->|"initializes"| BB_Main
    CK -->|"initializes"| FiD_Main

    %% External Dependencies supporting modules
    EXT --- BB_Main
    EXT --- FiD_Main
    EXT --- AUX

    %% Auxiliary connections (for helper functions and analysis)
    AUX --- NB

    %% Styles
    classDef data fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef config fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef engine fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef model fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#7D3C98,stroke-width:2px;
    classDef cli fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef checkpoint fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef aux fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;

    %% Click Events
    click DS "https://github.com/wenhuchen/time-sensitive-qa/tree/main/dataset/"
    click BB_Config "https://github.com/wenhuchen/time-sensitive-qa/blob/main/BigBird/config.yaml"
    click BB_Main "https://github.com/wenhuchen/time-sensitive-qa/blob/main/BigBird/main.py"
    click FiD_Config "https://github.com/wenhuchen/time-sensitive-qa/blob/main/FiD/config.yaml"
    click FiD_Main "https://github.com/wenhuchen/time-sensitive-qa/blob/main/FiD/main.py"
    click FiD_Model "https://github.com/wenhuchen/time-sensitive-qa/blob/main/FiD/model.py"
    click AUX "https://github.com/wenhuchen/time-sensitive-qa/blob/main/utils.py"
    click NB "https://github.com/wenhuchen/time-sensitive-qa/blob/main/Process.ipynb"
```
