This repository contains the scripts used to build the two-stage recommendation pipeline:
- preprocess item metadata and reviews,
- generate CLIP features and top-k concepts,
- train LightGCN / feature-aware LGCN,
- train the second-stage TransAct model on top of the learned item embeddings.
The codebase is organized around the actual scripts in this folder, not around a package or library layout.
-
prep_items_meta.py
Builds item metadata features from Amazon meta JSONL and writesitems_features.parquet,item_id_map.parquet, and optionallycobuy_edges.parquet. -
prep_reviews_revised.py
Converts the reviews JSONL intointeractions.parquetandreviews_agg.parquet. -
media_downloader.py
Downloads product images from the item metadata and writes the image manifest files. -
clip_feature_gen.py
Generates CLIP embeddings, concept bank files, top-k concept parquet, and ANN-related artifacts. -
clip_feature_gen_paths.py
Variant of the CLIP generator with the same pipeline but path overrides tuned for the handmade dataset layout. -
Untitled-1.py
Main LightGCN / feature-aware LGCN training script. It consumes the CLIP artifacts whenuse_clip_denseis enabled. -
tomp.pyandtomp_baseline_30m.py
TransAct second-stage scripts. They load the pretrained item embeddings from stage 1 and feed them into the transformer model.
The pipeline is roughly:
- build item features with
prep_items_meta.py - build review interactions with
prep_reviews_revised.py - download images with
media_downloader.py - generate CLIP embeddings and top-k concepts with
clip_feature_gen.pyorclip_feature_gen_paths.py - train LightGCN / feature-aware LGCN with
Untitled-1.py - train the second-stage TransAct model with
tomp.py
Typical output locations are:
amazon_out/items_meta/items_features.parquetamazon_out/items_meta/item_id_map.parquetamazon_out/reviews_revised_proc/interactions.parquetamazon_out/reviews_revised_proc/reviews_agg.parquetamazon_handmade_out/downloaded_media_all/images_per_asin.jsonlamazon_handmade_out/downloaded_media_all/downloads_manifest.parquetamazon_handmade_out/clip/clip_item_emb.npyamazon_handmade_out/clip/topk_tags.parquetitem_tower/*.ptfor the trained LightGCN exports
The CLIP generator writes the artifacts consumed by the stage-1 LightGCN script:
- item embeddings:
clip_item_emb.npy - top-k concept table:
topk_tags.parquet - concept embedding bank:
concept_text_emb.npy - concept vocabulary:
concept_bank.json
The exact output paths depend on whether you use clip_feature_gen.py or clip_feature_gen_paths.py.
Recommended packages:
pandasnumpypyarrowtorchopen_clip_torchpillowfaissorfaiss-gpuif you want ANN neighbors in the CLIP script
Example CPU setup:
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install pandas numpy pyarrow torch open_clip_torch pillowExample GPU setup:
conda create -y -n recsys python=3.10
conda activate recsys
conda install -y pytorch pytorch-cuda=12.1 -c pytorch -c nvidia
pip install pandas numpy pyarrow open_clip_torch pillow faiss-gpupython prep_items_meta.py
python prep_reviews_revised.py
python media_downloader.py
python clip_feature_gen.py
python lgcn_model.py
python transact-model.py - The repo currently includes several experiment and baseline scripts. Not every file is part of the main pipeline.
- The CLIP scripts can run in a CPU-only mode, but GPU is strongly preferred.
- If you only want the core pipeline, the five scripts above are the ones to keep track of.