# hkuds/llmrec architecture

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

- Interactive diagram: https://gitdiagram.com/hkuds/llmrec
- Repository: https://github.com/hkuds/llmrec

## Overview

##### Data Augmentation Module
- This includes the LLM-based augmentation scripts. Note the subdirectory “LLM_augmentation_construct_prompt” (with files like gpt_i_attribute_generate_aug.py, gpt_ui_aug.py, and gpt_user_profiling.py) which is responsible for generating prompts and completions to augment item attributes, user profiles, and implicit feedback.

##### Recommendation Model Training Module
- The training stage is executed through “main.py” at the repository root (and similar main.py files in subfolders like LATTICE/codes and MMSSL). This stage takes the augmented data as input and applies recommendation models based on graph augmentation.
- Components include the baseline recommenders derived or modified from LATTICE and MMSSL. Note that each of these baseline directories has its own structure (e.g., “codes” for LATTICE and “utility” for MMSSL) alongside configuration files (like config.yml) and candidate preparation scripts.

##### Core Utility Components
- “Models.py” files in several directories; these hold key model definitions which are central to performing recommendations.

##### External Services and Dependencies
- External libraries (PyTorch, CLIP-ViT, Sentence-BERT) as external dependencies, which provide capability for deep learning operations and multi-modal data processing.
- The README emphasizes links to the paper, demo pages, and dataset sources – you might want to note external data sources and research references.

##### Data Flow & Component Interactions
- The flow begins with raw multi-modal data ingestion and candidate generation (using pre-generated candidate indices) then proceeds into two stages:
– Stage 1 (Data Augmentation): Here, the LLM-based augmentation scripts operate on user and item data to produce enriched feedback and profiles.
– Stage 2 (Recommender Training): The models (from LATTICE, MMSSL and others) train on the augmented data with potential candidate preparation and evaluation via metrics modules.

##### Architectural Patterns and Design Principles
- Modular Design: The file structure is segmented into different directories for augmentation, baseline implementations, and utilities. Emphasize the modularity and separation of concerns.
- Reusability: The common utility functions and model definitions are reused across multiple modules, indicating a design that emphasizes code reuse.
- Pipeline Flow: The design clearly follows a two-stage data processing pipeline (data enrichment followed by model training and candidate selection).

– From raw multi-modal data (with sources like Netflix dataset) entering the augmentation module.
– From augmentation scripts to the enriched dataset.
– From the enriched dataset feeding into the candidate generation and recommendation model training.
– Application modules (e.g., augmentation scripts, model training scripts) versus utility libraries (e.g., logging, parsing).
– In-house developed components versus external services or libraries.
- Files or folders where appropriate (for example, “LLM_augmentation_construct_prompt”, “LATTICE”, “MMSSL”, “utility”, and “main.py” at multiple locations) to emphasize their roles.
- Incorporate brief notes on the purpose of each module as identified above (e.g., “LLM Augmentation Module: Enhances user/item features using LLM prompts”, “Recommender Training Module: Implements baseline models and leverages augmented data”, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Data Flow
    RawData["Raw Multi-Modal Data"]:::module
    DataFolder["Data (Datasets)"]:::module
    EnrichedData["Enriched Data"]:::module
    FinalOutput["Final Recommendation Output"]:::module

    %% Data Augmentation Module
    subgraph "Data Augmentation Module"
        LLMAug["LLM Augmentation (LLM_augmentation_construct_prompt)"]:::module
    end

    %% Recommendation Training Module
    subgraph "Recommendation Training Module"
        RootMain["Training Entry (main.py)"]:::module
        subgraph "LATTICE Variant"
            LATTICE_Main["LATTICE Training (LATTICE/codes/main.py)"]:::module
            LATTICE_Models["LATTICE Models (LATTICE/codes/Models.py)"]:::module
        end
        subgraph "MMSSL Variant"
            MMSSL_Main["MMSSL Training (MMSSL/main.py)"]:::module
            MMSSL_Models["MMSSL Models (MMSSL/Models.py)"]:::module
        end
    end

    %% Core Utility Components
    subgraph "Core Utility Components"
        Utility_Root["Root Utility (utility)"]:::utility
        LATTICE_Utility["LATTICE Utility (LATTICE/codes/utility)"]:::utility
        MMSSL_Utility["MMSSL Utility (MMSSL/utility)"]:::utility
    end

    %% External Dependencies
    External["External Dependencies (PyTorch,CLIP-ViT,Sentence-BERT)"]:::external

    %% Connections between nodes
    RawData --> DataFolder
    DataFolder --> LLMAug
    LLMAug --> EnrichedData
    EnrichedData --> RootMain

    RootMain --> LATTICE_Main
    LATTICE_Main --> LATTICE_Models
    RootMain --> MMSSL_Main
    MMSSL_Main --> MMSSL_Models
    LATTICE_Models --> FinalOutput
    MMSSL_Models --> FinalOutput

    %% Utility Support (dashed lines)
    Utility_Root --- LLMAug
    Utility_Root --- RootMain
    LATTICE_Utility --- LATTICE_Main
    MMSSL_Utility --- MMSSL_Main

    %% External Dependencies support (dashed lines)
    External --- LLMAug
    External --- RootMain

    %% Click Events for Component Mapping
    click LLMAug "https://github.com/hkuds/llmrec/tree/main/LLM_augmentation_construct_prompt"
    click RootMain "https://github.com/hkuds/llmrec/blob/main/main.py"
    click LATTICE_Main "https://github.com/hkuds/llmrec/blob/main/LATTICE/codes/main.py"
    click LATTICE_Models "https://github.com/hkuds/llmrec/blob/main/LATTICE/codes/Models.py"
    click MMSSL_Main "https://github.com/hkuds/llmrec/blob/main/MMSSL/main.py"
    click MMSSL_Models "https://github.com/hkuds/llmrec/blob/main/MMSSL/Models.py"
    click Utility_Root "https://github.com/hkuds/llmrec/tree/main/utility"
    click LATTICE_Utility "https://github.com/hkuds/llmrec/tree/main/LATTICE/codes/utility"
    click MMSSL_Utility "https://github.com/hkuds/llmrec/tree/main/MMSSL/utility"

    %% Styles
    classDef module fill:#ffefc2,stroke:#333,stroke-width:2px;
    classDef utility fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#333,stroke-width:2px;
```
