How ljy0ustc/llara works
Main Components
a. External Systems & Artifacts
– Raw Datasets (MovieLens, Steam, LastFM)
– Pre-trained LLaMA2-7B model (from Hugging Face)
b. Data Layer
– data_interface.py (abstract loader interface)
– [lastfm_data.py, movielens_data.py, steam_data.py] (dataset-specific loaders)
c. Prompt Layer
– prompt/*.txt (template prompts for artist, movie, game recommendations)
d. Model Layer
– SASRecModules_ori.py (core sequential modeling blocks)
– model_interface.py (defines train/eval API for rec model)
– mlp_projector.py (final rating/ranking head)
– optims.py (optimizer and scheduler definitions)
e. Orchestration & Execution
– main.py (entry point for training and evaluation pipelines)
– recommender/A_SASRec_final_bce_llm.py (integration of SASRec + LLaRA prompts + LLaMA calls)
– Shell scripts (train_*.sh, test_*.sh) to launch experiments per dataset
f. Artifacts
– rec_model/*.pt (trained checkpoint files)
– logs, metrics outputs
Relationships & Data Flows
– Raw Datasets → Data Layer: data loaders read raw files, preprocess into sequences.
– Data Layer → Model Layer: batched sequences fed into SASRecModules (embedding → self-attention → MLP projector).
– Model Layer ↔ LLM Layer: recommender script uses model outputs to construct prompt, sends to LLaMA2-7B, receives ranking logits or next-item suggestions.
– Model + LLM outputs → Loss Computation (within optims) → Backprop → Parameter Updates.
– Trained Model → rec_model checkpoint.
– Evaluation Pipeline: same flows but in inference mode, metrics computed (ValidRatio, HitRatio@1).
Architectural Patterns & Design Principles
– Modular layering: separate data, model, prompt, orchestration.
– Interface abstraction: data_interface.py and model_interface.py enable plugging in new datasets or model variants.
– Shell-based experiment orchestration for reproducibility.
– Reuse of pre-trained LLM as a service via prompt files.