Blog

AI · Data Engineering

Ordering the Right Part Number: An Evidence-First Assistant for Technical Distributors

Distributors of technical equipment order replacements and spare parts by part number, and the information sits in manufacturer PDFs nobody can search. This assistant reads those PDFs, decodes part numbers from the manufacturers' own configuration tables, and answers with the page every claim came from.

The problem: one character decides the order

A distributor of technical equipment sells and services products from several manufacturers. A large share of the daily work is not selling something new. It is ordering the right replacement or spare part for equipment that is already installed at a customer’s site.

That order is placed by part number, and manufacturers’ part numbers are configuration codes. Each position stands for an option:

  • Electric motors: frame size, voltage, mounting and certification.
  • Pumps: impeller material, seal type and connection standard.
  • Valves: body material, end connection and pressure class.
  • Network switches: port count, power over Ethernet, and the power cord for the destination region.

Two codes that differ in a single character can be two different products, and a wrong order means a return, a second order, and a customer whose equipment stays down in the meantime.

The information needed to get it right exists, but it is spread across manufacturer PDFs: ordering guides with configuration matrices that run over several pages, datasheets whose specification tables have no ruling, compatibility lists, scanned pages, and several editions of the same guide. The distributor’s own product system knows prices and stock, but rarely the technical attributes behind a code. Technicians rely on memory and on searching PDFs by hand.

A general-purpose chatbot makes this worse rather than better. It cannot read a table that spans three pages, it does not say where an answer came from, and it produces part numbers that look right. In this domain an invented part number is the most expensive failure there is.

The design rule: retrieve first, cite everything, never invent a code

The assistant answers technicians’ questions from the indexed documentation and leaves the decision to the technician. Three rules shape every part of it:

  1. Every technical claim cites its source. Each answer ends with the file and page behind every citation, so a technician can open the page before ordering.
  2. Part numbers come from the manufacturer’s tables, not from the model. Decoding, comparing and assembling codes is deterministic code working on tables extracted from the documents. The language model explains the result; it does not produce it.
  3. “Not found” is a valid answer. When nothing in the documentation matches, the assistant says so with a fixed reply. No model is called and no answer is guessed.

What a technician can ask

The examples below use an invented motor series, M200, whose configuration matrix has four positions: frame size (71, 80, 90), voltage (A = 230 V, B = 400 V), mounting (F = foot, L = flange) and certification (EU, US).

  • Decode an installed unit. “What is M200-80BFEU?” The answer lists each position with its meaning (frame 80, 400 V, foot mounting, EU certification) and cites the matrix rows it used.
  • Compare two codes. “The customer has M200-80BFEU and the quote says M200-80BLEU. What is the difference?” Only the mounting position differs: foot against flange. For a replacement that difference decides whether the part fits.
  • Build a code from requirements. “Which configuration is a 400 V flange-mounted motor in frame 90?” The result is M200-90BL followed by the certification position, which the question did not decide. That position is left open, and its options are listed instead of being chosen.
  • Ask about the documentation in plain language. “Which seal options does this pump series list for hot water?” or “Compare the pressure rating of these two valves.” The answer comes from the retrieved passages and tables, each claim cited.

Follow-up questions keep their context. “And its operating temperature?” is understood as a question about the product named in the previous turn.

Reading manufacturer PDFs properly

Most of the value is in tables, and most PDF pipelines destroy tables. The ingestion step treats them as first-class content.

  • Two detection strategies. Ruled tables are read from their drawn lines. For datasheets, where specification tables are often only aligned text, a second strategy detects whitespace-aligned columns. Cells are rebuilt from whole words, so a column edge never cuts a word in half, and no word is dropped or duplicated between table and prose.
  • Tables that span pages are stitched back together. A table on the next page continues the previous one when the column count matches, the first table reaches the bottom of its page, the second starts at the top of the next, and the left and right edges line up. A row that looks like the header of a different table ends the chain.
  • Long tables are split for retrieval, with the header repeated in every part. A row is never split. When one part of a table is used in an answer, its sibling parts are added as far as the evidence budget allows. A value 200 rows into a matrix is still read with its column names.
  • Every chunk knows its section. The heading in effect where a chunk starts is stored with it. Running headers and footers, lines made only of codes, and rows of part-number lists are not mistaken for headings.
  • Scanned pages are not lost. A page with no table and almost no text layer is rasterised and run through OCR, and the recognised text is kept only when it is longer than what the text layer had.
  • New editions replace old ones. A changed file with the same name from the same manufacturer becomes a new revision, and the older one is marked superseded. Superseded documents stay in the database for audit but never appear in answers.

Turning tables into part numbers

Manufacturers publish part numbers in two forms, and both are handled.

Enumerated lists. Many guides list every orderable code with a short description. These lists are found in the extracted text, parsed with patterns per manufacturer, and stored as a variant catalogue. A model derives a few attributes per code from its description, in batches, plus a legend of what each code segment means. Re-running costs nothing for codes whose stored row has not changed.

Configuration matrices. Other guides describe the structure instead: position 1 is the frame size with these options, position 2 the voltage, and so on. Here a model proposes the positions, their widths and their options, and the proposal is then checked without any model:

  • Structure. Positions are numbered without gaps, widths are positive, and every option code is exactly as long as its position.
  • Grounding. The base model must appear in the table or its section title, and every option’s code and meaning must be cells of one row of the source table. Nothing the model adds from its own knowledge survives this check.
  • Proof. A matrix is marked verified only when the example part number printed in the document decodes correctly against the stored positions.

