Sourced answers from maintenance documents: building a local AI assistant
Design a local maintenance assistant with Turkish OCR, provenance and human review: workflow infographic, open-source tools, data contracts and implementable acceptance tests.
Share via QR code

Answering a maintenance question matters. Showing which document and table row support the answer matters just as much. This guide turns the concept into a workflow a person can understand and a concrete contract an implementing AI can build.
Preserve the source address first; then retrieve evidence, validate the answer and make human verification easier.
13 November 2026 · Conceptual design and implementation guide. Thresholds are proposals and examples are synthetic. No completed customer pilot, field acceptance or measured time saving is claimed.
Turn a maintenance question into verifiable information work
A maintenance engineer looking for the correct record form, technical explanation or inspection condition may face several PDFs, scans and revisions. Finding a relevant sentence is only part of the job. The document must apply to the equipment, the appropriate revision must be selected, and a value in a table must belong to the correct row. Fluent prose does not establish any of these conditions.
The product concept is a local assistant that directs the engineer’s question to selected maintenance documents. It presents a short answer together with a quotation and an openable source location. Its initial scope is information access and human decision preparation. It issues no plant commands or automatic work orders. We measure value from asking a question through verifying its answer against the source.
This article is a construction guide and proposed acceptance contract. The existing local RAG foundation targets text-layer documents; the complete OCR, table-location, access-control and human-review workflow described here is not claimed as delivered. No real plant data, customer outcome or measured performance is presented.
What OCR, RAG and provenance each contribute
| Concept | What it does | What it does not establish by itself |
|---|---|---|
| OCR | Converts the image of a scanned page into machine-readable text. | Correct recognition or association with the right table cell. |
| RAG | Retrieves relevant source passages and gives that evidence to a generating model. | Whether a passage is current, authorized and actually supports the claim. |
| Provenance | Preserves document version, file hash, page and text or cell location. | Whether the source itself is correct in the physical world. |
An embedding is a numerical representation used to search by semantic similarity. A chunk is a small unit of indexed content. In a maintenance manual, the sentence alone may be insufficient: a section heading, equipment identifier, column header and footnote can all affect its meaning. Flattening a PDF into plain text can discard relationships that are difficult to recover later.
DoclingDocument can represent text, tables, hierarchy and, when available, locations and provenance. This helps the design, but does not guarantee perfect cell coordinates for every document. Missing locations must be explicit. A page-level citation must not be presented as verified cell-level precision. DoclingDocument
Infographic: prepare documents, then answer questions
The first workflow prepares a searchable corpus. The second uses only ready sources that the user may access. Poor extraction, insufficient evidence and an inconsistent answer produce different outcomes. This separation helps the reader understand what happened and helps the developer repair the correct component.
When document review produces a correction, preserve the original file and process the correction as a new extraction revision. When evidence is missing, ask for another document or a clearer scope. When applicable sources conflict, expose that distinction instead of silently selecting one. A draft that fails citation checks must not appear as a verified answer.
The three screens a person needs
1. Select the question and scope
The engineer chooses equipment, a document collection and, when needed, a revision date. A question might be: “What is the record form code for P-101?” The active scope stays visible, while the server enforces access.
2. Read the answer with evidence
The screen shows a concise answer, evidence for each claim, document versions and review status. “Insufficient evidence” and “Sources conflict” are normal outcomes. Do not display an uncalibrated confidence percentage.
3. Open and assess the source
The link opens the correct page of the original PDF and highlights the relevant item or cell when a verified location exists. The engineer can accept the answer or report an error with a reason. The review binds to a particular answer and source version.
Turkish and English interfaces must preserve the question, selected equipment and source scope. Original quotations and part identifiers remain unchanged. If a translation is offered, show it separately and label it as an interpretation alongside the original. Mobile source access, visible keyboard focus and readable help content are part of the product design.
Open-source technologies and why we would use them
| Component | Role and license | Decision |
|---|---|---|
| Docling | Document structure and conversion; MIT code license. | Build on the existing foundation; inventory model licenses separately. |
| Tesseract | OCR engine; Apache-2.0. Turkish language data exists. | Initial baseline for Turkish and English scans. |
| Haystack | Retrieval and generation pipeline orchestration; Apache-2.0. | Measure each stage’s inputs, outputs and failures. |
| PostgreSQL + pgvector | Versioned records and vector search; PostgreSQL license. | Start with exact search over the authorized small corpus. |
| Ollama | Local model runtime; MIT. | Disable cloud features and pin the model digest. |
| FastAPI + Pydantic | HTTP boundary and data-contract validation; MIT. | Enforce identity, scope, schemas and errors outside the model. |
| PaddleOCR | Alternative OCR experiment; Apache-2.0 code license. | Evaluate if it improves the same test set; not a mandatory additional service. |
Source code and license references are linked below. MIT, Apache-2.0 and PostgreSQL licenses permit commercial use subject to their notice and distribution conditions. A library license does not automatically cover every downloaded model or dataset. Docling · Tesseract · Haystack · pgvector · PostgreSQL · Ollama · FastAPI · Pydantic · PaddleOCR
Tesseract documents tur language data, and PaddleOCR documents Turkish recognition in PP-OCRv5. Language support is not an accuracy guarantee for our scans. Compare the same clean and degraded examples. Tesseract · PaddleOCR
BGE-M3 embeddings and Qwen3 4B Instruct are separate model artifacts in the existing foundation. Their model card and selected distribution identify MIT and Apache-2.0 respectively. Treat downloadable weights separately from the open-source runtime: record exact revision, hash, quantization and usage terms in a model inventory. BAAI/bge-m3 · Qwen3 4B Instruct
Document admission: readable does not mean ready
Admission validates file type, byte size, page limits, workspace and access scope. Compute a SHA-256 hash; identical bytes with the same extraction revision should not create another ingestion. A hash establishes that the bytes are unchanged, not that the content is true. Keep the original PDF read-only.
Use native extraction when a usable text layer exists. Route scanned pages or broken text layers through OCR. Configure Turkish and, where needed, English language data explicitly. Test dotted and dotless I, Turkish characters, part codes, decimal commas, minus signs and units. Recognizing the value 12 is insufficient if it is attached to the wrong equipment row.
| State | Searchable? | Next action |
|---|---|---|
| received / processing | No | Validate limits and finish the durable job and extraction. |
| needs_review | No | A human reviews the exact extraction revision; corrections produce a new revision. |
| ready | Within authorized scope | Preserve the usable version and its provenance. |
| superseded | Not in default current searches | Expose only through an explicit, authorized historical query. |
| rejected / failed | No | Record the reason; bounded, traceable retries apply to technical failures. |
Upload time alone does not determine which document governs. Use applicability dates, equipment scope and explicit supersession. If two approved sources for the same scope disagree, preserve the conflict until a responsible person resolves it. A low OCR score can trigger review, but do not invent one unmeasured threshold for every engine and document class.
The source contract: every fragment needs an address
Each text passage or table cell belongs to a workspace, document and immutable version. PDF page order and the printed page label are separate fields: a cover can make PDF page three carry the printed label “2”. Page indices are one-based; table rows and columns are zero-based. Coordinates require an explicit origin, scale and transformation rule.
{
"schema_version": "source-item/1",
"data_kind": "synthetic",
"workspace_id": "demo",
"document_id": "SYN-P101",
"document_version": "rev2",
"asset_ids": [
"P-101"
],
"sha256": "<compute from actual PDF bytes>",
"page_index": 3,
"printed_page_label": "2",
"item_id": "t1-r0-c1",
"locator": {
"kind": "table",
"table_id": "t1",
"row": 0,
"column": 1,
"bbox": null
},
"raw_text": "BK-17",
"column_header": "Kayıt formu",
"row_header": "P-101",
"extraction_revision": "ocr-layout-1",
"review_status": "ready"
}Leave bbox null when coordinates are unavailable; do not fabricate a highlight rectangle. Keep normalized retrieval text separate from original extracted quotation text. When chunking tables, retain column headers, row labels, the table title and material footnotes. Preserve row_span and column_span for merged cells. Never combine different documents or revisions into a single source item.
Test this contract with the database schema and source viewer. Opening the same page number in another revision is an error. Deleting a source or revoking access must also affect answers, exports and caches that depend on it.
Retrieval: scope before similarity
Start with lexical and equipment-code matching. Then add embeddings and compare both approaches on the same tasks. Identifiers such as BK-17 may benefit from lexical matching; differently worded questions may benefit from semantic retrieval. Initial experiments can retrieve 20 candidates from each channel, combine them with reciprocal-rank fusion using a constant of 60, and pass six items into context. These are experimental parameters, tuned only on development data.
Every retrieval path enforces the workspace derived from identity, access scope, equipment and eligible source versions. A client-supplied workspace_id is not authorization. Do not let a model see unauthorized material and expect it to redact the answer. Exact vector search is an understandable small-corpus baseline. When adding approximate indexes, remeasure filtered retrieval behavior and isolation. pgvector
Measure retrieval before generation. Report whether the gold source appears in the first k results, together with wrong-equipment and outdated-revision matches. If the correct evidence never reaches the model, a larger model has not fixed the underlying issue. Haystack’s evaluation documentation distinguishes component-level and end-to-end measurement. Haystack
Answers: bind every claim to evidence
Give the local model only bounded, authorized evidence and task instructions. Documents are data: a PDF paragraph telling the model to ignore its rules grants no additional authority. Require a validated output contract rather than unconstrained prose. Every claim has at least one evidence location; invented source identifiers are rejected.
{
"schema_version": "maintenance-answer/1",
"answer_id": "example-only",
"status": "answered",
"corpus_revision": "demo-corpus-1",
"model_revision": "<verified digest>",
"prompt_revision": "answer-1",
"review_status": "pending",
"statements": [
{
"text": "P-101 kayıt formu BK-17 olarak belirtilmiş.",
"evidence": [
{
"source_id": "SYN-P101",
"document_version": "rev2",
"sha256": "<actual 64-character SHA-256>",
"page_index": 3,
"quote": "BK-17",
"locator": {
"kind": "table",
"item_id": "t1-r0-c1",
"row": 0,
"column": 1
}
}
]
}
]
}answered means that a draft passed automatic gates; human acceptance is recorded separately in review_status. insufficient_evidence means that supporting material is missing, conflicting_evidence means that a contradiction remains unresolved, and needs_review means that a generated draft failed validation. These three outcomes have an empty publishable statements array. Restricted job records may hold review drafts and conflicting evidence for authorized inspection.
After schema validation, check document/version/page identity, quotation membership, and the row context of numbers and units. Finding a number inside a quotation does not prove the answer’s interpretation of that number. Negation, conditions, exceptions and wrong-equipment association require semantic assessment. Automatic checks are not human acceptance.
# Design pseudocode: implement and test these functions.
scope = authorize_request(identity, selected_workspace)
snapshot = freeze_versions(scope, selected_assets, selected_documents)
evidence = retrieve_ready_sources(question, scope, snapshot)
if not evidence:
return empty_answer("insufficient_evidence")
if has_unresolved_conflict(evidence):
return empty_answer("conflicting_evidence")
draft = generate_local(question, evidence, pinned_model, pinned_prompt)
if not schema_and_provenance_checks(draft, evidence):
save_restricted_review_draft(draft)
return empty_answer("needs_review")
recheck_permissions(identity, evidence)
return save_answer(draft, review_status="pending")Service boundaries and error contracts for the implementer
| Endpoint | Responsibility |
|---|---|
| POST /documents | Authorized upload, idempotency key, 202 and job_id. |
| GET /jobs/{id} | Scoped status and failure reason; never expose a partially searchable corpus. |
| POST /documents/{id}/versions/{version}/reviews | Human review of an exact extraction revision with concurrency checks. |
| POST /answers | Question and selected sources within identity scope; fixed corpus/model/prompt snapshot. |
| GET /answers/{id} | Return the validated result after rechecking current permissions. |
| GET /sources/{id}/versions/{version}/pages/{page} | Exact source revision; access control on every read. |
| POST /answers/{id}/reviews | Append-only human decision bound to answer hash and source versions. |
Use 401 for missing authentication, 403 for forbidden access, 409 for an idempotency or version conflict, 413/415 for upload restrictions, 422 for invalid contracts, and 503 for an unavailable local model. An access error must not disclose restricted titles or document existence. Model failure must not trigger a silent cloud fallback.
Jobs and state are durable. Retrying a worker interrupted during ingestion must not index the same work twice: the version is either completely ready or explicitly failed. Bound retries and timeouts. Never overwrite a previous human decision silently; append a review with answer_id, content hash, source revisions, reviewer identity and timestamp.
Local operation: data boundaries, hardware and maintenance
Prepare packages, OCR language files, embedding and generation models, and required UI assets during setup. Runtime should use these local artifacts throughout. Docling documents model prefetching and explicit remote-service opt-in. OLLAMA_NO_CLOUD=1 is part of the Ollama local-only configuration. Neither setting alone proves that the entire application has no network egress. Docling · Ollama
With outbound networking blocked, exercise upload, OCR, embeddings, question answering, source viewing, evaluation and export. Inspect attempted connections as well as successful ones. Cloud evaluators, telemetry, remote fonts, model downloads or an MCP client connected to a cloud agent can form separate data exits. Operational logs should default to job identifiers, timings and versions rather than full document text.
Start measurements on an existing computer with one user and bounded concurrency; do not declare a RAM or GPU capacity sufficient without measurements. A model file’s disk size is not its runtime memory requirement. Context length, OCR models, page counts and concurrent requests affect memory and latency. Record OCR duration, answer p50/p95 latency, peak RAM/VRAM and human-review minutes.
An operable installation preserves package locks, model digests, OCR artifacts, prompts, chunking policy and schema versions. Backups include originals, the database, reviews and permissions. A successful backup command is insufficient: test restoration in an isolated environment and verify that a revoked document remains inaccessible.
Acceptance: measure the work, not fluent prose
For initial technical screening, prepare at least 30 synthetic pages spanning native text, scans, rotated pages, tables, merged cells, Turkish characters, codes and decimals. A person marks the expected evidence independently of the system. In the downloadable recipe, P-101’s rev2 record-form code is BK-17; the superseded rev1 code is BK-11. P-102 has a different row, exposing correct-text/wrong-equipment errors.
Propose a fixed 60-question acceptance set separate from development: 30 answerable, 10 missing-evidence, 10 conflicting-source and 10 forbidden or revoked-access cases. Splitting translations or near-duplicate questions across development and acceptance can inflate performance. Split by document family and question pattern where practical.
| Measure | Initial target |
|---|---|
| Correct supported answers | At least 27 of 30 answerable questions; unnecessary abstentions count as failures. |
| Source location | Every emitted claim resolves to the correct version, page and item/cell in this test set. |
| Numbers and units | Zero wrong number, unit or table-row attribution in emitted claims in this set. |
| Negative cases | Every missing/conflicting/access case returns the expected outcome; no restricted content leaks. |
| Offline and recovery | Complete offline flow, interrupted-job retry and backup restoration are verified. |
| Human work | Compare manual and assisted search, verification and correction time alongside quality. |
Retrieving the right evidence but interpreting it incorrectly is different from never retrieving it. Report OCR character error, cell accuracy, gold-source Recall@k and final supported-answer rate separately. A model judge can supply a supplementary signal; it should not be the sole acceptance authority. Counterbalance task order to reduce the advantage of seeing the same question for a second time.
These gates apply only to the specified test set and do not promise zero future errors. A subsequent customer pilot needs document authorization, a business owner, domain reviewer, measurement period and acceptance decision. Time saved and realized cash savings remain separate outcomes.
Build in six finishable slices
S1 · Sources and contracts
Create synthetic documents, independent gold answers and JSON Schema. Complete a source viewer that opens the correct PDF page and table cell without a model. Exit: swapped source identifiers are rejected.
S2 · Document processing
Add idempotent ingestion, OCR and a human-review queue. Test clean, scanned, rotated and tabular documents separately. Exit: failed extraction never enters the ready corpus.
S3 · Retrieval
Add lexical/code search, then embeddings and fusion. Measure evidence retrieval without generation. Exit: scope and revocation cases pass.
S4 · Answers and abstention
Connect the local model, schema validation and evidence gates. Test known, unknown, conflicting and instruction-injecting documents. Exit: unsupported claims are withheld with an explicit outcome.
S5 · Human experience
Complete bilingual question, answer and source screens with version-bound review. Exit: language changes preserve context; mobile and keyboard paths work.
S6 · Operation and handover
Complete blocked-egress tests, interrupted-job recovery, backup/restore and acceptance reporting. Exit: another implementer can repeat the experiment with the same revisions.
Deliver code, test evidence, source/model revisions and unresolved failure examples with each slice. Add a new OCR engine or larger model only when it improves the same evaluation. This keeps maintenance effort and the cause of changing behavior visible.
The task to give an implementing AI
The following brief and downloadable contracts are inputs to an authorized development session. Inspect the existing code before assuming a new project or parallel infrastructure is needed. Do not present pseudocode as a functioning application or synthetic tests as field outcomes.
Goal: help a maintenance engineer find sourced answers in selected documents.
Inspect repository guidance, versions and the existing working flow first.
Read this article, implementation-spec.json, answer.schema.json and
acceptance-cases.json together; report inconsistencies.
Reuse existing components and work through S1–S6 in order.
First experiment: synthetic data, local services, read-only decision support.
Preserve source revisions, access scope and table-cell relationships.
Derive permissions on the server, never from the client or model.
Return defined states for missing or conflicting evidence; do not invent answers.
Pin package and model revisions; test network egress end to end.
Report independent acceptance cases and failures after every slice.
Deliver code, locks, migrations, setup/recovery instructions,
test evidence and limitations. Never claim an unrun test passed.
This guide does not authorize production access, purchases,
external data transfers or publication; verify the scope of that work.- Implementation contract and delivery slices (JSON)
- Validatable JSON Schema for answers
- Synthetic document recipe and acceptance cases (JSON)
- Editable workflow (Mermaid)
- Workflow infographic (SVG)
The JSON files use English technical field names; both article translations point to the same contracts. The Mermaid file is an editable workflow source. JSON Schema validates structure. Provenance correctness and authorization still require separately tested application code.
What the first-pilot decision actually commits to
The initial choice is to complete information finding and verification for one equipment family. The user gets a concise answer with an openable source; the implementer knows the acceptance condition for each stage. Broader document coverage, heavier models and other data systems can follow evidence from subsequent measurements.
The educational point is that preparation, retrieval, generation, validation and human judgment are different responsibilities. They must work together. Writing down when each is successful gives both people and an implementing AI a firmer basis for building the system.
Sources
Official documentation, repositories and model cards were checked on 13 November 2026. Links can change; pin selected package and model revisions during implementation. Architecture, starting parameters and acceptance targets are Watt2Work proposals for this use case, not vendor guarantees.
- Docling · repository, capabilities and MIT license
- DoclingDocument · structure and provenance
- Docling · offline models and remote-service controls
- Tesseract · engine and Apache-2.0 license
- Tesseract · Turkish language data
- PaddleOCR · repository and Apache-2.0 license
- PaddleOCR · PP-OCRv5 multilingual recognition
- Haystack · repository and Apache-2.0 license
- Haystack · component and end-to-end evaluation
- pgvector · exact search, filtering and PostgreSQL license
- PostgreSQL · license
- Ollama · repository and MIT license
- Ollama · local-only mode and runtime behavior
- BAAI/bge-m3 · model card and MIT license
- Qwen3 4B Instruct · selected distribution and Apache-2.0 license
- FastAPI · source and MIT license
- Pydantic · source and MIT license


