Skip to content
← All work

Retrieval · pgvector

Document question-answering pipeline

A retrieval-augmented generation pipeline that answers questions from a document collection using vector search in PostgreSQL. POC: the work was not pursued to deployment.

POCProof of concept. Not pursued to deployment.

query → nearest chunks → answer
Illustration
ChunksVector spaceAnswer
Illustration of documents split into chunks, embedded as vectors, and the nearest chunks retrieved to ground an answer.

The problem

Language models don't know your documents. Answers need to be grounded in the right passages, retrieved quickly and reliably.

Context

A document question-answering prototype: split a corpus, store vectors, retrieve the nearest passages, then draft an answer from those passages only.

My role

I designed and built the retrieval pipeline: chunking, embeddings, pgvector storage, similarity search and the grounded LLM answer. The work was not pursued to deployment.

What I built

Built features

  1. 01Document chunking
  2. 02Embedding and vector storage
  3. 03Similarity search for a question
  4. 04Answer generated from retrieved passages

Design decisions

  • Split documents into chunks small enough to retrieve a precise passage.
  • Store embeddings in PostgreSQL with pgvector so similarity search stays next to the data.
  • Ground the language-model answer in the retrieved chunks rather than in the model’s prior knowledge.
  1. 01Documents are split into chunks suited to retrieval.
  2. 02Each chunk is embedded and stored with pgvector in PostgreSQL.
  3. 03A query retrieves the most similar chunks.
  4. 04An LLM writes the answer from the retrieved context.

Outcome

This work stayed at proof-of-concept and was not pursued to deployment.

Architecture

How Document question-answering pipeline fits together.

Each step, in order. Select a node to see what it is responsible for.

  1. The source collection the system answers from.

  2. Splits documents into passages small enough to retrieve precisely.

  3. Encodes each chunk as a vector that captures its meaning.

    • Embedding model
  4. Stores vectors in PostgreSQL and supports similarity search.

    • PostgreSQL
    • pgvector
  5. Finds the chunks most similar to the user's question.

  6. Generates an answer grounded in the retrieved chunks.

    • LLM

Stack

  • PostgreSQL
  • pgvector
  • Embeddings
  • LLMs

Next project

Clinical training simulator

A clinical training MVP in development: students work through cases, guided by a state machine and evaluated with AI feedback and scoring. Several modules are functional; the platform is not fully delivered.