# Build an end-to-end RAG pipeline entirely in psql using pgrag and DeepSeek

DevFeed: [Build an end-to-end RAG pipeline entirely in psql using pgrag and DeepSeek](<https://devfeed.tech/articles/build-an-end-to-end-rag-pipeline-entirely-in-psql-using-pgrag-and-deepseek-5718.md>)

Original publisher: [Read original article](<https://neon.com/blog/pgrag-and-deepseek>)

Author: George MacKerron

Published: 2025-01-30T18:00:00Z

Content type: tutorial

Language: en

Sources: [Blog -- Neon Docs](<https://devfeed.tech/sources/blog-neon-docs.md>)

Topics: [Retrieval Augmented Generation (RAG)](<https://devfeed.tech/topics/retrieval-augmented-generation-rag.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [deepseek](<https://devfeed.tech/topics/deepseek.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>)

Tags: [database](<https://devfeed.tech/tags/database.md>), [deepseek](<https://devfeed.tech/tags/deepseek.md>), [embedding](<https://devfeed.tech/tags/embedding.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [product](<https://devfeed.tech/tags/product.md>), [rag](<https://devfeed.tech/tags/rag.md>), [retrieval](<https://devfeed.tech/tags/retrieval.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This tutorial explains how retrieval-augmented generation works and introduces pgrag, a Postgres extension for building an end-to-end RAG pipeline entirely in psql. It describes document chunking, embeddings, vector search, reranking, and generating answers with AI chat models such as ChatGPT, Claude, and DeepSeek.

## Source excerpt

Retrieval-Augmented Generation (RAG) works by taking a user's question, searching for information relevant to that question, and then including the retrieved information alongside the question in a prompt to an AI chat model: ChatGPT/Claude/DeepSeek, please answer question X usin...