AIForum.

How to Build a Private Document Q&A System with Local AI and RAG

On this page

THE SHORT ANSWER

A private document Q&A system indexes your own files as embeddings and lets a local language model answer questions with citations. This guide explains the pipeline, two open reference stacks (LM Studio-based LocalRAG and an Ollama/Qdrant/Docling stack), the steps to stand one up, and how to diagnose the failures that actually occur.
Quick facts

A private document Q&A system is a retrieval-augmented generation (RAG) pipeline that runs entirely on your own machine: your files are converted to text, split into chunks, turned into embeddings, stored in a local index, and retrieved as context whenever you ask a question. The language model that writes the answer never sends your documents to an external API.

Two open projects in the current landscape make this concrete. LocalRAG (Amir-Mohseni) pairs LM Studio with a Python app and states it runs in under 2.5 GB of memory while handling PDF, DOCX, TXT, MD, and CSV files. SirajSpark/local-rag takes a heavier, containerized route with Ollama, Qdrant, and Docling, adds structure-aware chunking and automatic document summaries, and is published under the MIT License as an early, functional prototype. This article explains what each stage does, how to stand a system up, and where these pipelines typically break.

What the pipeline actually does

Every local document Q&A system, regardless of the tools chosen, performs the same sequence of operations. Understanding the stages matters because most failures are traceable to exactly one of them.

  1. Ingestion. Files are read from disk or an upload folder. Format support is the first differentiator: LocalRAG lists PDF, TXT, DOCX, MD, and CSV, while SirajSpark/local-rag lists PDF, DOCX, PPTX, XLSX, TXT, and images in PNG, JPEG, TIFF, BMP, and GIF formats.
  2. Conversion and chunking. Documents become plain text or markdown and are then split into passages small enough to embed and retrieve. SirajSpark/local-rag converts with Docling and then splits the resulting markdown using a custom heading- and table-aware chunker, which preserves document structure better than fixed-length splitting.
  3. Embedding. Each chunk is passed through an embedding model that returns a numeric vector. LocalRAG recommends the embedding model text-embedding-embeddinggemma-300m-qat, listed at roughly 229 MB quantized.
  4. Indexing. Vectors are written to a vector store. SirajSpark/local-rag uses Qdrant; the LocalRAG README summary retrieved for this article does not name a specific vector store.
  5. Retrieval. Your question is embedded with the same model, and the nearest chunks are selected as context.
  6. Generation. The retrieved chunks plus your question form a prompt for the local LLM. LocalRAG recommends qwen/qwen3-4b-thinking-2507, listed at roughly 2.28 GB quantized.
  7. Citation. Both projects surface sources. LocalRAG shows which documents were referenced; SirajSpark/local-rag streams answers token by token with inline (filename) citations and then extracts the cited sources into a structured view.

Prerequisites and realistic hardware expectations

LocalRAG requires Python 3.10 or newer and LM Studio for running the local models. SirajSpark/local-rag is fully containerized with Docker Compose and depends on Ollama, Qdrant, and Docling.

On memory, the LocalRAG README claims the application uses less than 2.5 GB of RAM. Treat that as the project’s stated figure for its recommended configuration rather than a universal constant. Quantized weight sizes — about 229 MB for the embedding model and about 2.28 GB for the LLM — describe the files on disk, not peak runtime memory. Context length, the KV cache that grows with it, and the runtime’s own overhead all add on top, so a longer context window or a larger model will exceed the stated budget. Plan for headroom above the documented figure.

You also need disk space for model files and the vector index, and on the containerized stack, a working Docker environment before anything else.

Comparing the two reference stacks

The table below summarizes documented capabilities from each project’s README as retrieved. It reflects published descriptions, not independent testing, and the two projects are at different maturity levels.

AttributeAmir-Mohseni/LocalRAGSirajSpark/local-rag
Model runtimeLM Studio, local server at http://127.0.0.1:1234Ollama, containerized
Vector storeNot named in the retrieved README summaryQdrant
Document conversionNot named in the retrieved README summaryDocling
Supported formatsPDF, DOCX, TXT, MD, CSVPDF, DOCX, PPTX, XLSX, TXT, PNG, JPEG, TIFF, BMP, GIF
Folder uploadYesNot stated in the retrieved summary
Document summariesNot statedGenerated on ingest via a map-reduce pipeline
License / statusNo license stated in the retrieved listingMIT License; described as an early, functional prototype

Choose LocalRAG when you want the smallest moving-parts footprint and a plain Python install. Choose SirajSpark/local-rag when format breadth, structured chunking, and containerized reproducibility matter more than simplicity — and accept its own warning that it is not yet production-ready.

Standing up the LocalRAG stack

These steps follow the project README. They describe a documented setup, not a configuration independently tested for this article.

  1. Verify Python. Confirm you have Python 3.10 or newer available.
  2. Clone and install.
    git clone https://github.com/Amir-Mohseni/LocalRAG.git
    cd LocalRAG
    pip install -r requirements.txt
  3. Install LM Studio and use its model search to download the recommended models: qwen/qwen3-4b-thinking-2507 for generation and text-embedding-embeddinggemma-300m-qat for embeddings.
  4. Start the local server. In LM Studio, open the Local Server tab, load the downloaded models, and start the server. The README states it runs on http://127.0.0.1:1234.
  5. Launch the application and upload documents, or an entire folder, from the chat interface.
  6. Ask a question and inspect the source citations the interface returns.

Verifying the result

