How mohamedaminebentayeb/llmrec works
Project Type and Purpose
• This is a research‐oriented recommendation system pipeline (“LLMRec”) that augments a user–item interaction graph using Large Language Models (LLMs) and then trains a GNN‐style recommender on the augmented data.
• Stage 1: Data augmentation via three LLM‐powered scripts.
• Stage 2: Graph‐based recommender training and evaluation.
File‐Structure Analysis
• Top‐level:
• LLM_augmentation_construct_prompt/ – three augmentation scripts:
– gpt_ui_aug.py (u–i edge augmentation)
– gpt_user_profiling.py (user node profiling)
– gpt_i_attribute_generate_aug.py (item attribute augmentation)
• main.py – orchestrates dataset‐loading, model instantiation & training.
• Models.py – defines GNN / recommendation architectures.
• utility/ – helper modules (data loaders, metrics, logging, command‐line parser).
• requirements.txt – lists PyTorch, OpenAI, CLIP, S‐BERT, etc.
README Insights
• Clearly describes the three augmentation strategies (edges, user nodes, item nodes).
• Specifies two main stages and supported datasets (netflix, movielens).
• Mentions encoders: CLIP‐ViT for images, Sentence‐BERT for text.
• Indicates use of OpenAI GPT‐3.5 & text‐embedding‐ada‐002 APIs.
a. Data Sources (leftmost)
• Raw interaction data (CF training data, basic u–i interactions)
• Original multi‐modal content: item_attribute.csv, images folder
b. LLM Augmentation Layer
1. “u–i Edge Augmentor” (gpt_ui_aug.py) → produces augmented edges
2. “User Profiling Augmentor” (gpt_user_profiling.py) → user metadata
3. “Item Attribute Augmentor” (gpt_i_attribute_generate_aug.py) → item metadata
c. Data Storage / Merge
• “Augmented Dataset Store” merges raw + augmented edges & node attributes
• Represented as CSVs / pickled tensors under data/{dataset}/
d. Recommender Training Layer
• main.py invokes:
• utility/parser.py (CLI args)
• utility/load_data.py → constructs graph structure (u–i adjacency + node features)
• Models.py → GNN layers (e.g., GraphSAGE, GAT) or matrix factorization modules
• Encoders: CLIP‐ViT & Sentence‐BERT (called once to precompute features or on‐the‐fly)
• Loss & pruning logic (prune_loss_drop_rate)
• Training loop with metrics.py and logging.py
e. Evaluation & Output
• Batch testing (utility/batch_test.py) → computes recommendation metrics (HR@K, NDCG)
• Results logged / visualized
Relationships & Data Flows
• Raw data → LLM Augmentor scripts → augmented outputs
• Augmented + raw data → Data Storage → Recommender Training
• Recommender subcomponents communicate via function calls / data loaders
• Training → Evaluation → Logs / Metrics
Architectural Patterns & Technologies
• Pipeline pattern: clear two‐stage pipeline (augmentation → training)
• Modularization: augmentation scripts, utility modules, model definitions all decoupled
• External service integration: OpenAI API calls encapsulated in scripts
• Graph‐based learning pattern: treats recommendation as graph problem
• Multi‐modal encoding: CLIP & S‐BERT for node features
Essential Elements
• Component labels (script / module / service names)
• Clear grouping of Stage 1 vs. Stage 2