Self-hosted knowledge assistant

Answers from your company’s documents. Cited, and only what each person may see.

Enterprise RAG turns policies, contracts and HR records into an assistant that cites every fact and enforces access rules inside the search itself, so restricted text never reaches the model.

Runs on your infrastructure · Any OpenAI-compatible model · REST API and chat UI included

Signed in as sam · access: employee
Who founded Insurellm, and which product came first?
Insurellm was founded by Avery Lancaster in 2015 [1]. Its first product was Markellm, a marketplace connecting consumers with insurance providers [1][2].
Demo knowledge base: Insurellm, a fictional insurance company that ships with the project.
  • 4access levels, enforced inside retrieval
  • 150question evaluation suite included
  • 4file formats: PDF, DOCX, Markdown, TXT
  • 0re-embeds for unchanged files

Works with any OpenAI-compatible model provider

  • OpenAI
  • Azure OpenAI
  • Groq
  • OpenRouter
  • Ollama

Features

Everything a company needs from a document assistant

Accurate answers people can check, access rules that hold up in an audit, and the plumbing to run it in production.

Access control inside the search

Each folder gets a level: public, internal, confidential or restricted. Each role gets a clearance. The filter runs inside both the vector search and the keyword search, so a guest’s question can never pull an HR record into the prompt.

PublicEveryone
InternalEmployees and up
ConfidentialManagers and up
RestrictedHR and admins

A citation for every fact

Answers cite numbered sources like [1] or [2-4]. Only citations that point to a real retrieved chunk are kept, and the cited passages open in the sources panel.

Hybrid search

Semantic vectors find meaning; BM25 keywords find exact names, IDs and numbers. Reciprocal Rank Fusion merges both.

Rewrite and rerank

Follow-ups like “what about his salary?” become standalone queries; a fast model reorders the top candidates.

Incremental indexing

A SHA-256 hash per file means only new and changed documents are embedded. A failed run never leaves the index half-updated.

API and chat UI

A FastAPI service with API keys mapped to roles, and a chat interface with login, sources panel and access badges.

Quality you can measure

A 150-question evaluation suite reports MRR, nDCG and keyword coverage for retrieval, and an LLM judge scores accuracy, completeness and relevance, by question category. Compare chunking modes, hybrid search and reranking before you change production.

How it works

From folder to cited answer in four steps

No new document system to adopt. Point it at the files you already have.

  1. Organise by folder

    Put documents in folders like products/, contracts/ and employees/, and give each folder an access level. Unlisted folders default to restricted.

  2. Index

    Documents are split at headings, tagged with their access level and embedded. Re-runs only touch files that changed.

  3. Ask

    The question is rewritten, searched by meaning and by keyword, and reranked. Only chunks within the asker’s clearance are considered.

  4. Verify

    The answer cites its sources, and the cited passages open beside it so anyone can check the wording.

Try it: same question, different roles

What is Alex Chen’s current salary?
I couldn’t find anything about that in the documents you can access.

Folders this role can search

  • company/Public
  • products/Public
  • contracts/Confidential
  • employees/Restricted

Security

Fails closed, by default

The safe answer is the default answer. Anything the system can’t place gets the lowest clearance or the highest protection.

  • Unknown role? Treated as a guest.
  • Folder without a level? Treated as restricted.
  • No API keys configured? The API refuses every request.
  • System messages in chat history? Rejected before they reach the model.
  • Too many requests? Rate-limited per API key.
  • Model provider down? A clean error, never a stack trace.

Who it’s for

Built for the teams that answer questions all day

Managers cleared for contracts ask “What does the Roadway contract say about the term?” and get the answer with the clause cited.

Sales operationsContracts and pricing

HR records stay restricted to HR. Everyone else can still ask about benefits, culture and careers from the public company documents.

People teamsPolicies and records

Product questions get one consistent, cited answer instead of five different ones in five different chats.

Customer supportProduct knowledge

FAQ

Questions, answered

Something missing? The README in the project covers setup, configuration and troubleshooting in detail.

Where does my data go?

The index lives on your own server. To answer a question, the relevant passages and the question are sent to the model provider you configure. To keep everything on your own hardware, point it at a local model with Ollama.

Can someone see a document above their clearance?

No. The access filter runs inside both searches, before anything is sent to the model. Restricted passages are never retrieved for a lower role, so they can’t leak into an answer. Unknown roles and unmapped folders fail closed.

Which file types and models are supported?

PDF, Word (.docx), Markdown and plain text. Any OpenAI-compatible endpoint works for chat and embeddings, including OpenAI, Azure OpenAI, Groq, OpenRouter and Ollama.

How do people sign in?

The API maps each API key to a role. The chat UI has a login that maps each user to a role. For larger organisations, put your single sign-on in front of the app.

What happens when documents change?

Re-run ingestion. Each file is hashed, so only new and changed files are re-embedded and deleted files are removed. New embeddings are computed before the index changes, so a failed run leaves the old index intact.

How do I know the answers are good?

Run the included evaluation: 150 questions with reference answers across seven categories. It reports retrieval quality (MRR, nDCG, keyword coverage) and answer quality judged by a model, so you can compare settings with numbers.

Get started

Running on your machine in minutes

You need uv (it fetches Python 3.11+ if missing) and a key for any OpenAI-compatible provider. The demo knowledge base is included, so you can ask questions straight away.

  • Builds the index in about a minute for the demo data
  • Chat UI and REST API, with interactive API docs
  • Offline test suite, no API key needed
Terminal
# install (creates .venv from uv.lock)
uv sync
# .env: OPENAI_API_KEY=… and DEV_MODE=true (local)
# index the documents
uv run python -m rag.ingest
# chat UI
uv run python app.py
# or the REST API (docs at /docs)
uv run uvicorn api.main:app --port 8000