# tejanshsachdeva/biasness-mitigation architecture

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

- Interactive diagram: https://gitdiagram.com/tejanshsachdeva/biasness-mitigation
- Repository: https://github.com/tejanshsachdeva/biasness-mitigation

## Overview

##### Project type and purpose
- This is a research-oriented ML pipeline for “Bias Mitigation & Evaluation” in LLMs. It generates synthetic data, fine-tunes models with LoRA, and evaluates bias via custom metrics.

##### File structure
- Top-level scripts map to pipeline stages:
- Data generation: `custom_dataset_templates.py`, `unbiased_dataset.json`
- Fine-tuning: `gpt3.py`, `train_llama3b.py`, plus helper `training_model.py`
- Inference/testing: `running_finetuned_model.py`, `zero_shot_testing.py`, `ics_testing.py`, `Metrics_Eval.ipynb`
- No “frontend” or web-service layers—it's a set of standalone Python modules and a Jupyter notebook.
- Configuration and model checkpointing are handled inside `training_model.py`.

##### Extra insights from the README
- The pipeline is reproducible, uses LoRA on GPT-2 or Llama 3B, includes custom metrics (DI, ICS, TCS, IAT, ZSC), and plotting utilities.
- It’s under active refactoring—expect modular interfaces.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Data Generation Module
    subgraph "Data Generation Module"
        direction TB
        DG1["custom_dataset_templates.py"]:::data
        DG2[(unbiased_dataset.json)]:::artifact
        DG1 --> DG2
    end

    %% Fine-Tuning Module
    subgraph "Fine-Tuning Module"
        direction TB
        FT1["gpt3.py"]:::train
        FT2["train_llama3b.py"]:::train
        FT3["training_model.py"]:::train
        FT1 --> FT3
        FT2 --> FT3
        FT3 --> FT_CK[(LoRA Checkpoints)]:::artifact
    end

    %% Inference / Deployment Module
    subgraph "Inference / Deployment Module"
        direction TB
        INF1["running_finetuned_model.py"]:::infer
        FT_CK --> INF1
        INF1 --> INF_OUT[(Raw Model Outputs)]:::artifact
    end

    %% Evaluation & Visualization Module
    subgraph "Evaluation & Visualization Module"
        direction TB
        EV1["zero_shot_testing.py"]:::eval
        EV2["ics_testing.py"]:::eval
        EV3["Metrics_Eval.ipynb"]:::eval
        INF_OUT --> EV1
        INF_OUT --> EV2
        INF_OUT --> EV3
    end

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        PY["PyTorch"]:::external
        HF["Transformers"]:::external
        LO["LoRA Adapter"]:::external
        MP["Matplotlib/Seaborn"]:::external
    end

    %% Dependency Links
    PY -.-> FT3
    HF -.-> FT3
    LO -.-> FT3
    HF -.-> INF1
    MP -.-> EV1
    MP -.-> EV2
    MP -.-> EV3

    %% Click Events
    click DG1 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/custom_dataset_templates.py"
    click DG2 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/unbiased_dataset.json"
    click FT1 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/gpt3.py"
    click FT2 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/train_llama3b.py"
    click FT3 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/training_model.py"
    click INF1 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/running_finetuned_model.py"
    click EV1 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/zero_shot_testing.py"
    click EV2 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/ics_testing.py"
    click EV3 "https://github.com/tejanshsachdeva/biasness-mitigation/blob/master/Metrics_Eval.ipynb"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef train fill:#90EE90,stroke:#333,stroke-width:1px
    classDef infer fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef eval fill:#FFA500,stroke:#333,stroke-width:1px
    classDef artifact fill:#F5F5DC,stroke:#333,stroke-width:2px
    classDef external fill:#DDDDDD,stroke:#777,stroke-dasharray:5 5
```
