filmov
tv
Django & PGVector - Vector-Based Search in Django with PGVector & PostgreSQL
Показать описание
In this video, we look at connecting Django to Postgres and PGVector, and how to use a VectorField on our Django models to connect them with an underlying column of type vector.
We'll create a small proof-of-concept Django app where a user can submit some text, which is embedded using OpenAI, and then we search the database to find the "most similar" documents using PGVector and its distance metrics - L2Distance, CosineDistance, etc.
We'll also see how to add vectors to the database with Django, and how to use the inspectdb management command to integrate a Django app with an existing database.
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:20 Setup pgvector with Docker
02:48 Connect Django to Postgres database container
04:43 Using inspectdb management command to auto-generate models for existing database
06:52 Adding pgvector VectorField to Django Model
10:10 Adding documents and embeddings to template
14:27 Embedding text with openai Embedding model
20:35 Querying the database with pgvector L2Distance metric
26:33 Inserting vector data with Django and pgvector
29:55 Summary and use-cases
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
#python #langchain #datascience #postgresql #django
We'll create a small proof-of-concept Django app where a user can submit some text, which is embedded using OpenAI, and then we search the database to find the "most similar" documents using PGVector and its distance metrics - L2Distance, CosineDistance, etc.
We'll also see how to add vectors to the database with Django, and how to use the inspectdb management command to integrate a Django app with an existing database.
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:20 Setup pgvector with Docker
02:48 Connect Django to Postgres database container
04:43 Using inspectdb management command to auto-generate models for existing database
06:52 Adding pgvector VectorField to Django Model
10:10 Adding documents and embeddings to template
14:27 Embedding text with openai Embedding model
20:35 Querying the database with pgvector L2Distance metric
26:33 Inserting vector data with Django and pgvector
29:55 Summary and use-cases
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
#python #langchain #datascience #postgresql #django
Комментарии