From the course: Hands-On AI: Build a RAG Model from Scratch with Open Source
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Setting up a simple database schema
From the course: Hands-On AI: Build a RAG Model from Scratch with Open Source
Setting up a simple database schema
- [Instructor] Now that we have Postgres and Ollama running on our local servers, we need to make sure we have a way to connect to Postgres through a Python client so that we can store our data in our database. Let's quickly recap how we intend to do this. We wanna store each sentence in each of our files as a different row in our database. We'll wanna store it along with its vector, embedding its position in the file and the name of the file it comes from. So let's dive in. The first thing we wanna do is source the environment that we created back in chapter two. So let's go ahead and source rag_env/bin/activate. And now we're gonna install three Python packages. It's gonna be SQLAlchemy, pgvector, and Psycopg 2. So let's go ahead and paste that right here and hit Enter. Great, we got that installed. And let's create a new file called Database_connect_embeddings. So we're putting our embeddings in the database with…