# sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation architecture

> Architecture diagram of the GitHub repository sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation
- Repository: https://github.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation

## Overview

##### Project Type and Purpose
- This is a machine-learning pipeline project, specifically a fine-tuning workflow for IBM Granite LLM to solve the time-dependent heat equation.
- The two Jupyter notebooks partition responsibilities:
- dataset-creation.ipynb generates and formats the Q&A dataset
- llm-fine-tuning.ipynb orchestrates preprocessing, tokenization, PEFT fine-tuning, and evaluation

##### File Structure
- Top-level artifacts:
- README.md (project overview & methodology)
- dataset-creation.ipynb (data-prep module)
- llm-fine-tuning.ipynb (training & evaluation module)
- No separate “src” or “tests”—the notebooks themselves are the orchestration layer.
- External dependencies: Kaggle dataset, Hugging Face transformers & PEFT, cosine-similarity embedding service.

##### Main Components to Model
a. Data Ingestion & Creation
- Source: Kaggle heat-solution dataset
- Notebook: dataset-creation.ipynb
- Output: raw Q&A pairs in train/validation splits

b. Preprocessing Pipeline
- Steps: pad token definition, data collator, tokenization (batch map-reduce)
- Tools: Hugging Face Tokenizers, custom collator functions

c. Fine-Tuning Engine
- Framework: Hugging Face Transformers + PEFT
- Compute: GPU/TPU environment invoked inside llm-fine-tuning.ipynb
- Model: IBM Granite base model → partially fine-tuned

d. Evaluation Module
- Metric: cosine similarity between generated answers & references
- Components: embedding model (external), compute_metrics function

e. Artifacts & Storage
- Intermediate: tokenized datasets, model checkpoints
- Final: fine-tuned LLM model, evaluation reports

##### Relationships & Data Flow
raw dataset → data-creation notebook → processed dataset → preprocessing submodule → tokenized batches → fine-tuning engine → checkpoints → evaluation module → final metrics
- Kaggle dataset download
- Embedding service for cosine similarity
- (Optional) Hugging Face Hub for model storage

##### Architectural Patterns & Design Principles
- Pipeline pattern: sequential transformation stages
- Modular separation: data-prep vs. training vs. evaluation
- PEFT pattern: freezes most model parameters, tunes a small subset
- Notebook orchestration: each Jupyter file encapsulates one or more pipeline stages

##### Technology Stack Call-outs
- Python 3.x, Jupyter Notebooks
- Hugging Face Transformers, PEFT library
- Tokenizers library, custom DataCollator
- Cosine-similarity embedder (could be sentence-transformers)
- Kaggle dataset API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    Kaggle[/Kaggle API/]:::external
    Embedding[/Embedding Service/]:::external
    HFHub[/Hugging Face Hub/]:::external

    %% Data Stores
    RawData[(Raw Q&A Dataset)]:::dataStore
    ProcessedData[(Processed Q&A Dataset)]:::dataStore

    %% Project Overview
    ProjectOverview["README.md<br/>(Project Overview & Methodology)"]:::external

    %% Notebooks Subgraphs
    subgraph "dataset-creation.ipynb Orchestration"
        direction TB
        DataNotebook["Data Ingestion & Creation"]:::compute
    end

    subgraph "llm-fine-tuning.ipynb Orchestration"
        direction TB
        Preprocessing["Preprocessing<br/>(tokenization & collator)"]:::compute
        TokenizedData[(Tokenized Dataset)]:::dataStore
        FineTuning["Fine-Tuning Engine<br/>(PEFT-based LLM)"]:::compute
        Checkpoints[(Model Checkpoints)]:::artifact
        Evaluation["Evaluation Module<br/>(cosine-similarity metrics)"]:::compute
        Metrics[(Evaluation Reports)]:::artifact
    end

    %% Data Flow
    Kaggle -->|"download raw data"| RawData
    RawData --> DataNotebook
    DataNotebook -->|"generate splits"| ProcessedData
    ProcessedData --> Preprocessing
    Preprocessing --> TokenizedData
    TokenizedData --> FineTuning
    FineTuning --> Checkpoints
    Checkpoints --> HFHub
    Checkpoints --> Evaluation
    Evaluation --> Metrics
    Embedding -->|provides embeddings| Evaluation

    %% Click Events
    click DataNotebook "https://github.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation/blob/main/dataset-creation.ipynb"
    click Preprocessing "https://github.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation/blob/main/llm-fine-tuning.ipynb"
    click FineTuning "https://github.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation/blob/main/llm-fine-tuning.ipynb"
    click Evaluation "https://github.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation/blob/main/llm-fine-tuning.ipynb"
    click ProjectOverview "https://github.com/sumedh220122/fine-tunining-ibm-granite-to-interpret-heat-equation/blob/main/README.md"

    %% Styles
    classDef dataStore fill:#add8e6,stroke:#000;
    classDef compute fill:#90ee90,stroke:#000;
    classDef artifact fill:#ffa500,stroke:#000;
    classDef external fill:#d3d3d3,stroke:#000,stroke-dasharray: 5 5;
```
