How to Evaluate and Control LLM Structure-Following for Requirements Documentation
Large language models can help turn high-level feature lists into detailed product requirements documents, but only if they preserve the original structure. This article explains common failure modes such as deleting, merging, or inventing top-level requirements, and presents practical methods for evaluating and improving structural consistency through fixed test sets, automated validation, repeated testing, prompt design, and post-processing workflows.
How to Evaluate and Control LLM Structure-Following for Requirements Documentation
1. The Core Problem: Add Details Without Changing the Requirements
In software development, requirements documentation often follows a familiar workflow: a product manager or developer first creates a high-level feature list, then uses a large language model to add details to each item, and finally reviews and integrates the output into the document.
This workflow seems straightforward, but it requires a specific capability that is easy to overlook: structural instruction following.
Suppose the original feature list contains four items: A, B, C, and D. The expected task is to add child items beneath each one. An ideal output would look like this:
A├── A1├── A2└── A3B├── B1C├── C1├── C2D├── D1└── D2
In practice, some models produce something very different. They may remove B, invent a new item E, and explain that E was derived by combining certain sub-items from B and C.
For requirements authors, this is a serious problem. The original input has been altered, even though the initial feature list represents a scope that has already been confirmed by stakeholders. Any unauthorized addition, deletion, or restructuring can cause requirements drift.
This is the central issue discussed in this article: in completion tasks, how can we determine whether a model respects structural boundaries, and what engineering techniques can constrain it when it does not?
2. Two Common Types of Structural Failure
2.1 Unauthorized Deletion or Restructuring
A model may decide that one item in the original list has limited value or overlaps with another item. It then merges or omits that item in the output.
This behavior reflects a tendency shaped by the model’s training objective. Models are often optimized to generate content that is more concise, coherent, or useful. Requirements documentation, however, demands something different: faithfulness to the input.
2.2 Hallucinated Additions
A model may use its understanding of the business domain to derive a new item that was not present in the original list, followed by a seemingly reasonable explanation.
From an information-theoretic perspective, this increases the information difference between the input and output. In a completion task, however, the expected information increase should be strictly limited to the internal depth of existing items, not the horizontal expansion of new top-level items.
The constraint can be stated formally:
The set of top-level items in the output must be identical to the set of top-level items in the input. The model may expand items at the second level and below, but it may not alter the top-level set.
This rule is clear and easy to validate, making it a useful foundation for automated evaluation.
3. Why This Capability Matters
3.1 The Special Role of Requirements Documents
Unlike creative writing, a requirements document serves as a working contract for a team. Feature lists may originate from review meetings, stakeholder interviews, or legacy-system migration analysis. Each item usually has a clear source and owner.
If a model removes an item, the related feature may be missed during planning. If it adds an item, it may trigger scope creep. In other words, structural errors are often much more costly than wording issues.
3.2 The Hidden Cost of Retries
When a model makes unauthorized changes, users typically retry the request. Retrying, however, does more than consume time; it also introduces uncertainty. A second attempt may restore B but remove D2 instead.
This instability makes large-scale document processing difficult to automate. Every output must be compared item by item, potentially eliminating the productivity gains that the tool was intended to provide.
4. A Practical Checklist for Evaluating Structural Instruction Following
When selecting a model or evaluating one for a specific application, build a reproducible test set instead of relying on one or two subjective trials. The following lightweight framework is practical and effective.
1. Create a fixed test set.
Prepare 10–20 feature lists from different domains, such as e-commerce, administrative systems, and data reporting. Each list should contain four to eight top-level items and should be reused as a fixed input set.
2. Define the pass criteria.
- The set of top-level items must exactly match the input: no additions, omissions, or renaming.
- Each top-level item must produce at least the required number of child items.
- The output must not include argumentative explanations or derivation notes about the input items.
3. Automate validation.
Because top-level items are discrete and enumerable, a simple script can compare the two sets:
def check_structure(input_items, output_items):expected = set(input_items)actual = set(extract_top_level(output_items))missing = expected - actualextra = actual - expectedreturn len(missing) == 0 and len(extra) == 0
4. Repeat the evaluation.
Run the same test set at least five times and measure the pass rate rather than relying on a single result. In real workflows, consistency is more meaningful than peak performance.
5. Prompting and Workflow Techniques for More Stable Output
Even when models differ in their ability to follow structure, careful prompt design can significantly improve performance. The following practices have proven useful.
1. Explicitly state “expand only; do not modify.”
The instruction should clearly say:
Strictly preserve all of the following items. Do not delete, merge, rename, or add any top-level item. Only add child items within each existing item.
2. Lock the structure with a fixed format.
Require the model to use a consistent template, such as the same marker for every top-level item. Structured formats, including JSON and Markdown lists, can themselves provide constraints and reduce opportunities for unrestricted generation.
3. Complete items individually instead of all at once.
Rather than sending A, B, C, and D in a single request, issue one request per item:
The following is one feature description. Add two or three implementation-detail child items for it.
A single-item task reduces the input and output space, which can significantly lower the likelihood of structural modification. It also naturally supports parallel processing and targeted retries.
4. Add a post-generation validation step.
No matter how carefully the prompt is written, model self-restraint should not be trusted on its own. An automated pipeline should always run the validation script described above. Invalid outputs can then be retried automatically or routed to manual review.
6. Broader Implications: The Task Determines How Models Should Be Evaluated
The question of which model is “better” often leads to disagreement because model quality has little meaning when discussed independently of task type. A model’s relative performance may differ substantially across open-ended conversation, code generation, long-form summarization, and structured completion.
For engineering teams, a more useful approach is to:
Identify the primary task type.
Determine whether the task requires faithful completion, open-ended generation, or reasoning and inference.Build a task-specific evaluation set.
Use measurable indicators such as pass rate, structural consistency, and factual accuracy instead of relying on subjective impressions.Treat the model as a replaceable component.
Use standardized prompt templates and a validation layer to isolate differences between models and minimize switching costs.
Expanding the details of requirements documents is only one example, but it reveals a broader principle: when output boundaries must be tightly controlled, whether a model is obedient may matter more than whether it is clever.
When choosing a tool, start with a simple question: do you need the highest possible creativity, or the most reliable consistency?
