Skip to Content

Walk through an end-to-end RAG pipeline at a high level.

Category: Database & RAG

Answer

Ingest: load PDF -> split into chunks -> embed each -> upsert row + vector into chunks table. Retrieval: embed the user question -> ANN top-K -> fetch full text rows. Generation: assemble prompt(question, top-K chunks) -> LLM -> answer. Errors must bubble up at every stage so you can replay any step from logs.

Concrete examples from the fca project context

Example 1

ingest_pdf: file path -> page iterator -> splitter -> embed -> batch upsert to pgvector.

Example 2

query: question -> embed -> ANN top-K -> Pydantic list of RetrievedChunk.

Example 3

prompt: chat template(question, chunks) -> ChatGroq -> answer.

Data flow / flow chart

PDF -> splitter -> embed -> pgvector upsert
Question -> embed -> ANN top-K -> LLM -> answer
       (errors at any step replay via per-row logs)

Takeaway

RAG is three components glued by typed interfaces; one missing interface will silently break the chain.