Prompt

How do I build similar item recommendations for an ecommerce site?

Technology / Search & Discovery Tools1 observationLast seen Oct 13, 2026

Latest observation

Oct 13, 2026OpenAI APIWeb search: off

To build “similar item” recommendations for an ecommerce site, you generally want a product-to-product similarity system. There are a few ways to do it, and the best choice depends on your data volume, catalog quality, and how personalized you want it.

1) Start with the simplest useful approach

A. Content-based similarity

Recommend products that are similar based on item attributes like:

  • category
  • brand
  • title/description
  • price
  • color/material
  • tags
  • embeddings from images/text

How it works:

  1. Build a feature vector for each product.
  2. Compute similarity between products.
  3. For a given product, return the nearest neighbors.

Good for:

  • cold start items
  • new catalogs
  • explainable recommendations

Common methods:

  • TF-IDF on text fields
  • one-hot encoding for structured attributes
  • cosine similarity
  • image/text embeddings from ML models

B. Behavioral similarity

Use user behavior to infer which items are related:

  • co-views
  • co-adds-to-cart
  • co-purchases
  • “users who viewed this also viewed that”

How it works:

  1. Build item-item interaction counts.
  2. Normalize the counts to avoid popularity bias.
  3. Recommend items often interacted with together.

Good for:

  • strong relevance
  • discovering non-obvious complements
  • improving with more traffic

Common methods:

  • item-item collaborative filtering
  • matrix factorization
  • association rules
  • graph-based recommendation

C. Hybrid approach

Usually the best production choice.

Combine:

  • content similarity
  • behavioral signals
  • popularity/trending
  • business rules

This handles:

  • new items
  • sparse traffic
  • noisy data
  • catalog changes

2) Decide what “similar” means

For ecommerce, “similar” can mean different things:

  • Substitutes: same type of product, e.g. two sneakers
  • Complements: products bought together, e.g. a camera and memory card
  • Style similarity: same aesthetic, e.g. similar dresses
  • Functional similarity: solve the same need, e.g. two laptop chargers

This matters because a “similar items” widget often means substitutes, while “frequently bought together” means complements.


3) A practical architecture

Offline pipeline

  • Ingest product catalog
  • Clean and normalize attributes
  • Create item embeddings or features
  • Compute nearest neighbors for each item
  • Store top N similar items per product

Online serving

  • When a product page loads, fetch precomputed similar items
  • Apply filters:
    • in stock
    • same locale
    • price constraints
    • not already purchased
    • brand exclusions if needed
  • Re-rank with business rules

This is fast and scalable.


4) How to build content-based recommendations

Step 1: Prepare product data

Example fields:

  • title
  • description
  • category
  • brand
  • price
  • attributes
  • image

Step 2: Convert to vectors

Options:

  • Text: TF-IDF or transformer embeddings
  • Structured features: one-hot or target encoding
  • Images: CNN/vision embeddings
  • Combine all: concatenate or learn a joint embedding

Step 3: Compute similarity

Use:

  • cosine similarity
  • Euclidean distance
  • approximate nearest neighbors for scale

Step 4: Retrieve top-k similar items

For each product, store the top 20–100 nearest products.


5) How to build behavioral recommendations

Example signals

  • Viewed together in the same session
  • Bought together in the same order
  • Frequently viewed by same users

Simple item-item similarity formula

A common approach is:

  • count co-occurrences between items
  • normalize by item popularity

For example:

  • Jaccard similarity
  • cosine similarity on interaction vectors
  • lift / PMI for co-purchase strength

This often works very well if you have enough traffic.


6) How to combine content + behavior

A simple hybrid scoring formula might be:

final_score =

  • 0.5 × behavioral_similarity
  • 0.3 × content_similarity
  • 0.1 × popularity
  • 0.1 × margin/business_priority

You can tune weights using offline evaluation and A/B tests.

A more advanced setup:

  • candidate generation from multiple systems
  • rank candidates with a learning-to-rank model

7) Scaling considerations

If your catalog is small:

  • brute-force similarity is okay

If your catalog is large:

  • use approximate nearest neighbor search:
    • FAISS
    • Annoy
    • HNSW
    • ScaNN

Typical flow:

  1. Create embeddings for all items
  2. Index them in ANN
  3. Query nearest neighbors by item id

8) Evaluation metrics

Offline:

  • Precision@K
  • Recall@K
  • MAP / NDCG
  • Coverage
  • Diversity
  • Catalog freshness

Online:

  • CTR on recommendation widget
  • add-to-cart rate
  • conversion rate
  • revenue per session
  • long-term retention

Always A/B test before full rollout.


9) Practical tips

  • Remove out-of-stock items
  • Exclude duplicate variants unless you want variant recommendations
  • Penalize extremely popular items if they dominate results
  • Keep the recommender updated regularly
  • Use different logic for:
    • product page
    • cart page
    • checkout page
    • homepage

10) A good MVP plan

If you want to ship fast:

  1. Use product metadata only
  2. Build text embeddings from title + description
  3. Add category/brand filters
  4. Use cosine similarity to get top 20 similar items
  5. Filter for in-stock and price range
  6. Measure CTR and refine with purchase/session data later

11) Suggested tech stack

  • Data storage: PostgreSQL, BigQuery, Snowflake
  • Feature generation: Python, pandas, Spark
  • Embeddings: sentence-transformers, CLIP for images
  • ANN search: FAISS, HNSWlib
  • Serving: FastAPI, Redis cache
  • Experimentation: A/B testing platform

If you want, I can also give you:

  1. a simple Python example for item similarity,
  2. a production architecture diagram, or
  3. a recommendation strategy by use case like “similar products” vs “frequently bought together.”

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.