A working system passes three checks. First, the model server answers on its local address while the app is running — if the app cannot reach it, retrieval and generation both fail at once. Second, ask a question whose answer appears verbatim in one of your documents and confirm the cited source is that document, not a similar one. Third, ask something your documents do not cover; a healthy pipeline should say it lacks the information rather than producing a confident answer. If the third check fails, retrieval is returning weak context and the model is filling the gap.

Ingestion quality is where most systems succeed or fail

Generation quality is mostly a function of what retrieval hands the model. Two design details are worth attention.

Chunking strategy. Fixed-size splitting cuts through headings and tables, producing fragments that embed poorly. SirajSpark/local-rag addresses this by converting with Docling and then splitting markdown with a heading- and table-aware chunker, which keeps related content together.

Re-ingestion. Documents change. SirajSpark/local-rag detects filename conflicts and offers an overwrite or re-ingest workflow; re-ingesting creates fresh chunks and automatically removes stale vectors from earlier generations. Without that behavior, an updated file can leave old, contradictory passages in the index, and the model may retrieve both.

Diagnosing common failures

Work through these in order, from least invasive to most.

  1. No answers at all, or immediate errors. Confirm the model server is running and reachable at the address the app expects (http://127.0.0.1:1234 for the LM Studio setup). If the server is up, confirm both an LLM and an embedding model are loaded — a missing embedding model breaks ingestion silently while the chat interface still appears functional.
  2. Answers ignore your documents. This points at retrieval, not generation. Check that the embedding model used at query time is the same one used at ingest time; mixing models produces vectors that are not comparable. Then check chunk quality: extract text from a source document and confirm it is not empty or garbled.
  3. Scanned or image-heavy files return nothing. Text extraction fails on pages without a text layer. The containerized stack lists image formats and uses Docling for conversion, which is the relevant path to investigate; for other pipelines, verify extraction before blaming the model.
  4. Memory pressure or swapping. Reduce context length, use a smaller quantized model, or lower the number of retrieved chunks. Remember that the 2.5 GB figure is the project’s stated configuration, not a ceiling that scales automatically.
  5. Truncated or rambling answers. Usually a prompt-assembly or context-window problem. Fewer, better chunks generally beat more, worse ones.

If the cause remains unclear, capture the retrieved chunks alongside the question. That single artifact distinguishes a retrieval failure from a generation failure in almost every case.

Privacy, licensing, and honest limits

Local execution is the privacy mechanism: SirajSpark/local-rag describes itself as privacy-first with zero external API calls, and LocalRAG markets itself on data never leaving your computer. That covers the document path, but it is not a complete security model. Model files, vector stores, and any application telemetry still live on your machine and are governed by your own backups and access controls.

Licensing deserves separate attention. SirajSpark/local-rag carries an MIT License for the application code, but that says nothing about the licenses of the models you load into Ollama or LM Studio. Open weights, open source, and commercial-use permission are three different things; check the model card for each model you deploy. The retrieved listing for LocalRAG does not state a license, so verify that before any non-personal use.

Finally, both projects are small. LocalRAG was created in September 2025 and shows a handful of stars; SirajSpark/local-rag was created in June 2026 and explicitly labels itself an early prototype. Expect rough edges, and budget time for your own evaluation rather than assuming production readiness.

What to do next

Start with the smallest stack that matches your documents. If your files are PDFs, DOCX, and text, LocalRAG gets you to a working answer quickly with LM Studio and a modest memory budget. If you need spreadsheets, presentations, or scanned images, the Ollama/Qdrant/Docling stack is the more capable starting point — at the cost of a Docker dependency and prototype-level stability.

Whichever you choose, run the three verification checks before trusting any answer, and keep the retrieved chunks visible during your first weeks of use. That habit turns an opaque chatbot into a system you can actually debug.

FAQ

Does a local RAG system guarantee my documents stay private?

It removes the external API call from the document path, which is the main exposure. It does not cover everything: model files, the vector index, and any application telemetry remain on your machine and fall under your own access controls and backups.

Why does my local model answer without using my documents?

That is usually a retrieval failure rather than a generation failure. Confirm the same embedding model is used at ingest and query time, and extract text from a source file to make sure ingestion produced usable content rather than empty or garbled text.

Can I run this on a low-memory machine?

The LocalRAG README states its configuration uses under 2.5 GB of RAM, with a roughly 2.28 GB quantized LLM and a roughly 229 MB embedding model. That figure does not include the KV cache, which grows with context length, so reduce context length or chunk count if you hit memory pressure.

What happens when I update a document that is already indexed?

It depends on the implementation. SirajSpark/local-rag detects filename conflicts and offers an overwrite or re-ingest workflow that creates fresh chunks and removes stale vectors from earlier generations. Without that behavior, outdated passages can remain in the index and compete with current ones during retrieval.

References

  1. https://github.com/Amir-Mohseni/LocalRAG
  2. https://github.com/sirajspark/local-rag

Related terms

RAG (Retrieval-Augmented Generation)
A pattern where relevant passages are retrieved from your own documents and inserted into the prompt so the model answers from that context instead of only its training data.
Embedding
A numeric vector representation of text. Chunks and questions are embedded with the same model so their similarity can be compared.
Vector store
A database optimized for storing embeddings and finding the nearest ones to a query vector. SirajSpark/local-rag uses Qdrant.
Chunking
Splitting documents into passages small enough to embed and retrieve. Heading- and table-aware chunking preserves structure better than fixed-length splitting.
Quantization
Reducing a model's numeric precision to shrink its file size and memory footprint. The sizes quoted in this article are quantized figures.
KV cache
Runtime memory a language model uses to store attention state for the tokens in its context window. It grows with context length and adds to the model's file size.

Leave a Reply

Your email address will not be published. Required fields are marked *