Create text embeddings with OpenAI

Generate vector embeddings for text data to enable semantic search and similarity matching.

Search & Embeddings · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

You add an embedding column that automatically generates vectors for new rows. The embeddings are cached and only recomputed when the source text changes.

What it covers

  • Generate embeddings with OpenAI's models
  • Store embeddings as computed columns
  • Use embeddings for similarity queries

What it uses

Install
terminal
pip install pixeltable openai
Environment variables it names
OPENAI_API_KEY
Pixeltable calls
openai.embeddings()pxt.create_table()add_computed_column()insert()add_embedding_index()similarity()

A look at the code

embed-text-openai.ipynb
# Add embedding column using OpenAI's text-embedding-3-small
docs.add_computed_column(
embedding=embeddings(docs.content, model='text-embedding-3-small')
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103