This repository contains the complete implementation of the AI Product Intelligence System built using pre-trained CLIP (Contrastive Language-Image Pretraining) embeddings, vector search, and custom algorithmic heuristics.
Standard recommendation engines search for visually identical products. To improve user conversion and cross-selling, we engineered a system to recommend complementary items (e.g., matching running shoes with socks, apparel, and a fitness watch).
-
Rule-Based Category Linkages: Maps search categories directly to coordinate styled accessories (e.g.,
Footwear$\rightarrow$ Socks,Watches,Apparel). -
Contextual Filtering: Restricts candidate recommendations by
gender(e.g., Men or Unisex for male items) andusage(locking suggestions toSportsaccessories when viewing running shoes). - CLIP Visual Affinity: Ranks candidates within coordinate categories using cosine similarity of CLIP image embeddings.
Marketplaces face data quality issues due to sellers uploading near-duplicate products (e.g., slightly altered names, different packages like "Pack of 2"). This pipeline automatically groups duplicates and cleanses the database into a canonical unique catalog.
-
Leader-Centroid Clustering: Designates the first unvisited item as a leader and clusters all other unvisited items with cosine similarity
$\ge 0.88$ (adjustable threshold). - Medoid Selection: To select a single "canonical" product for each cluster, it computes the pairwise intra-cluster similarity matrix and identifies the medoid item (highest average similarity).
- Canonical Name Synthesis: Standardizes titles by cleaning noise suffixes, duplicate indices, pack counts (e.g. "Pack of 3", "Size L", "Combo", "Shoe A") using Regex patterns.
Enables natural language text search against product image databases by mapping textual semantics directly to visual assets in a shared vector space.
- Shared Space Retrieval: Maps text queries into the same joint embedding space as product images using the CLIP text encoder.
- Semantic Matching: Ranks candidate images by computing cosine similarity between the query text embedding and image embeddings.
-
Clone the Repository:
git clone https://github.com/khushalkks/GenAi.git cd GenAi -
Install Required Libraries:
python -m pip install streamlit sentence-transformers pandas numpy pillow scikit-learn matplotlib kagglehub
-
Run the Interactive Streamlit Web Application:
streamlit run app.py
This launches a browser dashboard at
http://localhost:8501/. -
Run the Self-Contained Notebook:
- Open
Bootcamp_Day2_Homework.ipynbin VS Code or Jupyter Lab. - Run cells sequentially to download the Kaggle dataset programmatically and execute verification.
- Open
- Khushal - Developer & Project Lead - @khushalkks
Contributions are always welcome! Feel free to open issues or submit pull requests to make this engine even better. ⭐


