← Portfolio

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.

edi.askX12
Business userWhat are the net terms on invoice 4471?
  1. 1 May · 850Purchase order received
  2. 3 May · 997Functional acknowledgement
  3. 5 May · 810Invoice 4471 · ITD segment read
AnswerInvoice 4471 is on net 30 terms, taken from the ITD segment of its 810.
Illustration
At a glance
ResultAsk the EDI in plain English
BeforeBusiness and EDI teams speak different languages; Rejected transactions decoded by hand; No view of where an order is stuck
StackEDI, X12, LLM Fine-Tuning, SAP IDoc
Related serviceForward-deployed AI engineers

What problem did the client have?

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 did we build?

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 does it hold up in production?

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.

First-Sprint Data Scientist

A vetted engineer embedded in your team, a shipped deliverable by end of sprint 1.

Pick a time below and 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.

Book a call

Cat Yung

Hong Kong & London time zones

Book a call · 30 min with Cat Yung