GPT-3 in Production: Latency, Prompts, and a Score You Can Trust
The key worked on a Thursday in July. Someone pasted a ticket into the playground, davinci wrote a reply that sounded like our best agent, and the room decided we should ship it. The handler was small. max_tokens=256, temperature=0, model davinci. The demo took about as long as a sip of coffee. The same call, from the support tool, often took longer than the spinner we had drawn.
The launch write-ups showed a clever prompt and a paragraph. They did not show the timeout, the second call that contradicted the first, or the fact that "is this reply acceptable" was a person nodding. Preference tuning exists in papers. It was not a knob on the account. The knobs were the words in the prompt, the temperature, and top_p.
The prompt was a program with no version
The first production prompt lived as a string in a Python file. It said the model was a support agent, pasted the ticket, and ended with Reply:. The string changed four times in nine days. Each change was a sentence. Adding "If you do not know the policy, say so" cut invented refund rules on our 40-ticket sheet from 11 down to 4. A blank line in the wrong place undid it the next afternoon.
Forty tickets is a small set. It was also the only set. We keep it as eval/tickets.csv with three marks a person can make without a meeting: right intent, right amount if money is involved, no invented policy. A reply scores 0 to 3. We stopped arguing about tone until those three were stable.
BLEU against a stored reference reply was the first score we tried and the first we dropped. Two replies can both tell the customer to reset the password and share almost no word sequences. The checklist catches the failure we actually shipped once, which was a fluent answer that made up a policy.
Latency is a product decision
On the week of August 3 the wrapper logged a median of roughly 6 seconds for a 200-token davinci completion. The slow tenth ran past 20 seconds. The support page gave up at 8. Agents saw an error while we were still being billed for tokens they never read.
The changes that stuck:
- Abort the HTTP call at 8 seconds.
- On abort, return the label from the BERT classifier we already run in under 40ms, plus the template for that label.
- Cache on a hash of model, prompt version, temperature, and ticket text. A second agent opening the same ticket should not pay another 6 seconds.
- Log the prompt version, the latency, the completion, and later the checklist score. That log is next month's eval file.
temperature=0 was not deterministic enough to skip the cache key. We still saw small differences between calls. The cache is there for latency and for the bill, not because the sampler is a pure function.
The loop we ran by hand
A prompt that scores 28/40 and a prompt that scores 34/40 should be two commits, not two memories of a meeting. When someone wants to adjust the wording, they re-run the 40 rows first. If the score drops, the wording does not ship. That is the whole evaluation setup we could build in a week. It caught more regressions than any demo.
We do not put davinci on a path that has to return in two seconds. A prompt change does not reach production without the CSV score on the pull request. And we do not delete the classifier to make the diagram simpler. The classifier is what we return when the API is slow, and it already knows the common intents. The language model is for tickets the classifier has not seen enough times. That split is the system. The playground is not.