TextLap: Customizing Language Models for Text-to-Layout Planning

Jian Chen, Ruiyi Zhang, Yufan Zhou, Jennifer Healey, Jiuxiang Gu, Zhiqiang Xu, Changyou Chen

Abstract

Automatic generation of graphical layouts is crucial for many real-world applications, including designing posters, flyers, advertisements, and graphical user interfaces. Given the incredible ability of Large language models (LLMs) in both natural language understanding and generation, we believe that we could customize an LLM to help people create compelling graphical layouts starting with only text instructions from the user. We call our method TextLap (text-based layout planning). It uses a curated instruction-based layout planning dataset (InsLap) to customize LLMs as a graphic designer. Human annotators are asked to build a benchmark to evaluate different layout planning models. We demonstrate the effectiveness of TextLap and show that it outperforms strong baselines, including GPT-4 based methods, for document generation and graphical design benchmarks.

Introduction

TextLap is a framework that fine-tunes Large Language Models (LLMs) to act as expert "layout planners," converting natural language instructions into precise 2D arrangements for images and graphic designs. While generative AI can create stunning images, "layout planning"—the specific placement and sizing of elements like text, buttons, or objects—remains a significant hurdle for non-designers. Traditional layout tools require manual coordinate entry or structured inputs, which is unintuitive for most users.

Large Language Models (LLMs) seem like a natural fit for this because they understand intent, but they have a "spatial reasoning gap." Because LLMs process text autoregressively and often tokenize numbers digit-by-digit, they struggle to understand the geometric relationships between coordinate numbers. TextLap aims to bridge this gap, allowing users to simply say, "Put a title at the top and a logo in the bottom right," and receive a professional-grade layout.

Methodology

The authors developed TextLap by fine-tuning a Vicuna-1.5 7B model. The core technical innovations include instruction-based fine-tuning, discrete coordinate tokenization, and flexible output formats.

Overview of the TextLap framework showing input prompts and CSS-formatted layout outputs.

To solve the "number-crunching" issue, the researchers integrated discrete coordinates (0-1024) as single, unique tokens in the model's vocabulary. This prevents the model from getting "confused" by multi-digit strings. Furthermore, the model can output layouts in multiple formats, including raw integers, floats, and—most effectively—CSS structures. Since LLMs are pre-trained on massive amounts of web code, using CSS properties like left, top, width, and height leverages the model's existing knowledge of design syntax.

Dataset Construction: InsLap

The researchers introduced InsLap (Instruction to Layout Planning), a massive dataset built using a "human-machine hybrid" approach.

The InsLap dataset generation pipeline using LLM-based augmentation and heuristic filters.

The dataset incorporates:

  • MS COCO & LAION: Used to train the model on natural scene layouts. GPT-4V was used to generate descriptive captions for existing bounding boxes.
  • Crello: A dataset for professional graphic design (posters, flyers). Phi-3-Vision was used to describe visual elements like SVGs and images.
  • Visual Text Layout: 4,873 prompts specifically for text-heavy designs (like book covers).
  • InstLap Bench: A newly curated benchmark of 502 human-annotated images to evaluate complex document designs.

Results and Discussion

A fine-tuned 7B model (TextLap) consistently outperformed the much larger GPT-4 on layout tasks. This suggests that for specialized spatial tasks, targeted data is more important than raw parameter count. In "text-only" scenarios, where the user doesn't list the objects, GPT-4 had a failure rate of nearly 98%, while TextLap-CSS maintained a failure rate of nearly 0%.

The model performed best when using CSS-style outputs, highlighting that "code-like" structures are a superior medium for LLMs to express spatial intent. Furthermore, because TextLap is an LLM, it supports "interactive editing." A user can generate a draft and then follow up with refinement instructions, which the model handles seamlessly.

When TextLap's layouts were used to guide image generators like Stable Diffusion, the resulting images were preferred by human evaluators 72% of the time over standard text-to-image generation, primarily due to better alignment with spatial instructions.

Conclusion

While TextLap demonstrates significant improvements, there remains a quality gap between AI-generated layouts and high-level human professional design. The dataset construction also relies on heuristics that might exclude nuanced design elements. Future work could involve "spatial-native" pre-training to bake 2D understanding into the model's core, rather than relying solely on fine-tuning.

Summary updated

BibTeX
@inproceedings{chen2024textlap,
  author = {Jian Chen and Ruiyi Zhang and Yufan Zhou and Jennifer Healey and Jiuxiang Gu and Zhiqiang Xu and Changyou Chen},
  title = {{TextLap: Customizing Language Models for Text-to-Layout Planning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  url = {https://openreview.net/forum?id=qk7pJfCwJQ},
}
Figure