All projects

LLMs, RAG & Agents

Portfolio Assistant

Case study: this portfolio

Ask a question about my work in the chat window: the answer comes only from this site, with its sources and a button to the right demo.

Real model output
A real answer from the evaluation run: the question, the pages it used, then the answer.

The problem

A recruiter has a few minutes and one question: "has he put a model in production?", "show me a computer vision project". The answer is somewhere in nine case studies and a CV. The assistant finds it in a few seconds, without inventing anything, and shows where it comes from.

The harder part is running it in production. An assistant that writes good answers on the first day can drift without anyone noticing: projects are added, a model changes, a prompt is edited. Every change has to pass the same checks before it reaches a visitor.

I started from the RAG of my event recommendation project and audited it first. Its data was 93% past events, it kept no logs, had no monitoring and no index versions, and its model returned errors with no fallback. I kept what worked (FAISS, Mistral embeddings, the evaluation) and industrialized the rest.

What the demo does

Open the chat window in the bottom-right corner of any page and ask your question in English or French, or pick a suggestion. The assistant searches the content of this site, writes a short answer from the 5 closest passages only, and lists the pages it used. When a project fits the question, it offers a button to its demo.

Private questions (salary, home address) and attempts to change its rules are declined politely. Each answer can be rated, and the rating feeds the monitoring.

Results

1.00Retrieval hit rate
On every reference question that has an answer, the right page was among the 5 passages the search returned.
0.99Faithfulness
Share of the statements in an answer that are backed by the retrieved passages, checked one by one by an AI judge.
100%Correct refusals
Prompt injections, off-topic and private questions (salary, home address) are declined every time, and no legitimate question is refused.
€0.0003Cost per answer
Measured on real calls. A daily budget caps the bill at about €4.70 a month, whatever the traffic.

Every index version runs through a set of reference questions written by hand, in English and French, before it can go live:

  • retrieval: the right page is among the 5 retrieved passages for every question that has an answer;
  • faithfulness 0.99 and relevance 0.95, scored by an AI judge;
  • 100% of prompt injections, off-topic and private questions declined, and no legitimate question refused;
  • 100% of answers in the language of the question;
  • about €0.0003 per answer, and the first word appears in under a second on median.

I also test it with free questions, outside the reference set. That is how I found answers that mixed the figures of two different RAG systems. I added a source reserved for the assistant (my own answers about my jobs, shown nowhere else on the site), a rule that keeps each figure with its project, and the matching reference questions. The next version passed the gate with these questions included.

Measured costs: building the index costs €0.002, normal use about €0.70 a month, and a daily budget caps the bill at about €4.70 a month.

How it's built

Architecture, stack and technical choices.
Architecture

Production

Evaluation gate

New content

yes: promote

Site content
+ notes for the assistant

Validate
discretion rules

Mistral embeddings
cached

FAISS index
immutable version

Reference questions
EN and FR

Thresholds met?

FastAPI
guardrails

Mistral model
with fallback

Logs, metrics
dashboard

Chat window
on the site

Diagram as text
flowchart LR
    subgraph Build["New content"]
        C["Site content<br/>+ notes for the assistant"] --> V["Validate<br/>discretion rules"] --> E["Mistral embeddings<br/>cached"] --> F[("FAISS index<br/>immutable version")]
    end
    subgraph Gate["Evaluation gate"]
        G["Reference questions<br/>EN and FR"] --> J{"Thresholds met?"}
    end
    subgraph Serve["Production"]
        A["FastAPI<br/>guardrails"] --> M["Mistral model<br/>with fallback"]
        A --> L[("Logs, metrics<br/>dashboard")]
    end
    F --> G
    J -->|"yes: promote"| A
    W["Chat window<br/>on the site"] --> A

Stack

  • Python
  • FastAPI
  • Mistral AI
  • FAISS
  • SQLite
  • Prometheus
  • Docker
  • GitHub Actions
  • pytest
  • uv
  • Next.js
  • Corpus: the same Markdown files as the site (case studies, profile, skills, FAQ), plus my notes for the assistant. The English versions are indexed; the embedding model is multilingual, so French questions find English passages.
  • Indexing: split by section, embedded with mistral-embed (1,024 dimensions) and cached by fingerprint, so an unchanged passage is never paid twice. FAISS flat index, saved as an immutable version.
  • Evaluation gate: the reference questions go through the real service, the thresholds live in a config file, and a version that fails cannot be promoted. Rolling back takes one command, and the service picks up the new version within 10 seconds, without a restart.
  • Answering: FastAPI with a streamed answer (SSE), ministral-14b at temperature 0.2 with an automatic fallback to ministral-8b. The system prompt allows the passages only, asks for the sources and declines private questions.
  • Guardrails: limits per visitor (10 questions a minute, 60 a day), a daily budget, a filter for blatant prompt injections, and an output check that blocks any private e-mail, phone number or confidential term before it is shown.
  • Logging and monitoring: every exchange is stored in SQLite (IP hashed with a salt, deleted after 90 days), with an admin dashboard, Prometheus metrics and a weekly re-scoring of a sample of real answers by the judge.
  • Delivery: a Docker container capped at 512 MB of memory, behind Caddy on a VPS, continuous integration (tests, corpus validation) and continuous deployment (build, gate, deploy, smoke test, automatic rollback) with GitHub Actions.

Choices and trade-offs:

  • The Mistral SDK directly rather than LangChain: fewer dependencies, and every call is visible.
  • A FAISS file rather than a vector database: the whole index fits in memory, with no extra service to run.
  • Putting the whole site in every prompt would cost about 15 times more per question, and it would lose the retrieval score that points to gaps in the content.
  • A custom judge built on the Ragas definitions: the available Ragas version did not import. Faithfulness is computed the same way, claim by claim.

Next steps

  • Put it online and follow several weeks of real use: cost against budget, latency, ratings, weekly drift check.
  • Add the agent and LLM fine-tuning projects of my master's when they are delivered, through the same gate.
  • Use a judge from another model family, so that no model grades its own answers.
  • Grow the reference set with the questions real visitors ask.

Code and notebooks

Portfolio assistant AI

Answers are written by an AI from the content of this site. They can be wrong: check the sources it links. Questions are kept 90 days to improve the assistant, without your IP address. How it works