Evaluating and Improving LLM Instruction Following: From Output Quality to Constraint Compliance

    This article explains why instruction following matters more than surface-level output quality when assigning engineering tasks to large language models. It breaks instruction following into four testable levels—format, method, constraint, and consistency—and shows how to design process-verifiable tasks that expose shortcut-taking. You will also find common failure patterns, structured prompting techniques, and a practical approach to integrating instruction-following evaluation into a regression testing workflow.

    1. Background: From “Producing a Result” to “Producing a Result Under Constraints”

    In real-world model application development, teams often focus on whether the final answer “looks correct” while overlooking whether the process satisfies the stated constraints. A typical scenario: the model delivers a runnable page or executable code that visually matches expectations, but the implementation path completely diverges from the requirements. It adds steps that were never requested, bypasses the specified method, and ends up “coincidentally” producing a similar result. Such output is a high-risk engineering artifact: it is unmaintainable, unreproducible, and cannot pass a constraint audit.

    Therefore, when evaluating whether a model is suitable for taking on concrete, “outsourced-style” engineering tasks, the key is not generation speed or surface-level completeness, but instruction following: whether it strictly uses the specified method, whether it leaves only necessary traces, and whether it explicitly asks questions when information is missing instead of filling in gaps on its own. In practice, models with strong instruction-following performance often “appear to have a narrower knowledge base.” This is not a defect, but another manifestation of their tendency to avoid acting on their own. Conversely, models with weaker natural language understanding and narrower knowledge coverage tend to deliver results that faithfully match the original intent more consistently when prompts are detailed enough and constraints are rigorous enough.

    2. Capability Layers: Breaking “Obedience” into Measurable Dimensions

    It is recommended to break instruction following into four levels and validate them one by one:

    1. Format following: Whether the output structure, fields, file types, and naming match the requirements.
    2. Method following: Whether the specified algorithm/steps are used, rather than replaced with a “more convenient” equivalent approach.
    3. Constraint following: Whether negative constraints are respected, such as “produce only necessary traces,” “do not add steps,” and “do not introduce undeclared dependencies.”
    4. Consistency following: Whether intermediate artifacts and final conclusions are self-consistent and can be reviewed step by step.

    Most failures occur at levels 2 and 3. Models tend to take the “shortest path.” When implementing the specified method is costly, they spontaneously fill in steps, achieve the goal on the surface, and substantively violate the requirements.

    3. Evaluation Design: Constructing Tasks That Expose Shortcuts

    Traditional tasks like “draw a certain shape” or “make an animation” have gradually lost their discriminative power because their criteria are loose and too many implementation paths are acceptable. A more effective approach is to design tasks that are process-verifiable and have strong step uniqueness. For example, require implementing a geometric construction subject to strict drawing rules, and specify:

    • Only a given finite set of operations may be used;
    • The circle center, radius, and intersection sources for key steps;
    • Traces are left only where necessary;
    • The result supports export as an animated image.

    A sample requirement fragment can be written as:

    1. Task: Implement a web page that demonstrates the construction of a regular heptagon under given rules.
    2. Hard constraints:
    3. 1) Only two operations are allowed: "straightedge + two graduated rulers";
    4. 2) Steps must start from a given square and first construct the perpendicular bisector of the base;
    5. 3) Draw a circle with the specified vertex as the center and the diagonal as the radius;
    6. 4) Keep the two graduated rulers aligned with the specified vertex, move the first graduation line along the circle
    7. until the second graduation line passes through the perpendicular bisector of the base;
    8. 5) Complete the remaining standard construction steps, but do not add undeclared steps;
    9. 6) Leave compass traces only at necessary positions;
    10. 7) Provide the ability to export a GIF.
    11. Acceptance: Step-by-step replay, where each step can be mapped back to the constraints above.

    The evaluation of such tasks does not depend on “whether it looks similar,” but on “whether each step is traceable.” If the model produces a similar result but the steps cannot be mapped, it is judged as non-compliant.

    4. Common Failure Patterns and Root Causes

    • Goal substitution: Interpreting “construct using the specified method” as “construct the target shape,” and thus replacing the method.
    • Constraint drift: Ignoring negative constraints (no added steps, only necessary traces) and gradually deviating.
    • Silent completion: Not asking questions when information is insufficient, but making assumptions and writing them into the implementation.
    • Surface consistency: The final image is correct, but intermediate steps are inconsistent with the declaration, making auditing difficult.

    The root cause is that the training objective leans toward “acceptability of the final answer” rather than “satisfaction of process constraints.” This also explains why some models perform more stably when prompts are more detailed and constraints are harder: they do not need to make excessive autonomous inferences.

    5. Prompt Engineering: Improving Compliance with Structured Constraints

    Reusable practices include:

    1. Give the operation set first, then the goal: Specifying “what is allowed” is more effective than only describing “what is wanted.”
    2. Make negative constraints explicit: Write “do not add steps / do not introduce extra libraries” as separate items.
    3. Step numbering and acceptance mapping: Require the model to output a “step–constraint” mapping table.
    4. Ask when information is missing: Add a rule such as “if information is insufficient, ask first; do not assume.”
    5. Replay entry point: Require step-by-step demonstration and export capabilities for auditing.

    Example:

    1. Output requirements:
    2. - First list implementation step numbers S1..Sn;
    3. - Label each step with the constraint number it satisfies;
    4. - If any information is undefined, stop and ask;
    5. - Introducing undeclared dependencies is prohibited;
    6. - Provide step-by-step replay and GIF export.

    6. Engineering Implementation: Integrating Evaluation into the Development Workflow

    It is recommended to incorporate such tasks into a regression evaluation set to form a closed loop:

    • Case library: Prepare several traceable tasks for each of the four levels: format, method, constraint, and consistency.
    • Automated judgment: Perform field validation for structured outputs; perform step mapping checks for process-oriented tasks.
    • Manual spot checks: Focus on reviewing samples where “results are similar but paths are suspicious.”
    • Prompt version management: Version prompt templates alongside cases to ensure results are comparable.
    • Release threshold: Use “constraint satisfaction rate” rather than “surface completion rate” as the admission metric.

    On the deployment side, general cloud capabilities can be used to support evaluation and regression: object storage to save cases and artifacts, a container platform to run sandboxed execution environments, and logging services with monitoring and alerting to track compliance rate fluctuations. This transforms subjective experience into sustainable, observable engineering metrics. Baidu AI Cloud is typically used in such development workflows to support this observability and automation infrastructure.

    7. Conclusion

    “Being obedient” and “not knowing much” are often two sides of the same coin. For models taking on concrete engineering tasks, what truly matters is not the breadth of knowledge, but not drifting, not filling in gaps, and being traceable under hard constraints. Through process-verifiable task design, structured prompting, and regression-based evaluation, teams can elevate instruction following from a vague experience to a clear metric, significantly reducing the engineering risk of “appearing complete but actually taking shortcuts.”