AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Nov 16, 2026, 16:00 JST

AI.EMBED lets BigQuery handle similar-product search in SQL

Send on LINE
AI.EMBED lets BigQuery handle similar-product search in SQL

3 Key Points

  1. What happened

    AI.EMBED converts product names and descriptions into embedding vectors, then cosine similarity ranks the top 5 similar products for a target item such as P001.

  2. Why it matters

    The whole similar-product lookup can run as SQL batch queries inside BigQuery, so small e-commerce operators can offer meaning-based recommendations without dedicated engineering staff.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

By signing up you agree to the Terms of Service and Privacy Policy.

Context & Analysis

AI.EMBED was a 2024 addition to BigQuery's set of ML SQL functions, and the case builds around a concrete gap: small e-commerce sites typically cannot afford hand-setting related products across hundreds to thousands of SKUs. Rather than presenting vector search as a research topic, it walks through a working pipeline — create a product master table, generate embeddings into a separate table with ML.GENERATE_EMBEDDING using the text-embedding-004 endpoint, then rank candidates by cosine similarity.

The explanation stresses why keyword matching is not enough: "100% cotton white T-shirt" and "cotton white cut-and-sew" differ in wording but land near each other in vector space, so similar products surface even when search terms do not overlap. The cosine scores range from -1 to 1, with values closer to 1 meaning greater semantic similarity, and the query returns the top 5 with a rounded score.

The final section extends the idea to GA4's BigQuery export, joining recent product-page view sessions with the similarity table to produce recommendation candidates for marketing and newsletter content. The suggested starting point is modest: validate behavior on a sample of 10 to 20 products, then tune what text goes into the content field and schedule regular embedding refreshes so new products are covered.

FAQ
Do I need Python or external APIs to build this?
No. The implementation is completed in SQL, and AI.EMBED relies on Google Cloud's Gemini models through Vertex AI integration, so no separate model is needed.
What setup is required before using AI.EMBED?
You must enable the Vertex AI API and have access to Gemini Embedding models in your Google Cloud project. A Vertex AI connection resource is also registered for ML.GENERATE_EMBEDDING.
How can similar-product search be used together with analytics data?
By joining the similar-product table with GA4 BigQuery export data, you can recommend products similar to the most-viewed items, for example those visited via social traffic.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

By signing up you agree to the Terms of Service and Privacy Policy.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleThailand GDP grows 2.9% on AI-related exports