LayoutCoT: Unleashing the Deep Reasoning Potential of Large Language Models for Layout Generation

Hengyu Shi, Junhao Su, Tianyang Han, Junfeng Luo, Jialin Gao

TL;DR

LayoutCoT is a training-free framework that unlocks the latent spatial reasoning capabilities of off-the-shelf Large Language Models (LLMs) for graphic layout generation. By combining layout-aware Retrieval-Augmented Generation (RAG) with a multi-stage Chain-of-Thought (CoT) refinement process, it achieves state-of-the-art results across multiple design benchmarks without requiring any fine-tuning.

What Problem Does This Paper Address?

Automating graphic layout generation—arranging text, images, and user interface (UI) components into visually appealing and coherent structures—is a challenging task. Traditional deep learning approaches (like GANs or diffusion models) require massive, task-specific datasets and expensive fine-tuning.

Recently, researchers have turned to training-free LLM-based methods using in-context learning. However, these methods often suffer from shallow reasoning. When given complex design constraints, standard LLMs tend to "game" quantitative evaluation metrics. For example, to minimize overlap scores, they frequently generate tiny, unreadable bounding boxes clustered tightly in a corner. This paper addresses the gap between raw LLM generation and the structured, iterative reasoning required to produce practical, human-like layouts.

Methods

LayoutCoT introduces a three-step, training-free pipeline that serializes layouts into LLM-friendly HTML snippets and processes them using two core components:

  1. Layout-aware RAG: Instead of randomly selecting in-context examples, the framework uses a layout transportation-based similarity measure (LTSim). This dynamically retrieves the top-$K$ exemplars from a database that best match the structural and semantic constraints of the user's request.
  2. Coarse Layout Generation: The LLM uses the retrieved exemplars to draft an initial, rough layout.
  3. Multi-stage CoT Refinement: Instead of forcing the LLM to output a perfect layout in a single pass, LayoutCoT breaks the task down into three sequential, conversational stages that mimic a human designer's workflow:
  4. Stage 1 (Logical Placement): Determines the initial positions and logical hierarchy of core elements without worrying about exact sizing.
  5. Stage 2 (Size Adjustment): Optimizes bounding box sizes and positions to resolve overlaps and crowding.
  6. Stage 3 (Aesthetic Tuning): Applies fine-grained, pixel-level mathematical adjustments to ensure perfect alignment and visual balance.
Figure 1: Qualitative evaluation of the multi-stage LayoutCoT framework. Each successive stage systematically refines the spatial arrangement of layout elements, resulting in designs with enhanced coherence and rationality.

Datasets

The authors evaluated LayoutCoT across five diverse public benchmarks spanning three distinct layout generation tasks:

  • Content-aware layout generation: PKU and CGL datasets (focusing on generating text boxes over poster background images).
  • Constraint-explicit layout generation: RICO (mobile UI designs) and PubLayNet (document typesetting layouts).
  • Text-to-layout generation: WebUI dataset (translating natural language instructions into spatial arrangements).

Key Insights and Ideas

  • Decomposition Beats Raw Power: A standard LLM (like GPT-4) prompted with a domain-specific, multi-stage CoT can actually outperform specialized deep-reasoning models like DeepSeek-R1 when the latter lacks a structured layout generation prompt.
  • The "Corner-Clustering" Failure Mode: The authors discovered that naive LLM layout generators exploit evaluation metrics by shrinking elements into microscopic boxes to avoid overlaps. To combat this, they introduced a new metric, $R_e$ (Reasonableness of element size), which penalizes layouts whose element sizes deviate significantly from the training distribution.
  • The Power of Layout-Aware Retrieval: Using soft-matching structural similarity (LTSim) for RAG ensures the LLM receives highly relevant contextual exemplars, even if the number or types of elements differ between the query and the database.

Key Results

LayoutCoT established new state-of-the-art performance across all five benchmarks without any model training or fine-tuning.

  • Content-Aware Tasks: On the PKU dataset, LayoutCoT achieved an alignment score of 0.0002 (where lower is better) and a perfect validation score of 1.000, substantially outperforming previous training-free baselines like LayoutPrompter.
  • Qualitative Improvements: As shown in the poster generation examples, while baseline models frequently fail by creating overlapping text or tiny, unreadable boxes in the upper-left corner, LayoutCoT consistently generates well-spaced, visually balanced, and practical designs.
Figure 4: Qualitative Results for the Content-aware Lay- out Generation Task. LayoutPrompter and LayoutCoT†

Limitations and Future Work

  • Inference Latency: Because the CoT module relies on an iterative, three-stage conversational process, it incurs higher computational overhead and slower generation speeds compared to non-autoregressive, end-to-end generative models.
  • Database Boundaries: As an in-context learning method, LayoutCoT's performance upper bound is inherently tied to the diversity of its RAG exemplar database. Handling extremely rare or highly complex layout constraints remains a challenge if similar examples do not exist in the retrieval pool.

Summary updated

BibTeX
@misc{shi2025layoutcot,
  author = {Hengyu Shi and Junhao Su and Tianyang Han and Junfeng Luo and Jialin Gao},
  title = {{LayoutCoT: Unleashing the Deep Reasoning Potential of Large Language Models for Layout Generation}},
  year = {2025},
  eprint = {2504.10829},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.10829},
}
Figure