LoopWeaver: Weaving Feedback Loops into Hierarchical Generation under Constraints

Yifan Zhu, Guanting Chen, Bing Wei, Haoran LuoNeurIPS 2026

TL;DR

Ask an LLM to write a short email, and it shines; ask it to write a 5,000-word year-long diary where specific events must happen on exact weeks without losing the plot, and things quickly unravel. LoopWeaver solves this juggling act by separating "architecting the outline" from "writing the prose," aligning both stages offline using a simple, deterministic rule-based reward. The result is a clean, feed-forward system at inference time that significantly boosts both rule-following and narrative coherence across open-source models.

What Problem Does This Paper Address?

Generating long-form text (thousands of tokens) under strict user constraints is a classic multi-objective headache. Models have to simultaneously manage global structure (does the overarching plot make sense?), local coherence (do paragraphs flow smoothly?), and constraint satisfaction (did we include a "jazz club visit" every third entry, as requested?).

Existing solutions generally fall into two camps, and neither quite nails the problem:

  1. Data-centric methods (like LongWriter) train models on long, constraint-heavy examples. However, constraints are baked in implicitly—if the model slips up halfway through a 10,000-word generation, there is no mechanism to catch or fix it, and errors compound.
  2. Planning-based workflows (like CogWriter) break writing into outlines and drafts. Yet, these pipelines are loosely coupled: high-level constraints often get lost in translation by the time the model decodes individual paragraphs, and post-hoc refinement loops are computationally expensive.
Figure 2: Framework comparison of LoopWeaver, LongWriter, and CogWriter. LoopWeaver couples plan-level and generation-level preference optimization during offline training, while inference proceeds through complete-plan revision, filtering, and segment generation.

Methods

Despite having "Loop" in its name, LoopWeaver doesn't trap your GPU in endless agentic revision loops at runtime. Instead, it weaves feedback into two sequential offline training stages, keeping inference fast and strictly feed-forward.

(Note: Let's look closer at the exact mechanics in Figure 3 below.)

Figure 3: Overview of LoopWeaver. Complete-plan construction, in-context revision, and whole- plan filtering operate at inference time; shared-reward plan-level and generation-level DPO provide sequential coupling during offline training.

Here is how the pieces fit together:

  • Constraint-Aware Hierarchical Planning: Given a prompt and constraints (categorized as single, range, or periodic), the planner generates a sequence of structured sub-plans and performs an in-context revision pass over the whole outline so upstream edits smoothly adjust downstream plans.
  • Feasibility Filtering: Before wasting compute on bad outlines, the base LLM acts as a gatekeeper. A lightweight, prompted YES/NO check evaluates the revised plan across six criteria (relevance, completeness, coherence, efficiency, specificity, and consistency), discarding malformed candidates.
  • Coupled Offline DPO via Shared Deterministic Reward: This is the core innovation. Rather than training a heavy neural reward model, the authors use a fast, deterministic Python-style scoring function (checking exact substring matches, SequenceMatcher ratios, and prompt keyword coverage). This exact same mathematical yardstick ranks candidate sub-plans for Plan-level DPO (Direct Preference Optimization, a standard technique for teaching models to prefer good outputs over bad ones), and then—transferring the trained checkpoint—ranks text segments for Generation-level DPO.

At inference time, LoopWeaver simply generates a plan, revises it once, filters it, and writes the text segment-by-segment conditioned on the current sub-plan and running narrative.

Datasets

The authors build and evaluate on LongGenBench, testing across four structured constrained-generation scenarios (such as generating a 52-week diary with specific word counts and recurring life events, or structured building/floor/block plans). Constraints are explicitly partitioned into three structural patterns: Once (single explicit requirement), Range (bounded structural span), and Periodic (fixed recurrence). No brand-new external benchmark is introduced, though the authors release their generated preference data and audit splits publicly.

Key Insights and Ideas

  • Offline alignment beats runtime babysitting: You don't need expensive, cyclic agent loops at inference time if your planner and writer are already aligned to speak the same constraint language offline.
  • A simple rule-based reward lifts narrative quality, too: Surprisingly, the deterministic reward only checks keyword relevance and string-matching constraint coverage—it has zero concept of tone or prose quality. Yet, optimizing with it improves narrative coherence and affective consistency, likely because structured, valid plans naturally prevent the model from rambling.
  • Sequential coupling is greater than the sum of its parts: Ablations show that training only the planner or only the generator yields solid gains, with planning-only slightly edging out generation-only on text quality. Sequencing both via checkpoint transfer unlocks the highest performance across the board.

Key Results

LoopWeaver was tested across four open-source backbones (Qwen2.5-0.5B, 1.5B, 7B, and LLaMA3.1-8B-Instruct) against Base models, LongWriter, and CogWriter, alongside a proprietary GPT-4o-mini reference.

Main results comparing Text Quality and Constraint Accuracy across four backbones
  • Consistent SOTA on Open Weights: LoopWeaver sweeps both Text Quality and Constraint Accuracy across all four open-source scales. On Qwen2.5-7B, it hits 48.41% constraint accuracy (beating Base by +17.67 points and CogWriter by +6.21 points) and 78.77 on text quality.
  • Punching Above Its Weight: Both Qwen2.5-7B (48.41%) and LLaMA3.1-8B (48.55%) equipped with LoopWeaver surpass GPT-4o-mini (45.28%) and GPT-4o-mini + CogWriter (46.82%) on overall constraint-following accuracy.
  • Scale Still Matters for Depth: Qualitative case studies show that while 0.5B and 1.5B models follow structural rules much better with LoopWeaver, they still suffer from repetitive phrasing, whereas the 7B model weaves constraints into genuinely rich, evolving narratives.

Limitations and Future Work

The authors are refreshingly candid about what LoopWeaver doesn't do:

  • No Runtime Recovery: Because inference is strictly feed-forward, generated text segments are never sent back to the planner. If a segment drifts off-script, the global plan won't adapt on the fly.
  • Surface-Level Reward: The deterministic string-matching reward cannot directly evaluate factuality, tone, or nuanced semantic coherence.
  • Imperfect Filtering & Domain Scope: Audits on LLaMA-3.1-8B revealed the YES/NO feasibility filter has a ~27.2% proxy false-rejection rate (throwing away some structurally valid plans). Furthermore, evaluation is limited to four structured scenarios, so unrestricted cross-domain generalization isn't guaranteed.

Future work aims to bolster planning reliability for tiny models (like the 0.5B scale) and tackle messy, open-ended long-form tasks with more complex structural demands.

Summary updated

Abstract

Large Language Models face a multi-objective optimization problem in constrained long-text generation, balancing global structure, local coherence, and constraint satisfaction. We propose LoopWeaver, a hierarchical workflow with two sequential offline preference-optimization stages. Constraint-aware planning produces structured plans, feasibility filtering removes invalid plans, and a shared deterministic reward constructs preference pairs for plan-level and generation-level DPO. At inference time, LoopWeaver remains feed-forward: it generates and revises a complete plan, filters the revised plan, and then generates segments conditioned on the current sub-plan and running narrative. We evaluate the method on four LongGenBench-style structured scenarios across multiple backbones. Results show improvements in both constraint accuracy and text quality across all four open-source backbones. Our software and data are publicly available at https://github.com/cgtaa-cmyk/LoopWeaver.
BibTeX
@inproceedings{zhu2026loopweaver,
  author = {Yifan Zhu and Guanting Chen and Bing Wei and Haoran Luo},
  title = {{LoopWeaver: Weaving Feedback Loops into Hierarchical Generation under Constraints}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=x14zIDXsFq},
}

Loading related content...

Figure