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

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

Super good walkthrough of how to create a front end using django for you Vector DB backend 🙂Impressive work!!

mattiassoderberg
Автор

Thanks for making this video! Really great content.

helloh
Автор

Taking us to another level. Thanks very much

AmoahDevLabs
Автор

great video, man i wish you had a video like everything about docker and kubeflow pipeline videos for dummies like me

efgmlgk
Автор

Thank you very much for making this video!

jonprasetyo
Автор

excellent intel bro! I've been looking to build a specialised chatbot using Django and i think this concept hits the mark right on the head, would appreciate if you could make some more videos on the subject, but a great job thus far!

janirico
Автор

Thank you so much! You are a great teacher

ouuv
Автор

As always, you explain everything perfectly. Thanks for this video. My question is: Is PostgreSQL suitable for Django AI applications? Or is it better to use Vector databases like Chroma?

sultanal-otaibi
Автор

What if we have an existing postgres db and installed the extention? how would we create new tables when we need them and use makemigrations and migrate to generate them?

shaunpx
Автор

Thank you for your useful content. I am facing a small problem can you please help me in this.
By Running this command in pgAdmin Query Tool
create extension vector
I am getting this error.
ERROR: extension "vector" has no installation script nor update path for version "0.5.1"

SQL state: 22023

noumanaziz
Автор

Thanks a lot great stuff! Is there source code available to this tutorial?

VidejaZoSrandy
Автор

Many thanks, hope it work with Oracle db 😢

wiki-infodevelopment