Skip to content
All projects

INSEI

sovereign RAG assistant, in production

It answers staff questions from the institute's intranet, cites its sources and declines when it finds nothing. Everything runs on the institute's servers.

  • 300

    users

    In production, open to the whole institute.

  • 96%

    of off-topic questions refused

    Compared with 12% for V1, on the same questions.

  • 89%

    of the right documents retrieved

    Compared with 46% for V1, on 325 answerable questions.

Setting
Professional, at INSEI
Period
V2 since autumn 2026
V1 from March to July 2026
Team
V2 independently
V1 as a team of two
Role
V2 lead
V1 project lead
ChapterProblemContents
  1. Problem
  2. Constraints
  3. Architecture
  4. Decisions
  5. Results
  6. Limitations and lessons learned

Problem

Answers buried in the intranet

Staff look for information that already exists: a procedure, a contact, an HR document. Everything is on the intranet, and everything is hard to find there. The need: an assistant that answers in natural language, cites its sources and makes nothing up.

The first version, my final-year project built as a team of two, never knew when to stay silent: it had no refusal threshold. It read neither scanned PDFs nor tables. I took over the project on my own and rebuilt the assistant from scratch, ingestion included.

Constraints

Nothing leaves the institute

  • Everything stays on the institute's servers. No hosted AI service, no telemetry.
  • No license budget. Open models, self-hosted.
  • Mixed content. Web pages, directory entries, PDFs that are sometimes scanned, tables, office files.
  • One person to run it. Everything must stay readable by that person, from the code to the server commands.

Architecture

The path of a question

A LangGraph graph whose path is set by the code: no model chooses its tools. Follow one example.

An example written for illustration

Where is the expense claim form? Answer written, with its sources.

Read the questionFind the passagesAnswer or refusea personhello, thanksa documentpassageson expenses“… [1], [2]”yesnoSure enough?
Read the questionFind the passagesAnswer or refuseyesnoSure enough?

Sure enough?reranker score

The reranker's best score decides: high enough, it writes; too low, it refuses without calling the model.

Example written for the illustration.

Reading the intranet

  • Read Web pages, PDFs, tables and office files through Docling; scanned pages through an OCR model.
  • Reread Every night, only what has changed. A page leaves the index only if the intranet confirms it was deleted.
  • Switch methods A new collection is built alongside, measured, then put into production with a switch that can be rolled back.

Decisions

Choices settled by measurement

Six decisions and what settled them
DecisionOption ruled outWhat settled it
A path set by the code, a learned routerAn agent that chooses its tools; GraphRAG; RAGFlow, triedAt this model size, an agent is unreliable, and RAGFlow did worse. Fixing an error means adding an example.
Gemma 4 E4B to writeQwen 3.5 9BJust as accurate and twice as fast, measured on the same machine.
A reranker, bge-reranker-v2-m3No reranker; Qwen3-Reranker-0.6BWith it, the right passage rises from 80% to 88%, on 260 questions. Qwen3-Reranker, just as good, is five times slower.
A refusal threshold on the reranker scoreThe prompt aloneWithout a threshold, V1 answered more than half of the trap questions.
Contacts displayed by the codeA contact copied out by the modelA copied contact can be wrong. The profile comes from the directory, with a choice between people who share a name.
An evaluation written for the projectDeepEval, Ragas, promptfooThese tools send telemetry, which the project's policy rules out.

Results

V2 vs. V1: same days, same judge

Before retiring V1, I measured both versions with the same questions.

Three headline metrics, on one scale

Trap questions refused: 89% (V2, in production) vs. 47% (V1), almost twice as many.

False refusals: 6% (V2, in production) vs. 28% (V1), five times fewer, lower is better.

Right passage passed to the model: 89% (V2, in production) vs. 46% (V1), almost twice as often.

All the other metrics

Correctness of answersV2 vs. V1
What is measured

Answers judged correct, on answerable questions.

How

The same judge grades both versions' answers, on the same days, on the same machine. The gap stays positive across the whole 95% confidence interval.

On how many

325 test questions

What it means

Almost twice as many correct answers as with the first version (36%).

Limitation

The judge is there to compare two versions, not to state an absolute rate. The ratio between the versions is the measurement; the rate is only indicative.

