Does Field Ordering Affect Model Performance?
Published on: 2025-06-21 09:09:52
I mostly wrote this post as an excuse to try the freshly-minted and excellent pydantic-evals framework for LLM evaluations but one interesting question that arises when working with Pydantic Models to implement structured output in your AI applications is: What happens if you shuffle the order of fields in your schema?
Does it matter if your output type looks like this:
class AgentOutput(BaseModel): answer: str reasoning: str
or like this:
class AgentOutput(BaseModel): reasoning: str answer: str
One line of argument goes something like this: For reasoning models, field ordering shouldn’t matter much. But for non-reasoning models, the second ordering might actually help: by placing the reasoning field first, we could nudge the model into a chain-of-thought-like regime early on, encouraging it to construct a more well-grounded answer. Contrast that with the first ordering, which asks the mode to output the answer first and then the explanation. This could backfire if the model locks
... Read full article.