Document summarizer and RAG chatbot

Upload PDFs, Word files or text, build an embeddings index, then summarize the documents or chat with them. Every answer cites the chunks it was grounded in.

Python, FastAPI, FAISS, Sentence-Transformers, Hugging Face Transformers, OpenAI API, Streamlit, Docker
DocumentsPDF, DOCX, TXTChunksclean and splitEmbeddingsSentence-TransformersFAISS indexnearest-neighbour searchTop-k chunksfor each questionLLM answercites [doc_id:chunk_id]
How a question becomes a cited answer.

Problem

Long documents are slow to read and easy to misquote. The goal was a tool that answers questions from a set of documents and shows where each answer came from, so the answer can be checked instead of trusted.

Pipeline

  • Ingestion: load PDF, DOCX or TXT, clean the text, split it into chunks.
  • Indexing: embed chunks with Sentence-Transformers and store them in a FAISS index with a docstore that maps vectors back to their source.
  • Chat: retrieve the nearest chunks for a question and pass them to the LLM, which must cite them as [doc_id:chunk_id].
  • Summarization: map-reduce. Summarize each chunk, then summarize the summaries, so documents longer than the model’s context still fit.
  • Serving: FastAPI routers for chat and summarization, a Streamlit front end, and Docker Compose to run both.

The LLM sits behind one provider setting. The default is TinyLlama 1.1B running locally through Hugging Face, so the whole system works without an API key; switching to OpenAI is one environment variable.

Not yet measured

Retrieval quality and answer faithfulness have no numbers yet. The next step is a small labeled question set, used to report recall@k for retrieval and to check whether each cited chunk actually supports its answer.