1. Overview
When a machine misbehaves, the answer is usually written down somewhere: in a visual manual (VM), a work instruction (WI) or a one-point lesson (OPL). There are thousands of them. Finding the right one used to take hours of searching, or a walk across the plant to ask someone who remembers.
ai-ebook lets operators ask the question in plain language and get an answer in seconds, with deep links back to the pages it came from.
Figure 1: An answer to “why is packaging bloated?”, broken down into a 5M root-cause and corrective/preventive action (CAPA) table, built from 5 matching cases. Chat history is blurred.
2. Architecture
Every question goes through four steps before the model writes an answer:
Figure 2: From question to cited answer. Jev picks the intent, the query is rewritten with the user’s profile, and two-stage retrieval narrows 781 cases to 300, then to 10.
- Intent: Jev, our decision model API, classifies the question first. Is the user troubleshooting a problem, asking for guidance on how to do something, or asking about an overall business process? Each intent searches a different slice of the library and gets a different answer format (a 5M and CAPA table for troubleshooting, steps for guidance, a flow for business processes).
- Query rewrite: the question is then rewritten using the intent and the user’s preferences, such as their line, area and language. A short question like “kenapa kembung?” becomes a full search query with the right area and terms.
- Stage 1, recall: a bi-encoder embeds the rewritten query and compares it against case embeddings stored in pgvector. BM25 keyword matching runs alongside it for part numbers and machine codes. This stage is fast and wide: it keeps the top 300 candidates.
- Stage 2, precision: a cross-encoder reranker reads the query and each candidate together, which is slower but much more accurate, and keeps the top 10.
- Answers: only those 10 reach the LLM. Answers are generated with citations, so every claim points at a real document.
- Evaluation: every stage is scored on a gold set with Ragas and exact retrieval metrics, tracked in Langfuse (see Section 3).
Figure 3: The case library, with 781 cases across business units and support departments, organised by area. Photos are blurred.
2.1. Why Hybrid Search
Stage 1 runs two searches side by side, a bi-encoder and BM25 keyword matching, because each one misses what the other finds:
| Question contains | BM25 | Bi-encoder | Hybrid |
|---|---|---|---|
| Machine codes, part numbers (CRE-012) | strong | weak | strong |
| Abbreviations (WH FG, QC) | strong | weak | strong |
| Same problem, different words | weak | strong | strong |
| Mixed Indonesian and English | strong | depends on the model | strong |
A bi-encoder turns text into a vector of its meaning. In that space CRE-012 and CRE-021 look almost the same, while to an operator they are two different machines. BM25 matches the exact token, so it gets codes right, but it cannot tell that “kemasan kembung” and “bloated packaging” describe the same problem. Together they cover both.
The two result lists are merged with Reciprocal Rank Fusion: each case scores 1 / (60 + its rank) in each list, and the scores are added. It needs no tuning, and the reranker in stage 2 decides the final order anyway. BM25 over the whole library takes milliseconds, so keeping it costs almost nothing.
Hybrid search stays only while the gold set says it helps. Stage 1 is tested three ways (BM25 only, bi-encoder only, and hybrid), with results split by question type, because an overall average can hide the case that matters most: a missed machine code is exactly the answer an operator acts on.
3. Evaluation
Every change is tested against a gold set: real operator questions, each labelled with its intent, the case IDs that should be found, and a reference answer. It includes the hard ones, such as machine codes, mixed Indonesian and English, abbreviations, and questions with no matching case, where the right answer is “not found”.
Each stage is measured on its own, so a bad answer can be traced to the step that caused it:
| Stage | Metric | What it tells us |
|---|---|---|
| Jev | Intent accuracy | Did the question go to the right intent? |
| Stage 1 | Recall@300 | Is the right case anywhere in the candidates? If not, nothing later can fix it. |
| Stage 2 | Recall@10, MRR | Did the reranker move the right case into the top 10, and how close to the top? |
| Stage 2 | Context precision (Ragas) | Are the useful cases ranked above the noise? |
| Stage 2 | Context recall (Ragas) | Do the 10 cases hold everything needed to answer? |
| Answer | Faithfulness (Ragas) | Is every claim in the answer backed by a retrieved case? |
| Answer | Answer relevancy (Ragas) | Does the answer address the question asked? |
| Answer | LLM judge, 1 to 5 | Is it correct and useful? Anything under 4 fails. |
| System | p95 latency, cost | Is it still fast and cheap enough? |
Recall@k and MRR are computed exactly from the labelled case IDs. Ragas scores the parts that need judgement, using a judge model that is different from the one writing the answers. All scores are logged to Langfuse against the trace of each run, one span per stage, so two versions can be compared side by side.
Figure 4: The Langfuse trace view we use: a list of traces on the left, the span tree of one trace in the middle, and its input and output on the right.
4. Improving It With Data
4.1. Finding Where Answers Fail
The first version had a single retrieval stage: the top 10 results from the bi-encoder and BM25 went straight to the model, and every question got the same context. Before changing anything, we sorted the failed gold-set answers by cause:
Figure 5: Causes of failed answers in the single-stage version.
Each cause points at a different fix. Cases that were retrieved but ranked too low called for a reranker. Wrong formats (a troubleshooting table for a “how do I” question) called for knowing the intent. Cases never retrieved at all called for better queries.
4.2. From One Stage to Two
The changes went in one at a time, and each was kept only if the gold set improved:
- v1: single stage, top 10 from the bi-encoder and BM25.
- v2: two stages, top 300 from stage 1, reranked by the cross-encoder down to 10.
- v3: v2 plus Jev for intent and the query rewrite from user preferences.
Figure 6: Gold-set scores for each version. The full set of metrics is in the table below.
| Metric | v1 | v2 | v3 |
|---|---|---|---|
| Intent accuracy | - | - | 96% |
| Recall@300 | 88% | 88% | 97% |
| Recall@10 | 61% | 84% | 92% |
| MRR | 0.47 | 0.71 | 0.80 |
| Context precision | 0.48 | 0.74 | 0.83 |
| Context recall | 0.58 | 0.79 | 0.88 |
| Faithfulness | 0.81 | 0.90 | 0.95 |
| Answer relevancy | 0.72 | 0.82 | 0.91 |
| Judge pass (4/5 or more) | 55% | 74% | 88% |
| p95 latency | 2.1 s | 3.4 s | 3.9 s |
The reranker gave the biggest jump: Recall@300 stayed the same from v1 to v2, so the right case was already among the candidates, just not near the top. Jev and the query rewrite then lifted Recall@300 itself, because a rewritten query finds cases the operator’s short question missed. The cost is about 1.8 seconds of extra latency, mostly from reranking 300 candidates.
4.3. Context Engineering
Wording the prompt well mattered less than choosing what goes into the model’s context. Every answer is built from the same parts, assembled fresh for each question:
system rules cite a case for every claim; say "not found" if none fits
user profile line, area, role, language
intent from Jev, with the answer format for that intent
rewritten query the question, expanded with the profile and intent
top 10 cases as structured fields: title, 5M, why-why, CAPA, link
chat summary a short summary of earlier turns, not the full history
The profile is what makes it personal. Two operators asking “kenapa kembung?” on different lines get different cases first, and the answer comes back in their own language.
Each change to the context went through the same loop: run the full gold set, keep it only if the judge pass rate went up without faithfulness going down.
Figure 7: Judge pass rate by context version.
- C1: the question and the top 10 cases as raw text.
- C2: added the user profile, so answers favour the operator’s own line and area.
- C3: added the intent from Jev, with an answer format for each intent, which stopped “how do I” questions getting a 5M table.
- C4: sent cases as structured fields instead of raw text, so the model could find the root cause and the actions without reading whole documents.
- C5: replaced the full chat history with a short summary, which kept follow-up questions on topic without old turns crowding out the cases.
- C6: removed duplicate cases and those with a low reranker score, which made the context shorter and cheaper with no loss in quality.
Most of the gain came from C2 to C4, about 9 points each: knowing who is asking, what kind of answer they need, and giving the model cases in a shape it can use. After that the gains were smaller, and C6 was mainly about cost.
4.4. The Loop
Figure 8: How a reported miss becomes a test, then a fix.
Every miss an operator reports becomes a gold question first, then a fix. The gold set grows with each review cycle, so an old miss cannot quietly come back.
5. Lessons Learned
Factory documents are full of part numbers and machine codes. Pure vector search is bad at exact strings like these, which is why keyword search stays in the mix.
Measure each stage on its own. A single end-to-end score says an answer is bad but not why, and most of our fixes came from knowing which stage failed.


