Retrieval-augmented generation, built in the open

Answers you can trace back to the page.

RagXGen is a working RAG system. Upload a PDF or text file, ask a question, and see which passages were retrieved, how closely they matched, and where the answer came from.

Example retrieval · illustrative

What is the refund window for digital products?

  1. [1]customer-policies.pdf · chunk 120.86Refunds are available within 14 days of purchase for digital products. Requests must be submitted through the support portal.
  2. [2]customer-policies.pdf · chunk 130.74Physical items may be returned within 30 days in their original condition. Shipping costs are non-refundable.
  3. [3]faq.txt · chunk 40.58How do I contact support? Open a ticket from the support portal and the team will respond.
  4. [4]release-notes-q4.pdf · chunk 2below top-k0.21The Q4 release adds semantic search and auto-complete to the dashboard.
Generated answer

Digital products can be refunded within 14 days of purchase. Physical items have a 30-day window. Either way, requests go through the support portal.

top_k = 3 · cosine similarityHover a citation

01 — The pipeline

Four moves from file to grounded answer.

The same steps run behind every question in the demo.

  1. Upload & chunk

    Drop in a PDF or text file. It is split into overlapping chunks so no idea is cut off at a boundary.

    RecursiveCharacterTextSplitter · 1000 chars

  2. Embed & index

    Each chunk becomes a vector that captures its meaning, stored in an index built for similarity search.

    text-embedding-3-small · FAISS

  3. Retrieve top-K

    Your question is embedded the same way, and the closest chunks come back with their similarity scores.

    Cosine similarity · K = 4 default

  4. Generate with sources

    The model answers using only the retrieved passages, and the answer lists which documents it drew on.

    GPT-4o-mini · temperature 0.1

02 — Why retrieval

A model that reads before it answers.

Grounding

Fewer made-up answers

Responses are built from your documents, not the model's memory, which cuts down on confident fabrication.

Freshness

Data the model never saw

Ask about last week's release notes or a private policy file. Retrieval reaches past the training cutoff.

Attribution

Every answer shows its sources

Retrieved chunks, their scores and source files are visible, so an answer can be checked, not just trusted.

03 — Built with

A small, honest stack.

Every piece is swappable; the trade-offs are written up in the About page.

Frontend
Next.js 14
App Router, TypeScript, Tailwind CSS
Backend
FastAPI
Async Python API with Pydantic validation
Orchestration
LangChain
Loading, splitting, retrieval and prompting
Vector store
FAISS
Exact inner-product search, one index per session
Models
OpenAI-compatible
GPT-4o-mini by default; DeepSeek and similar APIs supported
05 — Live demo

Bring a document. Ask it anything.

Upload a PDF or TXT file and question it. Every answer comes with the chunks it was built from.