What are embeddings?
Embeddings represent data in a vector space, with the distance between vectors indicating their relatedness. Small distances imply high relatedness, while large distances suggest low relatedness.
Embeddings represent data in a vector space, with the distance between vectors indicating their relatedness. Small distances imply high relatedness, while large distances suggest low relatedness.
They are essential for Retrieval-Augmented Generation (RAG), fine-tuning, semantic search, clustering, recommendations, anomaly detection, classification and many other AI applications.
Although creating embeddings is relatively cost-effective, it is not without expenses. For large datasets, such as millions of products or reviews, generating numerous embeddings can be costly.
-- Install the Embedefy PostgreSQL extension
CREATE EXTENSION embedefy CASCADE;
-- Create an embeddings table for an existing table
SELECT embedefy_embeddings_table_create('products', ARRAY['id'], 'bge-small-en-v1.5');
-- Process the name column in that table
SELECT embedefy_embeddings_table_process('products', 'name', 'bge-small-en-v1.5');
-- Query products based on user prompt, using cosine similarity
SELECT p.name
FROM products p, embedefy_products ep
WHERE p.id = ep.id
ORDER BY 1 - ((SELECT embedefy_embeddings('bge-small-en-v1.5', 'looking for breakfast items')::vector(384)) <=> ep.embedding) DESC
LIMIT 5;
name
-------------
Pancake mix
Omelette
Oatmeal
Noodles
Bacon
If you have more questions, visit our FAQ page.