Decoding a code then follows a fixed order: a verified matrix that decodes it uniquely; otherwise an exact entry in the enumerated list; otherwise a clear “not in the catalogue”, with up to eight codes of the same base model as suggestions. When two stored matrices could apply, the result is reported as ambiguous and nothing is guessed.

The reverse direction, from requirements to a code, matches the question’s terms against option meanings. A term selects an option only when it matches exactly one option at that position. Positions the question does not settle stay open. An assembled code is always labelled as configured from the manufacturer’s matrix, and the answer rules forbid presenting it as a confirmed, stocked or orderable item. Availability is a question for the distributor’s own systems.

Finding the evidence

Questions about equipment mix paraphrase (“waterproof”, “for outdoor use”) with exact identifiers (a part number, a pressure class, an interface name). One search method does not cover both.

  • Hybrid search. A vector search over multilingual embeddings in PostgreSQL with pgvector finds passages that mean the same thing in other words. A full-text search in PostgreSQL finds exact codes and acronyms; a hyphenated part number contributes each of its parts. The two ranked lists are merged with reciprocal-rank fusion, which combines ranks rather than scores, because the two scores are on different scales.
  • Reranking. A cross-encoder model then scores each passage against the question and reorders the merged list. It is never a hard dependency: if it is down, the fused order is used.
  • Comparison questions are split. “Compare A and B” searched as one query lets the better-documented product crowd out the other. When a question names two or more products or contains a comparison cue, it is split into one sub-query per product. Each sub-query reserves a place in the final evidence for a passage of its own. Single-product questions skip this step and its model call.

Answers that can be checked

  • An evidence budget. The prompt receives at most 24 passages, filled in priority order: reranked search results, the source passages of structured attributes, the matrix rows behind a decoded code, and the sibling parts of split tables.
  • Citations are enforced after the fact. Citation markers are normalised, and a citation that points to a passage that was not in the evidence is removed and logged.
  • The sources list is written by the pipeline, not the model. The model cannot invent a file name or a page number.

Documents are untrusted input

Manufacturer PDFs, supplier files and customer documents are text from outside, and text can contain instructions. Every request wraps each passage in delimiters that carry a random token generated for that request, and the model is told that anything inside them is data. Characters that could break out of the delimiters are escaped, and lines that imitate a chat role or a prompt section are marked as document text.

The output is filtered too. Links and images are reduced to their text unless the host is on an allow-list, and no HTML tag survives. The filter gives the same result whether the answer arrives in one piece or as a stream of tokens. Whether a particular model ignores an instruction hidden in a document is model behaviour. The delimiters and the output filter limit what such an instruction could achieve.

Running it

The system is a set of containers: a retrieval and answer service with an OpenAI-compatible API, a worker that ingests documents and extracts the variant lists and matrices, PostgreSQL with pgvector, an object store for the original PDFs, a model gateway, a reranker, a chat front-end and an analytics dashboard.

  • Models. All chat models are served through Ollama behind a LiteLLM gateway. Each one runs either on the host or in Ollama’s cloud, and no provider API key exists anywhere in the stack. For documentation that must not leave the premises, every model call can be pointed at on-host models.
  • Model choice per question. The front-end offers several assistant variants. They share the same retrieval, decoding and citation pipeline and differ only in the answer model, so models can be compared on real questions.
  • An audit trail. Every request writes one row: the question, the answer, the passages retrieved and cited, the model that answered, the time spent in each stage, and the outcome (answered, no evidence, failed, disconnected). Feedback on an answer (useful or not) is recorded against the same id.
  • A dashboard. Read-only views over the audit log feed a dashboard of volume, latency, model mix, retrieval health and feedback. Questions that found no evidence show where the documentation has gaps.

The SQL that the services run is executed in the test suite against a throwaway PostgreSQL, on a fresh schema and on an upgraded one. The table detection has its own evaluation: a list of tables that must be found in the sample documents, and the run fails when one is missed.

What is not built yet

This is a working proof of concept, not a finished product.

  • Product catalogue import. The import from the distributor’s own product system is not built, so codes are not yet joined with prices and stock.
  • Document attributes and review. Attributes are not yet extracted from documents into structured, filterable fields, and the human review workflow for them is still to come.
  • Answer-quality evaluation. There is no evaluation set for answer quality yet. The existing evaluation covers table detection.
  • Scanned tables. OCR pages produce text only, so a configuration matrix that exists only as a scan is not decoded.
  • Order and invoice checking. Checking that an order and its invoice match the requested parts is a separate, later phase that builds on this foundation.

What carries over

None of this is specific to one kind of equipment. The same principles apply to any system that must turn manufacturer documentation into decisions with consequences:

  • Do not let a model generate identifiers. Extract them from source tables, verify them against the document’s own examples, and let the model explain the result.
  • Treat tables as data. Stitch them across pages, repeat their headers, and retrieve them whole.
  • Combine meaning-based and exact-match search. Part numbers and paraphrases need different retrieval.
  • Make every answer checkable. Cite the page, write the source list in code, and prefer “not found” to a plausible guess.
  • Log every answer. The audit trail is what turns a demo into something a distributor can trust and improve.

Ordering parts from documentation nobody can search? Get in touch with the current setup, constraints and goals.