Structured Outputs interview question

Generative AIStructured OutputsPlanning & Reasoningeasy

A loan pre-screening step uses the schema below with constrained decoding, which emits properties in schema order. Reviewers find that reasoning usually argues for whatever decision was produced, even clearly wrong ones, and accuracy is lower than with the team's earlier free-text chain-of-thought prompt. What is the most likely cause and fix?

json
{
  "type": "object",
  "properties": {
    "decision":  { "type": "string", "enum": ["approve", "refer", "decline"] },
    "reasoning": { "type": "string" }
  },
  "required": ["decision", "reasoning"],
  "additionalProperties": false
}
  1. AJSON objects are unordered, so the model plans the whole object before writing any of it; the fix is a longer description on reasoning that tells the model to think carefully.
  2. BThe enum on decision stops the model from reasoning; replace it with a free-text field so that the model can explain its choice inside the decision value itself.
  3. CThe reasoning field is too short to hold a real chain of thought; set a minimum length on it so that the model must justify every decision in much more detail.
  4. DGeneration runs left to right, so decision is fixed before any reasoning exists and the rationale comes after the fact; put reasoning first in the schema.
Show the answer and explanation

Correct answer: D, Generation runs left to right, so decision is fixed before any reasoning exists and the rationale comes after the fact; put reasoning first in the schema.

Explanation Structured Outputs

An LLM writes its output one token at a time, left to right, and each token can depend only on the prompt and the tokens already written. With decision first, the model commits to approve, refer or decline with no reasoning tokens to condition on. The reasoning that follows is a post-hoc rationalisation: it is conditioned on the decision, so it tends to defend it, right or wrong. It adds no accuracy and cannot be trusted as an explanation.

Fixes:

  • Reorder the schema so reasoning (or evidence, analysis) comes first and decision last. The decision is then generated after, and conditioned on, the reasoning, just like chain-of-thought in free text. Most structured-output engines emit keys in schema order, but some APIs need an explicit property-ordering setting, so verify the output order.
  • If a strict format still hurts reasoning quality, use two steps: let the model reason in free text, then convert the conclusion into the schema with a second, cheap call or a parser.
  • With reasoning models, the hidden thinking happens before the visible output, so a separate reasoning field matters less.

Why the other options fail: JSON key order may not matter to a parser, but it is the order of computation for the model, which does not write a hidden draft of the whole object first; a description asking it to think carefully adds no reasoning tokens before decision. Enums make routing reliable and do not block reasoning. A longer reasoning field is still post-hoc.

Interview tip: say that "field order in a schema is a prompt-engineering decision": evidence and reasoning first, extracted values or verdicts last.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Generative AI questions

  1. The flow shows one generation step of a decoder-only LLM (GPT- or Llama-style). What happens at the highlighted step?
  2. From the same logits, a teacher LLM gives these next-token probabilities after "I want to ___ my subscription" (restricted to five candidate tokens): cancel…
  3. A retail client wants a customer-facing assistant over ~5,000 public help-center pages and product PDFs, live in six weeks, with a team of two engineers.…
  4. To save tokens, a bank adds an LLM extractor after retrieval that keeps only the sentences relevant to the question from each of the top 8 chunks. Context…
  5. A telecom's support assistant has no reference answers for live traffic, so the team wants implicit signals as quality proxies: the user rephrases the…