We shortened the system prompt from 1,200 words to a JSON schema and that fixed our output errors.

by•

When we began building the document parser, we kept adding rules to the system prompt each time the model made a mistake. Eventually, the instructions reached 1,200 words. The model began ignoring rules that were in the middle.

I thought that adding examples and repeating warnings in capital letters would force compliance. Instead, latency. The parser still invented fields whenever an invoice had an unusual layout.

We solved the problem by deleting ninety percent of the text instructions and enforcing a JSON output schema that has explicit enum values and nullable fields. When the model cannot find a date or tax number, the schema forces it to return null instead of guessing.

Our parsing accuracy jumped from seventy-eight percent to ninety-six percent overnight. Our API costs dropped by nearly a third because we stopped sending massive prompts on every call. If you are fighting outputs, stop writing longer instructions and start constraining the shape of the response. Have you found strict schemas more reliable than prompt rules in production?

3 views

Add a comment

Replies

Best

Yes, and the part I'd add is that the schema should also have a place for "no". One of our features reads a pasted chat or up to 5 screenshots and turns it into a duet song. The reader is a small fast model with a strict JSON schema: language, the two people with a guessed voice that is allowed to be "unknown", and the messages exactly as written. It never has to invent a voice, because "unknown" is a legal answer, the same way your nullable fields work. And when the chat can't become a duet, say three or more people, it doesn't try to squeeze it into the shape: it refuses with one of a few fixed reasons, and the app explains that reason. A schema that only describes the happy path still pushes the model to guess on the unhappy one.