Fill in the form: AI Engineering, story 4
HM Nayem writes one friendly sentence asking to return a jacket. Watch it become a form that software can act on.
The model picks words by weighted chance, so code asks for a fixed shape, checks it, and retries.
The story, step by step
HM Nayem wants to return a jacket
HM Nayem writes to the shop the way anyone would: one friendly sentence. But this message is not for a person. It has to end up in the shop's returns system.
Software wants a form
The returns system cannot read sentences. It needs a form: an order number, an item, and a reason picked from a fixed list. Something has to turn those words into fields.
A language software can read
Programs pass data to each other in strict formats. The most common is called JSON: names on the left, values on the right, wrapped in braces. If one bracket or one value is off, the program receiving it gives up.
Ask the model for the form
So the server asks the model to do the reading. Its instructions say exactly what shape to reply in: a small block of structured text called JSON, with three named fields.
How it chooses each word
Remember, a model writes by guessing the next token. Each guess is a set of odds, and it rolls weighted dice. Usually the most likely token wins. Not always.
Sometimes the dice land badly
This time an unlikely token wins, and the reason comes back as a phrase instead of one of the allowed values. It reads fine to a person. The returns system would reject it.
Check, then ask again
Good code never trusts the reply. The server checks every field against the rules. When one fails, it sends the model its own answer back with the error, and asks again.
Dial one: temperature
Every model call has a setting called temperature. Turned up, unlikely tokens get more of a chance, which suits creative writing. Turned down to zero, the model takes the likeliest token every time. For filling in forms, zero is what you want.
Dial two: a shape it must follow
Many providers go further. The server hands over the exact shape it needs, and the model is only allowed to pick tokens that fit it. A reason outside the list becomes impossible, not just unlikely.
A form the system accepts
The second reply passes every check. The server hands it to the returns system, which finally has what it needs. HM Nayem's sentence has become data.
Now at real speed
Read, check, retry, file. A model turning messy human words into clean data that software can act on is behind a huge share of real AI products.
That is how words become data.
- Software needs named fields, so the model is asked for an exact shape.
- The model picks each token by weighted chance, so it is sometimes wrong.
- The server checks every reply and asks again when a check fails.
- Temperature zero and an enforced shape make failures rare.
Ideas in this story
- Chance and temperature: The model picks each token by weighted chance. Temperature sets how adventurous it is.
- Structured output: Getting a reply in a fixed shape that code can read, checking it, and retrying when it is wrong.