PulseAugur
EN
LIVE 21:30:28

LLM structured output field order impacts accuracy

A developer discovered that the order of fields in a JSON schema significantly impacted an LLM's output for a refund classification task. By inadvertently alphabetizing the schema using `json.dumps(sort_keys=True)`, the 'answer' field was placed before the 'reasoning' field. This caused the model to generate the decision before considering the justification, leading to a drop in accuracy from 451/500 to 412/500 correct answers. The developer recommends ensuring that explanatory fields precede decision fields in schemas and implementing tests to verify schema field order. AI

IMPACT Highlights the critical importance of schema design and field order for reliable LLM structured output generation.

RANK_REASON Developer shares a practical tip for using LLM structured outputs.

Read on dev.to — LLM tag →

AI-generated summary · Google Gemini · from 1 sources. How we write summaries →

LLM structured output field order impacts accuracy

COVERAGE [1]

  1. dev.to — LLM tag TIER_1 English(EN) · jidonglab ·

    Structured Outputs Field Order: 'answer' First Cost Me 39 of 500

    <p>My refund-routing classifier lost 39 correct answers out of 500 overnight. No prompt change. No model change. No temperature change. The diff that did it was one argument in a caching helper: <code>sort_keys=True</code>.</p> <p>That argument alphabetized my JSON schema. <code>…