Independent Submission
Implementation Report: 2610-2.2
Category: Standards Track
I. S. Hudzaifah
Bandung, Indonesia
2026

← Section 2, Implementations

Implementation Report: ai-ebook

Abstract

An assistant that answers production questions from thousands of factory documents in seconds, with a link to the exact source.

See Tech Stack and Architecture.

Status of This Implementation

This implementation is in production use and actively maintained.

Tech Stack

Backend and agentGo (Gin)
Web appAngular
CMSPayload CMS on Next.js, where cases are written
Content databaseMongoDB (behind Payload)
App databasePostgreSQL
IntentJev, a decision model API
Retrievalbi-encoder (pgvector) + BM25, then a cross-encoder reranker
LLMGemini, through a LiteLLM gateway
EvaluationRagas, Langfuse, a labelled gold set
ObservabilityOpenTelemetry, one span per answer

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.

ai-ebook answer

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:

ai-ebook architecture

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.

ai-ebook case library

Figure 3: The case library, with 781 cases across business units and support departments, organised by area. Photos are blurred.

Stage 1 runs two searches side by side, a bi-encoder and BM25 keyword matching, because each one misses what the other finds:

Question containsBM25Bi-encoderHybrid
Machine codes, part numbers (CRE-012)strongweakstrong
Abbreviations (WH FG, QC)strongweakstrong
Same problem, different wordsweakstrongstrong
Mixed Indonesian and Englishstrongdepends on the modelstrong

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:

StageMetricWhat it tells us
JevIntent accuracyDid the question go to the right intent?
Stage 1Recall@300Is the right case anywhere in the candidates? If not, nothing later can fix it.
Stage 2Recall@10, MRRDid the reranker move the right case into the top 10, and how close to the top?
Stage 2Context precision (Ragas)Are the useful cases ranked above the noise?
Stage 2Context recall (Ragas)Do the 10 cases hold everything needed to answer?
AnswerFaithfulness (Ragas)Is every claim in the answer backed by a retrieved case?
AnswerAnswer relevancy (Ragas)Does the answer address the question asked?
AnswerLLM judge, 1 to 5Is it correct and useful? Anything under 4 fails.
Systemp95 latency, costIs 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.

Langfuse trace view

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:

Causes of failed answers

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:

Gold-set scores by version

Figure 6: Gold-set scores for each version. The full set of metrics is in the table below.

Metricv1v2v3
Intent accuracy--96%
Recall@30088%88%97%
Recall@1061%84%92%
MRR0.470.710.80
Context precision0.480.740.83
Context recall0.580.790.88
Faithfulness0.810.900.95
Answer relevancy0.720.820.91
Judge pass (4/5 or more)55%74%88%
p95 latency2.1 s3.4 s3.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.

Judge pass rate by context version

Figure 7: Judge pass rate by context version.

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

ai-ebook improvement 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.

HudzaifahStandards Track[Page 1]