EDI processing with GPT-3.5

Carlos Ortiz Urshela
Sounds klever
Published in
3 min readDec 19, 2022

--

Last night, I remembered how long it took me (more than one year) to develop from scratch using Java, XSLT, and other tools, an EDI translator and generator for a shipping container terminal where I worked for almost 18 years.

After remembering how complex and lengthy it was to build that processor, I asked myself. Could GPT-3 understand and generate EDI (the data format shipping lines and container terminals use to exchange logistic and operational information) so that building an EDI processor could take days, not months?

Well, I went to bed with that idea and determined to test the next day whether GPT-3 could reduce the time and cost of creating an EDI processor.

A bit of EDI background.

Electronic Data Interchange (EDI) is a structured method of exchanging business data between two or more organizations. It is used to process transactions electronically and accurately transfer data between partners such as suppliers, customers, and logistics providers.

EDI is an essential part of the global logistics industry, allowing companies like container terminals and shipping lines to quickly and accurately exchange data and process transactions in a timely and cost-effective manner.

With the help of GPT-3.5, I created an EDI processor in just five minutes!

This morning after jogging for 1 hour, I built a preprocessor for Booking confirmation (IFTMBC) EDI messages (one of the messages with the highest volume of interchange between shipping lines and container terminals) in just five minutes using OpenAI’s GPT-3.5 (text-davinci-003):

To instruct the model, I told it that it was an EDI preprocessor specialized in information retrieval from IFTMBC messages.

Then I completed the prompt with a real IFTMBC sample message from the Hamburg SUD web page.

And finally, I asked the model to extract key information from the message.

Look at the prompt 👀:

You are an EDI message translator specialized in extracting information 
from IFTMBC EDI files in the EDIFACT standard.

UNB+UNOC:3+SUDU+FMS+170711:1300+2538
UNH+2546+IFTMBC:D:99B:UN
BGM+770+174662531+6+AP
CTA+CW+:TINA ARAGHI
COM+-49–40–37050:TE
COM+-49–40–37052560:FX
COM+tina.araghi@hamburgsud.com:EM
DTM+137:201707111258:203
TSR+30
FTX+AAI+++BUCHUNG VORBEHATLICH IMO AKZEPT DES REEDERS!
GDS+11
GDS+15
RFF+CT:REUR600505
RFF+FF:5116027070020
RFF+SI:5116027070020
RFF+BN:7HAMSA2192
TDT+20+729S+1+8:MAIN CARRIAGE+SUDU:172:182+++9214202::11:E.R.LONDON:LR
LOC+9+NLRTM:139:6:ROTTERDAM NL
DTM+133:20170720:102
DTM+180:201707182200:203
LOC+11+BRRIO:139:6:RIO DE JANEIRO BR
DTM+132:20170809:102
NAD+CA+SUDU:160:87+HAMBURG SUED
NAD+CZ++FR. MEYER?S SOHN (GMBH & CO.) KG++GRUENER DEICH 19+++20097+DE
CTA+IC+:ESMAHAN AKYOL
COM+?+49 40 2393 1244:TE
COM+?+49 40 2393 2049:FX
COM+ESMAHAN.AKYOL@FMS-LOGISTICS.COM:EM
NAD+FW++FR. MEYER?'S SOHN (GMBH & CO.) KG++GRUENER DEICH19+++20097+DE
CTA+IC+:ESMAHAN AKYOL
COM+?+49 40 2393 1244:TE
COM+?+49 40 2393 2049:FX
COM+ESMAHAN.AKYOL@FMS-LOGISTICS.COM:EM
NAD+FC++FR. MEYER?'S SOHN (GMBH & CO.) KG
CTA+IC+:N/A
COM+-:TE
GID+1+1:PK:67:6:PACKAGE
FTX+AAA+++CHEMICALS?:(NOS)
MEA+AAE+G+KGM:55400
DGS+IMD+8+2735++2
FTX+AAD++PSN:122:ZZZ+AMINES, LIQUID, CORROSIVE, N.O.S.
FTX+AAD++TN:122:ZZZ+1-tetradecylamine, n,n-dimethyl, IMDG-CODE
SEGREGATION GROUP - N1 8 ALKALIS
FTX+AAC++LQD:122:ZZZ
FTX+AAC++P:122:ZZZ
FTX+PKG++31H:183:ZZZ
CTA+HE+:N/A
COM+N/A:TE
MEA+AAE+AAF+KGM:14400
EQD+CN++22GP:102:5
EQN+2:2
TMD+3++MM
MEA+AAE+AAL+KGM:55400
NAD+CK++KRAMER GROUP++MISSOURIWEG 17
DTM+392:201707060800:203
NAD+TR++ECT DELTA DDN++EUROPAWEG 875:MAASVLAKTE
DTM+180:201707181000:203
UNT+56+2546
UNZ+1+2538

Extract the following information:
1. Consignee name
2. Number of containers?
3. Commodities
4. Does this Booking include hazardous cargo?

Answer:

Then, look at what I got back:

1. Fr. Meyer's Sohn (GmbH & Co.) KG 
2. 2 containers
3. Amines, Liquid, Corrosive, N.O.S., 1-Tetradecylamine, N,N-Dimethyl, IMDG-Code Segregation Group - N1 8 Alkalis
4. Yes, this booking includes hazardous cargo.

Amazing 🤩 😎🥳

Now, I can’t stop thinking about the vast opportunities to extend this simple approach to processing EDI in logistic companies of all sizes.

We have reached the end of the post. I hope this article has been helpful. Feel free to DM me if you want to know more details or want my help in developing a prototype. Please add your comments if you have any questions.

Thanks for reading!

Stay tuned for more content about GPT-3, NLP, System design, and AI in general. I’m the CTO of an Engineering services company called Klever, you can visit our page and follow us on LinkedIn too.

--

--

Carlos Ortiz Urshela
Sounds klever

Machine Learning Engineer | Enterprise Solutions Architect — Interested in AI-based solutions to problems in healthcare, logistics, and HR. CTO of Klever.