Prompt
How do I generate similar item recommendations for a large catalog?
Latest observation
To generate similar-item recommendations for a large catalog, the usual goal is: for each item, find other items that are “close” in meaning, behavior, or usage, then surface those as recommendations.
A good approach depends on what data you have, but the scalable pattern is usually:
1) Decide what “similar” means
Common similarity signals:
- Content-based: same category, brand, attributes, text description, image
- Behavior-based: users often view/buy items together
- Collaborative: items co-liked by the same users
- Hybrid: combines several of the above
For large catalogs, hybrid usually works best.
2) Represent items as vectors
Instead of comparing every item to every other item directly, create an embedding for each item:
- Text embeddings from title/description
- Image embeddings if visual similarity matters
- Attribute embeddings for structured fields
- Behavior embeddings from user interaction patterns
These vectors let you measure similarity with cosine similarity / dot product.
3) Use ANN retrieval for scale
A brute-force all-pairs comparison is too expensive for large catalogs.
Use an Approximate Nearest Neighbor (ANN) index such as:
- FAISS
- ScaNN
- Annoy
- Vector databases like Pinecone, Weaviate, Milvus, Qdrant
Workflow:
- Build embeddings for all items
- Index them in ANN
- For each item, retrieve top-K nearest neighbors quickly
This scales to millions of items.
4) Filter out bad matches
After retrieving candidates, apply business rules:
- Exclude the item itself
- Exclude out-of-stock or inactive items
- Respect category constraints if needed
- Remove near-duplicates if you want diversity
- Boost items with better margin, popularity, or availability
5) Rerank candidates
A retrieval step gives approximate neighbors; then rerank with a more precise model or scoring formula.
Example features for reranking:
- embedding similarity
- category match
- brand match
- price proximity
- popularity
- conversion rate
- inventory
- freshness
This two-stage setup is common at scale:
- Stage 1: fast ANN retrieval
- Stage 2: ranking model or business logic
6) Precompute offline
For a large catalog, it’s often best to precompute similar items batch-wise:
- Nightly or hourly embedding generation
- ANN index refresh
- Top-N similar items stored in a table/cache
- Serve recommendations instantly at request time
This is much cheaper than computing on the fly.
7) Handle cold start
For new items with no interaction history:
- rely more on content embeddings
- use category/brand/attribute similarity
- optionally use LLM-derived text embeddings from title and description
8) Evaluate quality
Use both offline and online metrics:
- Offline:
- precision@K
- recall@K
- MAP / NDCG
- similarity relevance checks
- Online:
- CTR
- conversion
- add-to-cart rate
- revenue per impression
Also inspect examples manually to ensure recommendations are semantically sensible.
A practical architecture
For a very large catalog:
- Build item embeddings from text + metadata + behavior
- Normalize embeddings
- Index in ANN
- Retrieve top 100 candidates per item
- Apply filters
- Rerank to top 10
- Store results in a cache or database
- Refresh periodically
Simple starting point
If you want a quick first version:
- Use title + description embeddings
- Put them into FAISS
- Retrieve top 20 similar items per item
- Filter by category and availability
- Store the results in a precomputed table
That usually gets you a strong baseline fast.
If you want, I can also give you:
- a Python/FAISS example,
- a production architecture for millions of items, or
- a hybrid recommender design.