Django & PGVector - Vector-Based Search in Django with PGVector & PostgreSQL

Описание к видео 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:
https://ko-fi.com/bugbytes

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
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

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io/
🐦 Twitter:   / bugbytesio  

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
pgvector: https://github.com/pgvector/pgvector
Python-pgvector: https://github.com/pgvector/pgvector-...
pgvector Docker image: https://hub.docker.com/r/ankane/pgvector
Django inspectdb command: https://docs.djangoproject.com/en/4.2...
OpenAI Embeddings API: https://platform.openai.com/docs/guid...

#python #langchain #datascience #postgresql #django

Комментарии

Информация по комментариям в разработке