Member-only story

Tokenizing Product Descriptions with OpenAI Embeddings and Supabase

This guide demonstrates how to tokenize product descriptions from a Supabase table for semantic meaning using OpenAI’s embedding model.

Leo Leon
8 min readFeb 28, 2025

We will cover:

  • how to set up Supabase,
  • retrieve data,
  • generate embeddings,
  • store them efficiently in the database,
  • and perform semantic searches using vector similarity.

Each step includes sample code and clear explanations. Are you ready?

Step 1: Setting Up Supabase and Retrieving Product Descriptions

Before generating embeddings, set up your Supabase database to store and handle vector data:

Enable the PNG vector extension: Supabase is built on PostgreSQL, which allows storing and querying embedding vectors. Enable it via the Supabase web dashboard (under Database → Extensions) or by executing SQL in the SQL editor. For example:

-- Enable vector extension for vector embeddings
CREATE EXTENSION IF NOT EXISTS vector;

Prepare your table: If you already have a product table with descriptions, add a new column to hold the embedding vector. The OpenAI text-embedding-ada-002 model returns 1536-dimensional vectors, so define the column with that size. For example:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Leo Leon
Leo Leon

Written by Leo Leon

Technical Product Manager | Follow for Biteable Insights

No responses yet

Write a response