Auto Completion of User Interface Layout Design Using Transformer-Based Tree Decoders

Yang Li, Julien Amelot, Xin Zhou, Samy Bengio, Si SiarXiv 2020

Abstract

Automating graphical user interface (GUI) layout design is a significant challenge in mobile and web development. This paper presents a deep learning framework for auto-completing UI layouts based on partial user input. By modeling UIs as hierarchical trees of 2D elements, we propose two novel Transformer-based decoders: the Pointer Transformer and the Recursive Transformer. Our models predict the type, position, and dimensions of remaining UI components while maintaining structural integrity. Evaluated on a large-scale Android dataset, our methods demonstrate superior performance in layout completion and structural accuracy, grounded by new UX-centric evaluation metrics.

Introduction

Designing mobile application interfaces is traditionally a manual, iterative process. Designers must arrange various components—buttons, images, and text fields—into a coherent visual and structural hierarchy. While auto-completion is standard in text-based tasks, UI design presents unique challenges due to its non-linear 2D nature and complex hierarchical dependencies.

Mapping a 2D UI layout to its hierarchical tree representation.

As shown in Figure 1, a UI is not merely a collection of bounding boxes; it is a tree structure where containers (like lists) hold children (like list items). To address this, we treat layout completion as a tree generation problem, moving away from simple 1D sequences to capture the inherent structural complexity of modern interfaces.

Methodology

We leverage the Transformer architecture's ability to capture long-range dependencies, proposing three distinct decoder strategies:

  • Vanilla Transformer: Linearizes the UI tree into a sequence using brackets to denote hierarchy, treating layout completion as a translation task.
  • Pointer Transformer: Utilizes a pointer mechanism to explicitly predict which existing node serves as the parent for a newly generated element, avoiding the ambiguity of bracketed sequences.
  • Recursive Transformer: This novel approach generates the tree top-down. It recursively applies the Transformer model to decode the children of each parent node.
The Recursive Transformer architecture utilizing ancestor states for top-down tree generation.

As illustrated in Figure 2, the Recursive Transformer employs "ancestry attention." This allows the model to "look up" the tree at its parents and grandparents (ancestor states) while deciding what to place next, ensuring the generated elements remain consistent with the global design context.

Technical Implementation

A critical finding in our research was the efficacy of discretization. Instead of predicting coordinates as continuous numbers (regression), we treated them as discrete "vocabulary" tokens (classification). This allowed the model to better handle the multi-modal nature of design, where elements often align to specific grid points or standard margins.

Experimental Setup and Metrics

Our models were trained on a dataset of over 55,000 high-quality Android UI layouts featuring 25 component types. To evaluate these models, we moved beyond standard machine learning metrics to introduce UX-Grounded Metrics.

We developed a Layout Tree Edit Distance based on the GOMS model (a classic Human-Computer Interaction framework). This metric estimates the physical effort—measured in keystrokes and mouse movements—a designer would actually need to expend to correct the model's predictions, providing a more practical measure of the system's utility.

Results and Discussion

The Pointer and Recursive Transformers significantly outperformed the Vanilla baseline across all tests. In a "Breadth-First" design flow, the Recursive Transformer achieved an F1 score of 86.41% when the layout was 80% complete. Even with minimal initial input (10% completion), the model provided meaningful suggestions, achieving a 15.23% F1 score.

When tasked with predicting just the single next element a designer might need, the Recursive model achieved 36.58% accuracy on nearly-finished layouts. This is a high mark given the massive search space of possible UI configurations.

Conclusion

While our models are excellent at predicting structure and component types, challenges remain in achieving pixel-perfect precision for bounding box dimensions. Future work will explore incorporating visual context—the actual pixels of the partial design—via CNN encoders to further refine predictions. By bridging deep learning and UX principles, these Transformer-based tree decoders represent a significant step toward intelligent, automated design assistance.

Summary updated

BibTeX
@misc{li2020auto,
  author = {Yang Li and Julien Amelot and Xin Zhou and Samy Bengio and Si Si},
  title = {{Auto Completion of User Interface Layout Design Using Transformer-Based Tree Decoders}},
  year = {2020},
  eprint = {2001.05308},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2001.05308},
}
Figure