Let it run the numbers: AI Engineering, story 11
HM Nayem uploads a year of orders and asks for the total spent on boots. The model is bad at arithmetic, so it does something smarter.
The model writes code, a locked box runs it, and the result comes back.
The story, step by step
A year of orders
HM Nayem uploads a spreadsheet of last year's orders, 214 rows of them, and asks one question: how much went on boots? The answer is a single exact number.
What is in the file
The file is a plain table: one row for each item bought, with a date, an item, a type and a price. Somewhere in those 214 rows are the boots. The answer means finding every one and adding the prices exactly.
Arithmetic is not its strength
Hand the model all 214 rows and it will give a number. But a model predicts text. It does not calculate. Adding dozens of prices by prediction drifts, and the result looks every bit as confident as a correct one.
A better idea: write a program
So the server offers a different kind of tool: run this code. Now the model does not try to add anything. It writes a short program that would add it, which is something models are very good at.
Not on the shop's own server
That program was written by a model, about a file a stranger uploaded. It could do anything a program can do. So the server never runs it itself. It goes into a sandbox: a sealed, throwaway computer.
It fails the first time
The program crashes. It looked for a column called “category”, and this spreadsheet calls it “type”. The sandbox does not hide that. It sends the error message straight back.
It reads the error and fixes it
The model reads the error like a programmer would, sees the real column names, and writes the program again with one word changed. Nobody at the shop had to step in.
An exact answer
This time it runs. The number is not a prediction. A computer added the prices, so it is simply correct. The result travels back to the model.
Words around the number
The model turns the bare number into a sentence, and it streams to HM Nayem. The model did the thinking and the writing. The computer did the sums. Each did what it is good at.
Now at real speed
Write, run, fail, fix, run, answer. The same loop lets a model make charts, clean data and analyse files far too big to read. All of it inside a box that cannot hurt anything.
The model writes the program. A locked box runs it.
- A model predicts text, so it is unreliable at exact arithmetic.
- Asked to write code instead, it lets a computer do the exact part.
- Model-written code runs in a sandbox with no network and no access to anything else.
- When the code fails, the error goes back and the model fixes it.
Ideas in this story
- Code execution: The model writes a small program and a computer runs it, so exact work is done exactly.
- The sandbox: A sealed, throwaway computer for running code a model wrote.