EfficientUICoder: A Bidirectional Token Compression Framework for Efficient MLLM-Based UI Code Generation
Open Access
- 30 June 2026
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Software Engineering
- Vol. 3 (FSE) , 2396-2418
Abstract
Multimodal Large Language Models (MLLMs) have demonstrated exceptional performance in UI2Code tasks (i.e., generating code from UI mockups), significantly enhancing website development efficiency. However, UI2Code tasks incur substantially higher computational overhead compared to traditional code generation tasks. This overhead is primarily driven by the large number of input image tokens required to represent complex visual designs and the extensive volume of output code tokens needed to describe complete webpage structures. In this paper, we conduct a comprehensive preliminary study on popular MLLMs for UI2Code tasks, identifying significant redundancies in both image and code tokens. We observe that these redundancies not only exacerbate computational complexity but also hinder the model’s ability to focus on key UI elements, leading to excessively lengthy and often invalid HTML files. To address these challenges, we propose EfficientUICoder, a bidirectional compression framework designed for efficient UI code generation. First, we introduce an Element and Layout-aware Token Compression method, which preserves essential UI element and layout information by detecting element regions and constructing a UI element tree for efficient representation. Second, we design a Region-aware Token Refinement strategy that refines selected tokens by leveraging attention scores to evaluate semantic importance, discarding low-attention tokens from selected regions while integrating high-attention tokens from unselected regions. Third, we develop an Adaptive Duplicate Token Suppression mechanism, which dynamically modulates token probabilities during decoding by tracking HTML/CSS code structure frequencies and applying exponential penalty strategies to minimize repetitive generation. Extensive experiments demonstrate that EfficientUICoder achieves a 55%-60% compression ratio without compromising the quality of the generated webpages, effectively reducing output code redundancy. In terms of efficiency, EfficientUICoder achieves superior improvements, reducing computational cost by up to 44.9%, generated tokens by up to 41.4%, prefill time by up to 46.6%, and inference time by up to 48.8% on 34B-level MLLMs. Code is available at https://github.com/WebPAI/EfficientUICoder.Keywords
Funding Information
- The Senior Research Fellow Scheme of the Research Grants Council of the Hong Kong Special Administrative Region, China (No. SRFS2425-4S03)
- The General Research Fund of the Research Grants Council of the Hong Kong Special Administrative Region, China (No. CUHK 14209124)
- The Singapore Ministry of Education (MOE) Academic Research Fund (AcRF) Tier 1 grant (23-SIS-SMU-088)
- Hong Kong PhD Fellowship Scheme (No. PF23-87650)
This publication has 42 references indexed in Scilit:
- Interaction2Code: Benchmarking MLLM-based Interactive Webpage Code Generation from Interactive Prototyping2025
- Token Sugar: Making Source Code Sweeter for LLMs through Token-Efficient Shorthand2025
- WebCode2M: A Real-World Dataset for Code Generation from Webpage Designs2025
- An Image is Worth 1/2 Tokens After Layer 2: Plug-and-Play Inference Acceleration for Large Vision-Language Models2024
- When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Prevention2024
- Code generation from a graphical user interface via attention-based encoder–decoder modelMultimedia Systems, 2021
- UIED: a hybrid tool for GUI element detection2020
- Automatic HTML Code Generation from Mock-Up Images Using Machine Learning Techniques2019
- pix2code2018
- Reverse Engineering Mobile Application User Interfaces with REMAUI (T)2015