Project · AI & ML

Incident Navigator

RAG assistant that helps operators resolve industrial incidents from past accident reports, with every sentence linked to its source.

Ref.
01.01
Period
Jan 2025
Status
Completed
Organization
M2 AI — UCBL
Contributors
Axel COLMANT, Matéo MUÑOZ and Mohamed Massamba SENE
Stack
  • Python
  • Flask
  • React
  • Llama 3.3 70B
  • E5-large-v2
  • Weaviate
  • MongoDB
  • Docker
  • RAGAS

Key points

  1. Three-stage pipeline: conversational query refinement, vector retrieval filtered by the user's industries, cited answer generation.
  2. Each part of the answer is colour-coded to the incident report it comes from.
  3. Evaluated with RAGAS on 24 questions: 90% response relevancy, 73.7% faithfulness, 82.9% context precision.
  4. Ablation against a smaller LLM and another embedding model, plus a user study (18 participants).
  5. Built the React app and its source-ticket panel, the Flask/LLM integration and the packaging of the whole stack.

Context

When an incident happens on an industrial site (a chemical leak, a fire, a machine failure), the operator on duty needs to know quickly how similar cases were handled before. That knowledge exists, buried in years of incident reports, but keyword search tools like Elasticsearch miss reports written with different words, and a plain chatbot answers confidently from its training data, with no way to check where an answer comes from.

Goal: an assistant that understands a vague, stressed question, finds the relevant past incidents, and answers with every claim traceable to a real report.

Built in a team of three (Matéo Muñoz, Mohamed Massamba Sene and me) for the Theory and Practical Applications of LLMs course of the M2 AI at Université Claude Bernard Lyon 1, and written up as a short paper with equal contribution. My teammates led the retrieval pipeline, the prompts and the evaluation; I turned that pipeline into a usable product: the chat interface that makes the sources visible, its integration with the LLM backend, and the packaging (details below).

Data

The knowledge base is eMARS, the European Commission's Major Accident Reporting System: 1,190 reports of industrial accidents from 1979 to 2023, across 45 industries (general chemicals and oil refining make up the largest share). 967 are major accidents, the rest near misses and other events.

Each report describes the accident, its causes, its consequences, the emergency response and the lessons learned, which is exactly what an operator needs. Reports are stored in full in MongoDB and embedded into a vector index; each user only searches the industries they are authorised for.

Pipeline

The system runs in three stages for every message (Fig. 1), and keeps the conversation history so follow-up questions stay in context.

Fig. 1The IncidentNavigator pipeline, from our paper.
IncidentNavigator pipeline: question refinement, document retrieval, response generation around the conversation history

Fig. 1The IncidentNavigator pipeline, from our paper.

  1. Question refinement. The LLM rewrites the user's question together with the chat history into a precise, self-contained search query. A question like "chemicals exposed, risk of gas emanations, any known solutions?" becomes a query the retriever can actually match.
  2. Document retrieval. The refined query is embedded with E5-large-v2 and searched in Weaviate, filtered on the user's authorised industries: 20 diverse candidates (MMR), re-scored by a cross-encoder reranker (FlashRank, ms-marco-MiniLM) that keeps the top 3. Those reports are then loaded in full from MongoDB.
  3. Response generation. The LLM writes the answer from the refined query, the retrieved reports and the history, and returns structured JSON: the answer in HTML, with each passage colour-coded to the report that supports it (Fig. 2). The operator sees at a glance which incident backs which recommendation.

Both LLM roles use the same model (Llama 3.3 70B served by Groq) with task-specific prompts.

Fig. 2The passage in green comes from ticket #1193 (Major Accident, chlorine installation), shown in the same colour in the sidebar.
IncidentNavigator chat: an answer about chemical gas releases, with one passage highlighted in green next to the matching ticket #1193 in the sidebar

Fig. 2The passage in green comes from ticket #1193 (Major Accident, chlorine installation), shown in the same colour in the sidebar.

From pipeline to product

A RAG pipeline in a notebook is not something an operator can use. My job was to make it one: I built most of the React app and its connection to the backend.

  • Chat interface (React). Conversation view, history of past chats, and the source-ticket panel: each ticket used for the answer is listed with its type and industry, in the same colour as the passage it supports. That colour coding is what makes the system's main promise, traceability, visible to the user.
  • Accounts and access. Sign-up and login, sessions with JWT tokens refreshed automatically, protected routes, and per-industry access so each user only queries the reports they are allowed to see.
  • Integration with the pipeline. The Flask route that sends a message through the LLM chain and returns the answer with its tickets, and the storage of tickets and conversations in the database.
  • Packaging. The stack runs with Docker Compose (Weaviate, MongoDB, Redis) behind one-command install / start / uninstall scripts, with the React build served by Flask, and the README that documents setup and LLM configuration.

The app also has an admin page (built by Matéo) to plug in any OpenAI-compatible LLM endpoint without touching the code.

Evaluation

We wrote 24 test questions simulating real incident scenarios and scored the answers with RAGAS (Llama 3.3 70B as the judge). To check that each component earns its place, we compared the full pipeline with two variants: a smaller LLM, Llama 3 8B, and a different embedding model, gtr-t5-large (Table 1).

Metric (mean %)Full pipelineLlama 3 8Bgtr-t5-large
Context precision82.969.749.9
Context recall48.944.313.5
Response relevancy90.097.482.7
Faithfulness73.765.165.4
Table 1RAGAS scores of the full pipeline and of two variants (mean %, best in bold).
  • The embedding model matters most: swapping E5 for gtr-t5-large drops context recall from 48.9% to 13.5%.
  • The 8B model sounds more relevant (97.4%) but is less faithful to the retrieved reports: fluent answers that drift from the sources. For incident response, grounding wins, so we kept the 70B model.

User study. 18 participants compared, on 10 questions, three anonymised answers: our pipeline, Llama 3.3 70B without retrieval, and a human-written reference. Our pipeline was preferred most often (40.6%), ahead of the raw LLM (36.1%) and the human answer (23.3%).

Limits and next steps

  • Context recall stays below 50%: part of the relevant reports is still missed. Hybrid search (BM25 + dense vectors) is the obvious next step.
  • RAGAS uses an LLM as the judge, and the user study is small; an evaluation with real operators would be more convincing.
  • Multilingual reports and images (site photos, diagrams) are not handled yet.

References

  1. [1]Lewis et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. NeurIPS
  2. [2]Wang et al. (2022). Text Embeddings by Weakly-Supervised Contrastive Pre-training (E5)
  3. [3]Es, James, Espinosa-Anke, Schockaert (2024). RAGAS: Automated Evaluation of Retrieval Augmented Generation. EACL demo
#llm#rag#chatbot#retrieval#evaluation