← All case studies

Ask the EDI in plain English

Natural-Language EDI for a US EDI Solutions Vendor

Business users ask questions of raw X12 — “what are the net terms on invoice 4471?” — and get answers in plain English, from a Llama 3 model fine-tuned on EDI and grounded in the parsed transactions.

The problem

A US EDI vendor’s customers had two teams that did not share a language. The business side talks in invoice and PO numbers; the EDI side talks in 810s, 850s and segment positions. Every question crossed that gap by hand, and the vendor’s existing “plain text” rendering of each transaction was really hard-coded templates, not language anyone could ask questions of.

What we built

A natural-language layer over the vendor’s EDI data: the user asks in business terms, the system resolves them to the right X12 transactions, retrieves the exact segments, and a fine-tuned model writes the answer in English. The same layer links each EDI document to its SAP IDoc counterpart and lays the whole exchange out as a timeline.

Before: Business and EDI teams speak different languages; Rejected transactions decoded by hand; No view of where an order is stuck. After: Ask the EDI in plain English.

Before

  • Business and EDI teams speak different languages
  • Rejected transactions decoded by hand
  • No view of where an order is stuck

How it works

  1. Parse, keeping order. X12 files are parsed interchange → functional group → transaction (850 purchase order, 997 acknowledgement, 810 invoice) into JSON. Element order inside each segment is kept exactly, because in X12 position is meaning.

  2. Store beside the existing index. Parsed documents live in a document store next to the Elasticsearch index the vendor already ran, so nothing upstream had to change.

  3. Map business terms to transactions. An invoice number resolves to its 810, a PO number to its 850, and the question becomes a lookup over the right transaction set rather than a free-text search.

  4. Fine-tune the model on EDI. Llama 3 in 4-bit via Unsloth, trained in stages: supervised fine-tuning on EDI vocabulary and on turning retrieved segments into answers, then ORPO preference tuning for EDI ↔ English translation.

  5. Link EDI to SAP IDocs. An EDI document and an IDoc are matched when their PO or invoice numbers agree and their sender and receiver IDs resolve to the same trading partners in a company dictionary.

  6. Draw the timeline. Once linked, every timestamp becomes an event — 850 on 1 May, 997 on 3 May, 810 on 5 May — plotted as a graph, so a stuck order is visible at a glance.

After

Ask the EDI in plain English

Stack

EDIX12LLM Fine-TuningSAP IDoc

Why it holds up

The model is allowed to explain, never to decide. Parsing, matching and partner resolution are deterministic and auditable; the language model only reads what retrieval hands it and writes it in English. That split is what makes it safe to put an LLM in front of a supply chain’s system of record.

Related service: Forward-deployed AI engineers

Get started

Talk to the engineer who will build it.

You will speak with me directly. Bring the use case, the data and the constraints, and I will give you a straight view on feasibility, effort and the first thing to ship.

Cat YungBook a call

Hong Kong & London time zones