What is measured

Correct answers on the held-out set.

How

A judge model, distinct from the models under evaluation, grades each answer. V2 was never tuned on these questions: it is the most conservative measurement.

On how many

65 questions never seen during tuning

What it means

Almost twice as many correct answers as V1 (38%), on questions never used to tune V2.

What is measured

Successful messages, replayed conversations.

How

Working split of the replayed conversations, on November 12, 2026: the same judge grades both versions' messages.

On how many

531 messages, working split

What is measured

Successful messages, held-out split of the conversations.

How

Replayed against the real API, each message checked by code; only aggregate counts are extracted from this split. V2 had already been run on it once, on October 22, 2026.

On how many

141 messages, a split never opened before the measurement

Limitation

V2 had already been run on this split once, on October 22, 2026: only aggregate counts came out of it.

What is measured

Contact questions answered correctly.

How

The profile is displayed by code, never copied by the model. On this sample, a full score does not prove that no error will ever happen in production.

On how many

profile taken from the directory

Limitation

Fifty questions: a full score on this sample does not prove that no error will ever happen in production.

RefusalsV2 vs. V1
What is measured

Off-topic questions refused.

How

Same judge for both versions, comparison of November 12 and 13, 2026. A sample too small for a precise rate.

On how many

25 questions

Limitation

Twenty-five questions: too small a sample for a fine-grained rate.

SourcesV2 vs. V1
What is measured

Expected document among the cited sources.

How

The expected document must be among the sources shown to the user; same judge, comparison of November 12 and 13, 2026.

On how many

325 answerable questions

Scanned PDFsV2 vs. V1
What is measured

Correct answers, scanned PDFs.

How

Questions whose quotation sits on a page read by OCR. For most of them, the document was missing from V1's collection: the gap comes first from reading.

On how many

39 questions on 13 documents

What it means

Almost three times as many correct answers as V1 on scanned documents (26%).

Limitation

For 31 of these questions, the document was missing from V1's collection: the gap comes first from reading.

What is measured

Right passage passed on, scanned PDFs.

How

Same questions, measured with the OCR model reading the scanned documents.

On how many

same questions

RoutingV2 only, cross-validation
What is measured

Routing examples correctly classified in cross-validation.

How

Each example is classified by a model trained on the others, on a PC, on November 19, 2026. These are the training examples, not real use.

On how many

983 examples

Limitation

These are the training examples, not real usage. Thresholds are cautious: an uncertain message falls back to document search, which lowers some intents' scores without harming the answers.

What is measured

Document messages sent elsewhere by the router.

How

Messages aimed at a document that routing sends to another branch. An uncertain message falls back to document search.

On how many

lower is better

CodeV2 only
What is measured

Product code statements covered by the tests.

How

pytest-cov on the assistant, the deployment and the readers, on a PC, on November 19, 2026, branches not counted. Coverage says where tests run, not what they prove.

On how many

by the automated tests

Limitation

A statement run by a test is not a statement checked: coverage says where the tests go, not what they prove.

  • The set. 500 test questions, 325 to answer and 175 to refuse. The trap questions fall into five kinds: missing information, off-topic, false premise, dangerous, or incomprehensible. Across the whole set, 100 form a sealed held-out set, never used for tuning.
  • The judge. An LLM distinct from the models under evaluation, with a frozen prompt. Each version read the intranet with its own code.
  • The uncertainty. A 95% confidence interval on each gap, resampled by whole document. The decision rule is written down before each measurement.
  • The conditions. Both versions, on November 12 and 13, 2026, on the same machine, under Ollama, with the same judge. This set is harder than V1's, which had no trap questions or scanned PDFs, so their rates are not comparable.

Limitations and lessons learned

What I would measure earlier

I measured each component after the comparison, not when it was added. This late measurement shows that BM25 adds nothing once the reranker is in place: without BM25, the right passage does not move. Done earlier, it would have raised the question of keeping BM25.

The time saved by staff was never measured. That would have required timing a request handled the old way, before the first version. The test questions were written from the documents as V2 reads them; the held-out set and the held-out conversations therefore give the most conservative figures. Next measurement: response time and load handling, on the production server.