With a Retrieval-Augmented Generation (RAG) system, you can create an AI assistant that can answer questions based on the information contained within

RAG With PostgreSQL - pgDash

submited by
Style Pass
2024-05-12 13:00:05

With a Retrieval-Augmented Generation (RAG) system, you can create an AI assistant that can answer questions based on the information contained within your existing, in-house knowledge bases like wikis, manuals, training and reference material.

We will use a few paragraphs from a story as our “document corpus”. For each document, we’ll generate an embedding of the document using Meta’s open source LLM Llama3, hosted locally using ollama. We will then store the document and it’s embedding into a PostgreSQL table. The embedding will be stored and accessed using the pgvector extension.

For querying, we’ll retrieve a single document from our table most relevant to the user’s query, and use llama3 again to generate a response.

For the Go code, we’ll use jackc/pgx and pgvector-go to talk to Postgres, and the ollama client-side API package to make the HTTP API calls.

Ollama is a recently released tool that allows you to run popular open source models (see list) locally on your machine. It provides a model-agnostic OpenAI-style REST API that can be used from client applications. See the docs for installing and running ollama.

Leave a Comment