Document structuring is a subtask of natural language generation that involves deciding the order and grouping (for example into paragraphs) of sentences in a generated text. It is closely related to the content determination NLG task, which decides what information to include. The goal is to produce a coherent and well-organised text from the reader's perspective, rather than simply a random arrangement of facts.
For example, consider four sentences about a weekend forecast: "It will rain on Saturday", "It will be sunny on Sunday", "Max temperature will be 10 °C on Saturday", and "Max temperature will be 15 °C on Sunday". There are 24 (4 factorial) possible orderings of these messages. Some orderings are preferred by human readers, such as grouping weather conditions by day (rain and 10 °C on Saturday, then sun and 15 °C on Sunday), over less logical sequences. Similarly, for any ordering, there are multiple ways to group sentences into paragraphs; for four sentences, there are 8 (2 to the power of 3) possible paragraph groupings. Readers generally prefer groupings that cluster related information, such as (12)(34) over (1)(23)(4).
Approaches and algorithms
Three classic approaches to document structuring exist: schemas, corpus-based methods, and heuristic-based methods. Schemas are templates that explicitly specify sentence ordering and grouping, typically derived by manually analysing a corpus of human-written texts in a target genre. They work well for short texts (five sentences or fewer) or those with standardised structures, but struggle with longer or less fixed texts.
Corpus-based structuring uses statistical analysis of text corpora to automatically build ordering and grouping models. This technique is common in automatic summarisation, where programs generate summaries of documents. In principle, it could apply to text generated from non-linguistic data, but this work remains nascent, partly because NLG systems are expected to produce high-quality text, which automatic summarisation often does not.
Heuristic-based structuring relies on rules derived from theories of rhetoric, psycholinguistic models, or intuition and user feedback. This approach can focus on what is best for readers, unlike schemas or corpus methods that imitate authors, but it is difficult to implement well because heuristics often depend on semantic information about how sentences relate, which may not be readily available.
Modern neural approaches
Recent advances in deep learning and large language models have shifted document structuring toward end-to-end neural text generation. Systems based on transformers and neural networks learn ordering and grouping implicitly from large training corpora, rather than through explicit rules or templates. This approach, used by models from organisations like OpenAI, Anthropic, and Google DeepMind, can produce fluent text but may still exhibit coherence and discourse-organisation problems, such as logical jumps or poorly grouped paragraphs.
These models often employ techniques like positional encoding and multi-head attention to capture sentence relationships, but document structuring remains a challenge because it requires global coherence beyond local word predictions. Research in artificial intelligence continues to explore how to improve this, with some work drawing on curriculum learning or reinforcement learning from AI feedback to optimise text organisation.
Narrative generation
The ultimate document structuring challenge is generating a good narrative: a text that sets the scene, introduces an overview, describes events clearly so readers see how they link, and concludes with a summary. This applies to factual texts as well as stories. Current NLG systems often fail at this, and it is a major source of user criticism. Generating good narratives is difficult across all NLG aspects, but document structuring is arguably the most fundamental hurdle.
Evaluation and challenges
Evaluating document structuring typically involves human judgments of coherence and readability, as readers prefer certain orderings and groupings over others. Automated metrics are less common because coherence is subjective and context-dependent. Challenges include handling long documents, adapting to varied genres, and ensuring that generated text meets reader expectations, especially when source data is non-linguistic. As of the early 2020s, no single approach fully solves these issues, and hybrid methods combining heuristics with neural generation are an active area of research.