Stability and Evaluation of Long-Form Text Generation in LLMs
This article reframes the debate over which large language model is "best" into three measurable engineering questions for long-form generation: long-range consistency, detail density, and structural controllability. It presents a five-stage pipeline—planning, world modeling, chapter generation, validation, and revision—that maintains settings in an external structured store instead of relying on model memory. It also covers machine-checkable world modeling, automated consistency gates, a four-dimension scoring formula for descriptive quality, and a reproducible evaluation loop with fixed variables. The approach extends to long-document writing, repository-level code generation, and cross-file refactoring.
1. The Problem: Why “Which Model Is the Strongest” Is Not a Valid Question
In long-content generation, a recurring debate is which model writes code best or which one writes fiction best. From an engineering perspective, such claims usually lack reproducible evaluation conditions: the task definition is vague, input prompts are inconsistent, and judging criteria depend on personal preference. The resulting conclusion reflects a single sampling experience rather than the actual capability boundary of a model.
A more reasonable approach is to reframe the problem as three measurable sub-questions:
- Long-range consistency: across tens of thousands of output tokens, do the setting, characters, and timeline remain self-consistent?
- Detail density: is the description concrete and perceivable, rather than vague generalization?
- Structural controllability: can generation follow a predefined outline and converge reliably under constraints such as word count, chapter count, and conflict pacing?
The practical approach below uses “generating a long-form work of more than 70,000 words” as its background, but the methods transfer directly to engineering tasks such as long-document writing, repository-level code generation, and cross-file refactoring.
2. Overall Architecture: A Layered-Outline-Driven Generation Pipeline
Asking a model to produce tens of thousands of words in a single pass almost inevitably leads to setting drift and pacing collapse. A workable approach splits generation into a five-stage pipeline: plan, model, generate by chapter, validate, and rewrite.
# Illustrative pseudocode: layered outline drivenoutline = plan_structure(topic, chapters=16, target_words=70000)world = build_world_model(outline) # structured setting storestate = {"timeline": [], "items": {}, "relations": {}}for ch in outline.chapters:ctx = retrieve_relevant(world, state, ch) # inject only settings relevant to this chapterdraft = generate_chapter(ch, ctx, state)issues = check_consistency(draft, world, state)if issues:draft = revise(draft, issues)state = update_state(state, draft) # incrementally update world state
The key point is that settings are not something the model has to “remember”; they are explicitly maintained in an external structured store. Each generation step injects only the slice relevant to the current chapter, shifting the context pressure from “full recall” to “precise retrieval.”
3. Structured Setting Modeling: Making the Worldview Machine-Verifiable
Breaking the worldview into enumerable entity tables is the foundation of long-range consistency. Taking a xianxia-style theme as an example, it can be abstracted into the following structure:
world:cosmology: [historical lineage, distribution of factions, core settings]cultivation:realms: [Entry Realm, Tongxuan Realm, Immortal Lord Realm]core_method: Qingyun Condensation Artorigin: Qingyun Cavegeography:- name: Pining Valleyfeature: Spring of Lifefactions:- name: protagonist camprelation: ally / life-saving debt / brotherhood- name: Eye of the Abyssrole: antagonist- name: Qingyun Alliancerole: enemy or ally depending on circumstancesconflicts: [moral choice, faction confrontation, resource scarcity, identity transformation]deadline:limit_days: 7success: repair the Demon-Suppressing Grand Arrayfailure: the grand array collapses
With this table in place, consistency checking reduces to automatically executable rule evaluation: whether realm names exceed their allowed bounds, whether geography and item ownership conflict, whether the deadline is violated, and whether character relations contradict earlier text.
4. Consistency Validation: From Post-Hoc Reading to Automatic Blocking
Manually reading through 70,000 words is extremely costly, so validation should be moved earlier and turned into a gate during generation. Common rules fall into four categories:
- Naming and terminology validation: proper nouns must exist in the setting table, and synonym drift is prohibited;
- Timeline validation: event order is monotonic and countdown constraints are not broken;
- Capability boundary validation: character actions must not exceed their current realm and held items;
- State consistency validation: consumed resources and already-acquired manuals must not reappear.
def check_consistency(chapter, world, state):issues = []for name in extract_entities(chapter):if name not in world.entity_index:issues.append(f"Unregistered entity: {name}")if chapter.day_index > world.deadline.limit_days:issues.append("Deadline constraint exceeded")for item, cnt in chapter.acquired.items():if state["items"].get(item, 0) + cnt > world.item_total[item]:issues.append(f"Item out of bounds: {item}")return issues
The value of this gate is not only error correction. It also turns the subjective argument about whether the writing style is good into an objective discussion about whether constraints are satisfied.
5. Evaluating Descriptive Quality: From Impression to Metrics
The original text notes differences between tools in describing something like a “deformed wolf”: scales covering the body, bony spikes along the spine, fluorescent glow in the eye sockets, and dripping saliva. Such differences can be quantified, and a four-dimension score is recommended:
- Sensory channel coverage: whether visual, auditory, olfactory, and tactile channels are all engaged;
- Concrete noun density: the ratio of concrete nouns to abstract adjectives;
- Number of verifiable details: detail entries that can be checked against the setting table or common sense;
- Redundancy: the proportion of repeated imagery and stock phrases.
detail_score = 0.35*sensory_coverage + 0.25*concrete_noun_density+ 0.25*verifiable_details - 0.15*redundancy
For code generation tasks, the same framework transfers to interface signature completeness, boundary condition coverage, number of error-handling branches, and duplicate implementation rate.
6. Designing the Evaluation System: Reproducibility Is a Prerequisite for Conclusions
To make the “who is stronger” discussion engineering-meaningful, four categories of variables must be fixed: the same prompt and the same outline, the same temperature and sampling configuration, the same validation script, and the same scoring sheet, with repeated sampling to take the mean and variance. Looking only at the single best sample makes it easy to mistake chance for capability.
The recommended minimal evaluation loop:
- Input layer: fixed outline, setting table, and constraint list;
- Generation layer: chapter-based pipeline, recording tokens and elapsed time per chapter;
- Validation layer: automated gates output an issue list;
- Scoring layer: weighted combination of consistency, detail, and structure;
- Archiving layer: save failed samples to build a regression test set.
7. Engineering Implementation: Integration with Existing R&D Systems
In real production environments, long-content generation is usually not an isolated capability but needs to work with general cloud components: object storage to hold outlines, setting tables, and historical versions; a message queue to decouple the planning, generation, and validation stages for peak shaving and retry on failure; a container platform to host stateless generation and validation services with elastic scaling by concurrency; and logging services plus monitoring alerts to track failure rate, average retry count, and the distribution of gate blocks. Baidu AI Cloud offers corresponding capabilities in these general categories and they can be combined as needed, while the model capability itself should still be verified with a self-built evaluation set rather than relying on marketing claims.
8. Conclusion
“Whether a certain model is the strongest” is a question that cannot be reproduced; “under given constraints, what are the consistency, detail density, and structural controllability of long-form output” is an engineering question. Structuring the settings, automating validation, turning scoring into metrics, and decoupling the generation pipeline from general cloud infrastructure are what make long-content generation stable, regression-testable, and comparable. This method applies equally to repository-level code generation and large-scale document production, and its value far exceeds any one-off model ranking judgment.
