Skip to content
Document Q&A (RAG) — ai system screenshot

AI System · Personal project · 2025

Document Q&A (RAG)

Retrieval-augmented document Q&A that answers with supporting source passages.

Chunk → embed → retrieve → generate with a pretrained Hugging Face model; sources shown with every answer.

My role
Solo
Stack
Python · Hugging Face Transformers · FAISS · Streamlit
Microsoft-ecosystem fit

▸ Same pattern as Azure AI Search + Azure OpenAI “on your data”

90%

Relevant answers on test questions

Document Q&A (RAG) — main screen
Document Q&A (RAG) — mobile

Source · Streamlit demo — extractive version of the original

01 — Problem

Finding specific information in long documents was slow and unreliable.

02 — Approach

  1. 01

    Overlapping chunks, FAISS index.

  2. 02

    Top-k retrieval feeds the model; answers cite sources.

  3. 03

    Labelled question set to measure relevance.

03 — Architecture

System architecture

  1. S01

    Upload

  2. S02

    Chunk

  3. S03

    Embed · FAISS

  4. S04

    Top-k

  5. S05

    Generate

  6. S06

    Cite

04 — Engineering notes

Chunking with overlap

Answers often straddle a paragraph break. Overlapping windows keep that context in at least one chunk.

python
# demos/doc_qa/app.py
def chunk(text, size=60, overlap=15):
    words = text.split()
    step = size - overlap
    return [" ".join(words[i : i + size]) for i in range(0, max(1, len(words) - overlap), step)]

Measuring relevance

A small labelled set of question → correct passage pairs gave a single number to improve against: relevant answers on 90% of test questions.

Document Q&A (RAG) — detail screen 1

Outcome

Relevant answers on 90% of test questions, with sources shown for every answer.

Next project

Yen Dine

Yen Dine — ml research screenshot