Web2Code: A Large-scale Webpage-to-Code Dataset and Evaluation Framework for Multimodal LLMs

Sukmin Yun∗,1,4, Haokun Lin∗,1, Rusiru Thushara∗,1, Mohammad Qazim Bhat∗,1,
Yongxin Wang  ,1, Zutao Jiang1, Mingkai Deng2, **hong Wang1, Tianhua Tao1,3,
Junbo Li1, Haonan Li1, Preslav Nakov1, Timothy Baldwin1, Zhengzhong Liu1,5,
Eric P. Xing1,2,5, Xiaodan Liang1,6, Zhiqiang Shen1
1MBZUAI, 2CMU, 3UIUC, 4HYU ERICA, 5Petuum, 6SYSU
https://mbzuai-llm.github.io/webpage2code/
Equal Contribution.
Abstract

Multimodal large language models (MLLMs) have shown impressive success across modalities such as image, video, and audio in a variety of understanding and generation tasks. However, current MLLMs are surprisingly poor at understanding webpage screenshots and generating their corresponding HTML code. To address this problem, we propose Web2Code, a benchmark consisting of a new large-scale webpage-to-code dataset for instruction tuning and an evaluation framework for the webpage understanding and HTML code translation abilities of MLLMs. For dataset construction, we leverage pretrained LLMs to enhance existing webpage-to-code datasets as well as generate a diverse pool of new webpages rendered into images. Specifically, the inputs are webpage images and instructions, while the responses are the webpage’s HTML code. We further include diverse natural language QA pairs about the webpage content in the responses to enable a more comprehensive understanding of the web content. To evaluate model performance in these tasks, we develop an evaluation framework for testing MLLMs’ abilities in webpage understanding and web-to-code generation. Extensive experiments show that our proposed dataset is beneficial not only to our proposed tasks but also in the general visual domain, while previous datasets result in worse performance. We hope our work will contribute to the development of general MLLMs suitable for web-based content generation and task automation. Our data and code are available at https://github.com/MBZUAI-LLM/web2code.

Refer to caption

Figure 1: Our motivation for constructing the Web2Code dataset stems from the limitations of previous models, such as LLaVA [33], which are trained on general datasets and struggle to generate high-quality webpages, as in the second row. Our dataset aims to significantly enhance the quality of webpage generation as in third row while maintaining a strong level of general multimodal ability.

1 Introduction

Multimodal large language models (MLLMs) have achieved explosive growth in the past few years. Leveraging the rich commonsense knowledge in large language models (LLMs), MLLMs are remarkably successful at processing and reasoning about various modalities such as image [2, 35], video [60, 53], and audio [40] in a broad range of tasks such as recognition [52], reasoning [59], and question-answering [39], all using language as the intermediate representation. However, existing MLLMs are surprisingly poor at understanding webpage screenshots and generating the HTML code to express their latent states. For instance, given the instruction “Parse the HTML code for this webpage”, the well-known LLaVA-1.5 [33] generates generic, pale code that fails to preserve most of the original webpage’s features (see Figure 1), which hampers its utility in applications such as UI prototy**, automation agents, and accessibility (e.g., noting available buttons and options given webpage screenshot).

The essential ingredients behind the progress in MLLMs are arguably large-scale instruction datasets [9, 63] and evaluation benchmarks [16, 58] – the former for aligning multimodal inputs with the massive knowledge in LLMs [27, 35], and the latter for standardized comparison which facilitates model development. However, existing instruction datasets and benchmarks typically focus on general settings (e.g., visual QA and reasoning) and pay insufficient attention to webpage understanding and webpage-to-code generation, which requires a unique combination of capabilities such as optical character recognition (OCR), spatial reasoning, and long-text generation, among others. While previous work has developed datasets for these tasks [4, 22], they lack instruction information and are unsuitable for integration with general-purpose MLLMs. On the other hand, popular benchmarks [36, 25] evaluate some of the required capabilities in isolation, but not fully in combination for visual parsing and reasoning over webpages.

To fill this gap, we propose a new instruction tuning dataset and evaluation suite named Web2Code. Web2Code contains a total of 1179.7k webpage based instruction-response pairs. The responses consist of not only the HTML code, but also the structured questions and answers about the webpage, which assist a model in better understanding its information. For dataset collection, we use GPT-3.5 and GPT-4 to clean existing data (e.g. WebSRC [10]) as well as to generate completely new webpages in HTML code. To evaluate the MLLM’s success at webpage understanding and HTML parsing, we propose the Webpage Understanding Benchmark (WUB) and Webpage Code Generation Benchmark (WCGB), two tasks that test the model’s abilities to answer questions about a webpage and generate its HTML code, respectively. For the latter task, we find that traditional text similarity metrics are insufficient for evaluating the fidelity of the generated code, and instead propose to render the output HTML back to a webpage screenshot, and use GPT-4V [42] to evaluate the quality of the resulting webpage [61].

To demonstrate the utility of our dataset, we train LLaVA-style MLLMs with our dataset included in the instruction finetuning stage. Quantitative results show that finetuning on our dataset not only clearly improves the image-to-HTML-code translation ability of the MLLM, but also leads to slight improvements in the model’s perception and reasoning abilities in general benchmarks. In contrast, including previous datasets without our data conversion leads to degraded general performance, suggesting our dataset is suitable for inclusion in MLLM instruction-tuning for additional capabilities without impacting existing ones.

2 Related Work

MLLM Dataset. At present, there is a substantial amount of large-scale visual instruction data, primarily generated using GPT. SVIT [63] and LRV-Instruction [32] are both generated by GPT4 based on manual prompts to adjust the instruction data, including rich high-quality dialogue question and answer, complex reasoning question and answer, reference question and answer, and image detail description task datasets; similarly, ShareGPT4V [9], LLaVAR [62], LVIS-Instruct4V [55] use GPT-4V [42] to generate millions of high-quality image-text pairs, aiming to enhance the perception, reasoning and planning capabilities of MLLM. Commonly used image data sources include LAION [48], CC [49], SBU [46], COCO [31], VG [21], VQAv2 [18].

MLLM. Instruction Tuning MLLM has made great progress in recent years. The structure of MLLM usually contains a visual encoder, vision-language map** module and LLM. LLaVA-v1.5 [33] only uses MLP as the vision-language map** module and the successful application of instruction tuning on MLLM has inspired people. The community has explored various feasible structures, which can be divided into attention structures BLIP2 [27], InstructBLIP [12], Qwen-VL [3], ShareGPT4V [9] and non-attention structures LLaVA [33], Shikra [8] according to the vision-language map** module. At the same time, various open source and more powerful LLMs, such as Vicuna1.5 [11], InternLM2 [5] also help MLLM achieve richer and more extensive instruction following capabilities. Qwen-VL [3], OtterHD [24], mPLUG-Owl [56], InternLM-XComposer2-4KHD [13] increase the resolution of images, while LLaVA-NeXT [34], Mini-Gemini [28], MM1 [41] split the input image into several image crops. In addition, BRAVE [19], MoVA [64], DeepSeek-VL [38], OmniFusion [17] apply supplementary vision encoders to obtain abundant visual features, e.g. DINOv2 [43], SAM [20]. Furthermore, more computer vision models are utilized for different tasks, which include image segmentation, detection and OCR, in MOAI [23], CuMo [26] and SpatialVLM [7]. Subsequently, MoE [30] was applied to MLLM to expand the scale of training data at the same computing scale.

Code Study. There are various code studies related to LLM. Sarker et al. [47] focused on generating code functions through formula hints, trying to improve the robustness of the syntax, and systematically tested the robustness of the syntax. From the perspective of security. Finkman et al. [15] said that these code assistance tools may inadvertently disclose the developer’s proprietary code to the code assistant service provider in the process of hel** development, thus they proposed a complementary method to reduce the risk of code leakage while providing effective advice to developers. In addition to code leakage, the code generated by LLM has also caused concerns in industries and other fields. To address this issue, Ye et al. [57] proposed a new zero-shot synthetic code detector based on the similarity between code and its rewritten variants. In the evaluation work on code generation, Du et al. [14] proposed a new computational efficiency benchmark Mercury and a new metric Beyond for the efficiency evaluation of code. They experimentally showed that direct preference optimization can be used as a robust baseline for improving computational efficiency compared to supervised fine-tuning, which paves a promising path for future exploration of efficient code generation.

3 Dataset Construction

Overview. Our Web2Code instruction tuning dataset construction and instruction generation process involves four key components: (1) Creation of new webpage image-code pair data: We generated high-quality HTML webpage-code pairs following the CodeAlpaca prompt [6] using GPT-3.5 and convert them into instruction-following data. (2) Refinement of existing webpage code generation data: We transform existing datasets including WebSight [22] and Pix2Code [4] into an instruction-following data format similar to LLaVA data [33], so they can be used as instruction-following data to train MLLMs. (3) Creation of a new text question-answer pair data: We generated a new question-answer pair dataset utilizing our new GPT-3.5 generated data from (1) for webpage understanding. (4) Refinement of existing webpage understanding data: We refine the WebSRC [10] question-answer data to improve its quality using the GPT-4. Each component is elaborated in detail as follows:

Refer to caption

Figure 2: Qualitative example of generated question-answer pair dataset. Questions cover diverse aspects of the web page understanding.

Refer to caption

Figure 3: WebSRC data refinement for improved Quality. Left: Before refinement; Right: After refinement, the quality has been improved and duplications have been excluded.

DWCG: Creation of new webpage image-code pair data for code generation. To augment our dataset with high-quality data, we employed GPT-3.5 to generate 60K HTML pages following the guidelines and prompts in CodeAlpaca [6]. Using Selenium WebDriver, we then created web image screenshots from the generated HTML code. These web image-code pairs were subsequently converted into an instruction-following data format similar to the LLaVA data format [33], enabling their use in training Multimodal Large Language Models (MLLMs). The example of the instruction is shown in Figure 16. The generation of instruction was done in two stages using prompts fed to GPT-4: (a) During stage 1, the prompt shown in Figure 12 resulted in the creation of generic instructions. (b) This was followed by augmenting the instruction from (a) with the GPT generated instructions using the prompt shown in Figure 13 to include stylistic information. This allowed the model to learn two styles: Modern and Bootstrap style as shown in Figure 21 and Figure 22, respectively.

DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT: Refinement of existing webpage code generation data. To enhance the capability of our model in the task of HTML code generation, we leverage the Pix2code [4] and WebSight [22] datasets. To mitigate the detrimental impact on model performance from random letters in Pix2Code data, we replace these random letters with meaningful text using GPT-4, thereby refining the webpages into diverse webpages encompassing product landing pages, personal portfolios, blogs, and other categories. We then visually rendered each sample by taking screenshots of the browser view of each webpage. Further, we convert all these data into LLaVA instruction following data format using the same strategy as used for DWCG. We note that DWCG and WebSight webpages follow Modern style while Pix2Code follow Bootstrap style.

DWU: Creation of a new question-answer pair data for webpage understanding. For the purpose of fine-tuning our models through an instruction-following manner, we utilized the capabilities of GPT-4 to generate webpage code-based question-answer pairs. We generated 10 question-answer pairs using GPT-4 for a subset of 24.35K webpage data, resulting in a total of 243.5K question-answer data points. This includes, a set of 230K question-answer pairs for GPT-3.5 based webpages, a set of 13.5K newly generated question answer pairs for refined Pix2Code images. These pairs were meticulously crafted to align with our image-based evaluation criteria, ensuring that each question probes specific aspects of the visual and content quality reflected in the generated web images. This strategy enhances the model’s performance by integrating a nuanced understanding of the evaluation parameters into its learning process. Figure  2 shows a qualitative example from our generated question-answer pairs. The prompt used for question-answer generation is shown in Figure 11.

DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT: Refinement of existing webpage understanding data. To increase our instruction-following dataset with high-quality instruction-following examples for webpages, we integrated the WebSRC dataset into our training regime. Prior to inclusion, we meticulously filtered the existing question-and-answer pairs from the WebSRC dataset to ensure relevance and quality. This involves duplication removal and quality optimization as shown in Figure 3. Specifically, we found that WebSRC data contains several questions related to the same answer. To this end, we first removed those duplicates and then employed GPT-4 to assess and enhance the quality of answers. This process not only refined the dataset into 51.5K high-quality instruction data but also ensured that the model’s training was influenced by high-fidelity, instructionally sound data, thereby improving its ability to follow complex web-based instructions.

3.1 Statistics and Analysis

Figure 5 shows the word cloud of the answer set of our question-answer dataset. The word cloud highlights the most frequently occurring terms, with "section," "color", "button", and "website" being the most prominent, indicating a strong emphasis on structural and design elements in the data. This reflects the detailed focus on the layout and visual aspects of the dataset.

Figure 5 illustrates the distribution of the most common HTML tags in our GPT-3.5 generated HTML data. The distribution shows a high frequency of essential structural tags such as <div>, <p>, <meta>, <img>, and <a>, indicating that the generated pages include a diverse range of elements necessary for rich and varied web content. The significant presence of <h2>, <input>, <html>, <head>, and <body> tags further reinforces the completeness and structural integrity of the generated HTML documents.

To estimate the difficulty levels of our HTML-based webpage dataset, we provide several quantitative measures and compare them with recent and similar existing datasets, namely WebSight [22], Design2Code [50], and Pix2Code [4] (See Table 1).

Design2Code is primarily used for testing and has a small size of 484 examples, limiting its versatility and robustness. In contrast, our dataset, intended for both training and testing, is significantly larger (884.7K examples) and more complex, making it more suitable for develo** robust models. Overall, our benchmark examples are more challenging and cover a broader spectrum of complexities compared to prior efforts such as WebSight.

Dataset WebSight [22] Design2Code [50] Pix2Code [4] DWCG (ours) DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT (ours)
Instruction - - -
Source Synthetic Real-World Synthetic Synthetic Synthetic
Size 823K 484 1.7K 60K 824.7K
Avg Length (tokens) 647±plus-or-minus\pm±216 31216±plus-or-minus\pm±23902 658.7±plus-or-minus\pm±98.0 471.8±plus-or-minus\pm±162.3 652.85±plus-or-minus\pm±157.0
Avg Tag Count 19±plus-or-minus\pm±8 158±plus-or-minus\pm±100 51.6±plus-or-minus\pm±8.0 28.1±plus-or-minus\pm±10.6 35.3±plus-or-minus\pm±9.0
Avg DOM Depth 5±plus-or-minus\pm±1 13±plus-or-minus\pm±5 8.0±plus-or-minus\pm±0.0 5.3±plus-or-minus\pm±1.0 6.5±plus-or-minus\pm±1.0
Avg Unique Tags 10±plus-or-minus\pm±3 22±plus-or-minus\pm±6 17.0±plus-or-minus\pm±0.0 13.6±plus-or-minus\pm±2.7 13.5±plus-or-minus\pm±2.5
Table 1: Comparison of dataset statistics among webpage code generation datasets: WebSight, Design2Code, Pix2Code, our DWCG, and our DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT. DWCG is a newly generated GPT-3.5-based dataset, while DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT is the refined dataset that utilizes WebSight and Pix2Code datasets.

3.2 Distribution

Dataset DWU DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT
Instruction
Size 243.5K 51.5K
Table 2: Distribution of DWU and DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT datasets. Both datasets include high-quality question-answer pairs for webpage understanding.

Our instruction-following dataset contains 1,179.7K instruction data points. This includes 884.7K website image-code pairs and 295K question-answer pairs.

The 295K question-answer pairs consist of 243.5K GPT-4 based question-answer pairs (DWU Data) and 51.5K question-answer pairs from WebSRC image-based data, as shown in Table 2. Our evaluation dataset comprises 1,198 webpage screenshot images, sourced from diverse origins, including WebSight, Pix2Code, GPT-3.5 based data, and manual processes, ensuring a broad representation of web content. Additionally, we utilize 5,990 "yes" / "no" question-answer pairs generated from the GPT-4 Vision API for our Webpage Understanding Benchmark, as shown in Section 6.

Refer to caption
Figure 4: Word Cloud for the answer set of the GPT4 based DWU dataset.
Refer to caption
Figure 5: The distribution of most common 20 tags in GPT-3.5 based HTML data.

4 A New Evaluation Framework for Webpage

Our proposed evaluation framework includes two schemes: (1) Webpage Understanding Benchmark (WUB): An offline evaluation using "yes" / "no" questions. (2) Webpage Code Generation Benchmark (WCGB): An online evaluation (using GPT-4 Vision) based on image similarity.

4.1 Evaluation Metric for HTML Code Generation

In the realm of assessing code quality, particularly in terms of final visual appeal and overall functionality, existing methods that rely on code similarity metrics fall short. These traditional approaches often lack the precision and reliability needed for nuanced evaluations of code effectiveness. To address these shortcomings, we have developed a novel approach: regenerating the webpage using the model’s predicted HTML code and capturing screenshots of these generated webpages. This process, automated using the Selenium WebDriver extension in Python, shifts the focus from the less reliable code similarity assessments to a more accurate and visually oriented method. By comparing images of the generated webpages, we can more effectively evaluate the aesthetic and functional aspects of the code, offering a more comprehensive understanding of its quality.

Refer to caption

Figure 6: Evaluation benchmark for webpage generation and webpage understanding. Left: WCGB utilizes GPT4 Vision based online evaluation for image level comparison; Right: WUB employs an offline evaluation based on question-answer pairs.

We propose two benchmarks for assessing webpage understanding and code generation capabilities.

WUB: This benchmark comprises 5,990 high-quality question-answer pairs generated from GPT-4 Vision API (See prompt 15), based on 1,198 webpage screenshot images, where each answer is either "yes" or "no". These images are sourced from diverse data origins, including WebSight, Pix2Code, GPT-3.5, and manual processes, ensuring a broad representation of web content. Figure 10 shows a qualitative sample data we used for WUB. We test these pairs on various multimodal image understanding models by comparing the predicted answers to the ground truth, with the final accuracy score serving as the evaluation metric as depicted on the right side of Figure 6. Qualitative data examples in our WUB benchmark are shown in Figure 10.

WCGB: Utilizing the same images as the WUB, this benchmark evaluates a multimodal model tasked with generating HTML code from webpage images based on specific instructions. Unlike traditional code-level evaluations, this benchmark assesses the generated webpage’s fidelity at the image level. We convert the predicted HTML codes back into images using Selenium WebDriver to allow a direct visual comparison with the ground truth images. The evaluation, depicted on the left side of Figure 6, considers 10 different aspects, which are further categorized into four evaluation matrices using the GPT-4 Vision API. This image-level evaluation provides a more accurate measure of the model’s code generation capabilities, acknowledging that identical webpages can be constructed from varying codes. The prompt used for evaluation is shown in Figure 14. This framework consists of 10 distinct criteria, which we group into four categories, each encompassing specific criteria that are scored on a 0-10 scale, as shown in Section D of Appendix.

4.2 Quantitative Evaluation for HTML Code Generation of MLLMs

We have evaluated the trained models using various data configurations and backbones on our WUB and WCGB benchmarks. The performance of the models on the code generation benchmark is presented in Table 3, while the results for webpage understanding are shown in Table 4.

LLM Backbone DWCG DWU DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT VSA \uparrow CAD \uparrow TCC \uparrow UII \uparrow Overall \uparrow
CystalCoder-7B [37] - - - - 3.832 3.678 3.411 3.992 3.728
- - - 7.812 7.899 8.138 8.112 7.990
- - 8.010 8.102 8.266 8.124 8.126
8.023 8.071 8.321 8.334 8.187
CrystalChat-7B [37] - - - - 4.714 4.572 4.865 5.147 4.825
- - 7.900 8.001 8.204 8.215 8.080
8.384 8.287 8.417 8.488 8.394
Vicuna1.5-7B [11] - - - - 3.042 3.250 3.333 3.167 3.198
7.876 7.687 7.267 7.563 7.598
LLaMA3-8B [1] 8.522 8.564 8.421 8.611 8.530
Table 3: The performance of different LLM backbones under various data configurations on our Webpage Code Generation Benchmark (WCGB). "VSA" denotes Visual Structure and Alignment, "CAD" represents Color and Aesthetic Design, "TCC" represents Textual and Content Consistency, and "UII" denotes User Interface and Interactivity.
LLM Backbone DWCG DWU DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT Accuracy (%)
CrystalCoder-7B [37] - - - - 73.54
- - - 71.81
- - 73.74
73.61
CrystalChat-7B [37] - - - - 73.94
- - 73.48
74.14
Vicuna1.5-7B [11] - - - - 71.12
71.23
LLaMA3-8B [1] 74.84
Table 4: The accuracy of webpage understanding under various data configurations and LLM backbones. All models are instruction-tuned and evaluated on our WUB benchmark. We note that the general domain data (i.e., LLaVA) is included in all data configuration as default.

To be specific, our dataset components have an orthogonal contribution to the overall improvements on both the WUB and the WCGB benchmarks. Table 3 demonstrates improvements in webpage code generation quality when adding DWU, DWCG + DWU, and DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT + DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT. For example, the results based on instruction-tuned CrystalChat show step-wise improvements on the WCGB benchmark when adding DWCG + DWU, and DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT + DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT (4.825\rightarrow8.080\rightarrow8.530 on the overall metric). Interestingly, the instruction-tuned CrystalChat-7B with the general domain data only shows poor WCGB performances while it shows on par WUB performance compared to the use of further webpage datasets. Similar trends are also found in the Vicuna1.5-7B backbone, while adding the proposed dataset shows significant improvements, achieving an overall score of 7.598.

Similarly, Table 4 further demonstrates the effectiveness of the proposed dataset on the webpage comprehension capabilities. For example, the four rows of the instruction-tuned CrystalCoder-7B show that not only using DWCG with DWU can prevent degradation in language understanding, but also the full components even enhance the webpage comprehension capabilities. Overall, we found the proposed dataset can enhance both webpage understanding capability and webpage code generation abilities under various LLM backbones, and LLaMA3-8B archives the best performance among all on both webpage code generation and webpage understanding.

4.3 Visualizations for Qualitative Evaluation

As shown in Figure 7, we compare the results between the original image which is the real-world webpage sample, the rendered image generated by using LLM backbones of Vicuna1.5-7B and CrystalChat-7B, respectively. CrystalChat-7B is a code-enhanced LLM and our visualization demonstrates that it achieves the better quality of generation than Vicuna1.5-7B even the performance is slightly worse on general multimodal domain, as presented in Table 6. Moreover, as in Figure 9, our rendered webpage from the model trained on our web dataset closely resembles the original image, indicating the positive impact of the web2code dataset. We further visualize our generation in Figure 9 when the input is a hand-drawn webpage to examine the adaptation ability of our model.

Refer to caption
(a) Original
Refer to caption
(b) Our Vicuna1.5-7B
Refer to caption
(c) Our CrystalChat-7B
Figure 7: Visualization comparison using different backbones. Using the code-enhanced LLM backbone CrystalChat-7B achieves better quality of generation than Vicuna1.5-7B.
Refer to caption
(a) Original
Refer to caption
(b) GT-Code to Image
Refer to caption
(c) Ours
Figure 8: Visualization comparison between ground-truth code generated image and our result. The style and layout of the generated webpage image are similar to the ground-truth image.
Refer to caption
(a) Hand drawn webpage and our generation
Refer to caption
(b) Hand drawn webpage and our generation
Figure 9: Visualization of our CrystalChat-7B generation when the input is a hand-drawn webpage.

5 General Evaluation of MLLMs Using Web2Code

Setup and Overview. Our model training framework mainly follows the design of LLaVA-1.5 [33] where we leverage the capabilities of both a pre-trained visual encoder, an LLM and a projector to connect visual features into the word embedding space. The model consists of (1) a pre-trained CLIP ViT-L/14 [44] visual encoder with a resolution of 336×\times×336 and a patch size of 14, which has good feature representation already aligned with the text embedding space. (2) As for the LLM backbones, we leverage CrystalChat [37] as the base model and compare it with other latest LLM backbones like Vicuna1.5 [11], LLaMA2 [54], LLaMA3 [1] and CrystalCoder [37]111CrystalCoder [37] and CrystalChat [37] are an open-source code LLM pre-trained and instruction-tuned models, respectively. They are trained on publicly available language and code datasets.. Training details and hyperparameters are presented in the Appendix A.

General Evaluation Metrics for MLLMs. MME [16] serves as an extensive evaluative benchmark, aiming to assess the perceptual and cognitive capability of MLLMs within 14 sub-tasks. Additionally, we also evaluate the performance of our models on text-oriented visual question-answering tasks employing a diverse set of benchmark datasets including ScienceQA [39] and TextVQA [51]. Furthermore, We assess our models’ ability toward anti-hallucination through POPE [29].

LLM Backbone DWU DWCG DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT MME-P MME-C POPE SciQA TextVQA
CrystalChat-7B [37] - - - - 1456.53 308.21 86.86 67.77 57.84
- - - 1438.51 292.14 87.10 68.27 58.15
- - 1478.82 297.14 86.13 67.92 57.41
1449.54 279.64 86.53 68.32 57.86
Table 5: Component analysis on CrystalChat-7B backbone under various data configurations. We note that the general domain data (i.e., LLaVA) is included in all data configuration as default.

Effects of Web2Code on General Domain. Here, we first perform instruction tuning using Web2Code on various LLM backbones and then we evaluate those MLLMs on the general domain of visual language understanding. Throughout extensive experiments under various data configurations, we observed that the proposed dataset Web2Code can be incorporated with the conventional visual language instruction tuning dataset of LLaVA [33] without harming performances on the general domain. Table 5 summarizes the results222We observe that the conventional visual language domain data (i.e., LLaVA) is a crucial component for visual language understanding, i.e., instruction-tuned MLLMs without the general domain data are weak.. Specifically, both proposed Web Understanding data (DWU or DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT) and Web Code Generation data (DWCG or DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT) do not hurt or even can be beneficial to the visual language understanding. For example, we observed that adding DWU to CrystalChat achieves comparable or even better performances on POPE (86.86\rightarrow87.10), SciQA (67.77\rightarrow68.27), and TextVQA (57.84\rightarrow58.15). Somewhat surprisingly, we further found that adding DWCG can even improve visual language understanding. For example, the second and third rows of CrystalChat show +40.31 and +5.00 points higher improvements in MME-P and MME-C benchmarks, respectively. Moreover, adding refined data DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT and DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT are still effective in the visual language domain, by achieving comparable (or even better) performances on overall benchmarks. For example, the last row indicates that adding DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT and DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT preserves comparable performances on overall benchmarks and even achieves +0.4 higher points on the SciQA benchmark.

6 Conclusion

We have presented Web2Code, a benchmark that consists of a high-quality, large-scale webpage-to-code instruction tuning dataset containing 1179.7k entries and an evaluation suite for the webpage understanding and webpage-to-HTML translation abilities of MLLMs. Through extensive experiments, we have demonstrated that our proposed dataset is clearly effective at enhancing these abilities of MLLMs as well as general visual proficiency, while existing datasets lead to inferior performance. We hope our work will attract the community’s attention and facilitate progress toward foundation models serving as virtual assistants for content generation and task automation.

Limitations and Ethics Statement. The Web2Code project provides a comprehensive dataset and evaluation framework for fine-grained multimodal large language models. This can significantly enhance the capabilities of LLMs in understanding and generating web code from instructions, leading to advancements in web development automation, improved coding assistance tools and platforms. By enabling more accurate and context-aware code generation, it can boost productivity for developers and make coding more accessible to beginners. However, the primary limitations of the Web2Code include the potential for biased dataset that may not cover all possible HTML coding scenarios, potentially leading to gaps in model performance, some webpages that include humans may be privacy sensitive. Ensuring high-quality annotations and comprehensive coverage of all possible HTML and code structures is challenging. Also, handling complex, real-world HTML and code scenarios might still be beyond the current capabilities of the models trained on this dataset. Moreover, the proposed evaluation framework may not capture all aspects of the code generation quality, such as code efficiency, readability, or adherence to best practices.

Acknowledgements

We are thankful to Veselin Stoyanov for discussions on multimodal large language models. We also thank the support provided by the MBZUAI IT/corporate service teams (Ian Mathews, John Murphy, Padma Pavani, Tapas Sen, Walid Omari) and CIAI engineering team (Guowei He, Yun Xu, Yue Peng) for organizing High Performance Computing resources and services. Z.S. and E.X. would like to thank the MBZUAI-WIS Joint Program for AI Research. Z.S. also would like to thank the Google Research award grant for the support.

References

  • AI@Meta [2024] AI@Meta. Llama 3 model card. 2024. URL https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md.
  • Alayrac et al. [2022] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. NeurIPS, 2022.
  • Bai et al. [2023] **ze Bai, Shuai Bai, Shusheng Yang, Shijie Wang, Sinan Tan, Peng Wang, Junyang Lin, Chang Zhou, and **gren Zhou. Qwen-vl: A versatile vision-language model for understanding, localization, text reading, and beyond, 2023.
  • Beltramelli [2017] Tony Beltramelli. pix2code: Generating code from a graphical user interface screenshot. arXiv preprint arXiv:1705.07962, 2017.
  • Cai et al. [2024] Zheng Cai, Maosong Cao, Haojiong Chen, Kai Chen, Keyu Chen, Xin Chen, Xun Chen, Zehui Chen, Zhi Chen, Pei Chu, et al. Internlm2 technical report. arXiv preprint arXiv:2403.17297, 2024.
  • Chaudhary [2023] Sahil Chaudhary. Code alpaca: An instruction-following llama model for code generation. https://github.com/sahil280114/codealpaca, 2023.
  • Chen et al. [2024] Boyuan Chen, Zhuo Xu, Sean Kirmani, Brian Ichter, Danny Driess, Pete Florence, Dorsa Sadigh, Leonidas Guibas, and Fei Xia. Spatialvlm: Endowing vision-language models with spatial reasoning capabilities. arXiv preprint arXiv:2401.12168, 2024. URL https://arxiv.longhoe.net/abs/2401.12168.
  • Chen et al. [2023a] Keqin Chen, Zhao Zhang, Weili Zeng, Richong Zhang, Feng Zhu, and Rui Zhao. Shikra: Unleashing multimodal llm’s referential dialogue magic, 2023a.
  • Chen et al. [2023b] Lin Chen, Jisong Li, Xiaoyi Dong, Pan Zhang, Conghui He, Jiaqi Wang, Feng Zhao, and Dahua Lin. Sharegpt4v: Improving large multi-modal models with better captions. arXiv preprint arXiv:2311.12793, 2023b.
  • Chen et al. [2021] Xingyu Chen, Zihan Zhao, Lu Chen, Danyang Zhang, Jiabao Ji, Ao Luo, Yuxuan Xiong, and Kai Yu. Websrc: A dataset for web-based structural reading comprehension. arXiv preprint arXiv:2101.09465, 2021.
  • Chiang et al. [2023] Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with 90%* chatgpt quality, March 2023. URL https://lmsys.org/blog/2023-03-30-vicuna/.
  • Dai et al. [2024] Wenliang Dai, Junnan Li, Dongxu Li, Anthony Meng Huat Tiong, Junqi Zhao, Weisheng Wang, Boyang Li, Pascale N Fung, and Steven Hoi. Instructblip: Towards general-purpose vision-language models with instruction tuning. NeurIPS, 36, 2024.
  • Dong et al. [2024] Xiaoyi Dong, Pan Zhang, Yuhang Zang, Yuhang Cao, and et al Bin Wang. Internlm-xcomposer2-4khd: A pioneering large vision-language model handling resolutions from 336 pixels to 4k hd, 2024.
  • Du et al. [2024] Mingzhe Du, Anh Tuan Luu, Bin Ji, and See-Kiong Ng. Mercury: An efficiency benchmark for llm code synthesis. arXiv preprint arXiv:2402.07844, 2024.
  • Finkman et al. [2024] Amit Finkman, Eden Bar-Kochva, Avishag Shapira, Dudu Mimran, Yuval Elovici, and Asaf Shabtai. Codecloak: A method for evaluating and mitigating code leakage by llm code assistants. arXiv preprint arXiv:2404.09066, 2024.
  • Fu et al. [2023] Chaoyou Fu, Peixian Chen, Yunhang Shen, Yulei Qin, Mengdan Zhang, Xu Lin, **rui Yang, Xiawu Zheng, Ke Li, Xing Sun, Yunsheng Wu, and Rongrong Ji. Mme: A comprehensive evaluation benchmark for multimodal large language models, 2023.
  • Goncharova et al. [2024] Elizaveta Goncharova, Anton Razzhigaev, Matvey Mikhalchuk, Maxim Kurkin, Irina Abdullaeva, Matvey Skripkin, Ivan Oseledets, Denis Dimitrov, and Andrey Kuznetsov. Omnifusion technical report, 2024.
  • Goyal et al. [2017] Yash Goyal, Tejas Khot, Douglas Summers-Stay, Dhruv Batra, and Devi Parikh. Making the v in vqa matter: Elevating the role of image understanding in visual question answering, 2017.
  • Kar et al. [2024] Oğuzhan Fatih Kar, Alessio Tonioni, Petra Poklukar, Achin Kulshrestha, Amir Zamir, and Federico Tombari. Brave: Broadening the visual encoding of vision-language models, 2024.
  • Kirillov et al. [2023] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C. Berg, Wan-Yen Lo, Piotr Dollár, and Ross Girshick. Segment anything, 2023.
  • Krishna et al. [2016] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A. Shamma, Michael S. Bernstein, and Fei-Fei Li. Visual genome: Connecting language and vision using crowdsourced dense image annotations, 2016.
  • Laurençon et al. [2024] Hugo Laurençon, Léo Tronchon, and Victor Sanh. Unlocking the conversion of web screenshots into html code with the websight dataset. arXiv preprint arXiv:2403.09029, 2024.
  • Lee et al. [2024] Byung-Kwan Lee, Beomchan Park, Chae Won Kim, and Yong Man Ro. Moai: Mixture of all intelligence for large language and vision models, 2024.
  • Li et al. [2023a] Bo Li, Peiyuan Zhang, **gkang Yang, Yuanhan Zhang, Fanyi Pu, and Ziwei Liu. Otterhd: A high-resolution multi-modality model, 2023a.
  • Li et al. [2023b] Bohao Li, Rui Wang, Guangzhi Wang, Yuying Ge, Yixiao Ge, and Ying Shan. Seed-bench: Benchmarking multimodal llms with generative comprehension. arXiv preprint arXiv:2307.16125, 2023b.
  • Li et al. [2024a] Jiachen Li, Xinyao Wang, Sijie Zhu, Chia-Wen Kuo, Lu Xu, Fan Chen, Jitesh Jain, Humphrey Shi, and Longyin Wen. Cumo: Scaling multimodal llm with co-upcycled mixture-of-experts, 2024a.
  • Li et al. [2023c] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. Blip-2: Bootstrap** language-image pre-training with frozen image encoders and large language models. In International conference on machine learning, pages 19730–19742. PMLR, 2023c.
  • Li et al. [2024b] Yanwei Li, Yuechen Zhang, Chengyao Wang, Zhisheng Zhong, Yixin Chen, Ruihang Chu, Shaoteng Liu, and Jiaya Jia. Mini-gemini: Mining the potential of multi-modality vision language models, 2024b.
  • Li et al. [2023d] Yifan Li, Yifan Du, Kun Zhou, **peng Wang, Wayne Xin Zhao, and Ji-Rong Wen. Evaluating object hallucination in large vision-language models, 2023d.
  • Lin et al. [2024] Bin Lin, Zhenyu Tang, Yang Ye, Jiaxi Cui, Bin Zhu, Peng **, Junwu Zhang, Munan Ning, and Li Yuan. Moe-llava: Mixture of experts for large vision-language models. arXiv preprint arXiv:2401.15947, 2024.
  • Lin et al. [2015] Tsung-Yi Lin, Michael Maire, Serge Belongie, Lubomir Bourdev, Ross Girshick, James Hays, Pietro Perona, Deva Ramanan, C. Lawrence Zitnick, and Piotr Dollár. Microsoft coco: Common objects in context, 2015.
  • Liu et al. [2023a] Fuxiao Liu, Kevin Lin, Linjie Li, Jianfeng Wang, Yaser Yacoob, and Lijuan Wang. Mitigating hallucination in large multi-modal models via robust instruction tuning. In The Twelfth International Conference on Learning Representations, 2023a.
  • Liu et al. [2023b] Haotian Liu, Chunyuan Li, Yuheng Li, and Yong Jae Lee. Improved baselines with visual instruction tuning. arXiv preprint arXiv:2310.03744, 2023b.
  • Liu et al. [2024a] Haotian Liu, Chunyuan Li, Yuheng Li, Bo Li, Yuanhan Zhang, Sheng Shen, and Yong Jae Lee. Llava-next: Improved reasoning, ocr, and world knowledge, January 2024a. URL https://llava-vl.github.io/blog/2024-01-30-llava-next/.
  • Liu et al. [2024b] Haotian Liu, Chunyuan Li, Qingyang Wu, and Yong Jae Lee. Visual instruction tuning. Advances in neural information processing systems, 36, 2024b.
  • Liu et al. [2023c] Yuan Liu, Haodong Duan, Yuanhan Zhang, Bo Li, Songyang Zhang, Wangbo Zhao, Yike Yuan, Jiaqi Wang, Conghui He, Ziwei Liu, et al. Mmbench: Is your multi-modal model an all-around player? arXiv preprint arXiv:2307.06281, 2023c.
  • Liu et al. [2023d] Zhengzhong Liu, Aurick Qiao, Willie Neiswanger, Hongyi Wang, Bowen Tan, Tianhua Tao, Junbo Li, Yuqi Wang, Suqi Sun, Omkar Pangarkar, Richard Fan, Yi Gu, Victor Miller, Yonghao Zhuang, Guowei He, Haonan Li, Fajri Koto, Li** Tang, Nikhil Ranjan, Zhiqiang Shen, Xuguang Ren, Roberto Iriondo, Cun Mu, Zhiting Hu, Mark Schulze, Preslav Nakov, Tim Baldwin, and Eric P. Xing. Llm360: Towards fully transparent open-source llms, 2023d.
  • Lu et al. [2024] Haoyu Lu, Wen Liu, Bo Zhang, Bingxuan Wang, Kai Dong, Bo Liu, **gxiang Sun, Tongzheng Ren, Zhuoshu Li, Hao Yang, Yaofeng Sun, Chengqi Deng, Hanwei Xu, Zhenda Xie, and Chong Ruan. Deepseek-vl: Towards real-world vision-language understanding, 2024.
  • Lu et al. [2022] Pan Lu, Swaroop Mishra, Tony Xia, Liang Qiu, Kai-Wei Chang, Song-Chun Zhu, Oyvind Tafjord, Peter Clark, and Ashwin Kalyan. Learn to explain: Multimodal reasoning via thought chains for science question answering. In The 36th Conference on Neural Information Processing Systems (NeurIPS), 2022.
  • Lyu et al. [2023] Chenyang Lyu, Minghao Wu, Longyue Wang, Xinting Huang, Bingshuai Liu, Zefeng Du, Shuming Shi, and Zhaopeng Tu. Macaw-llm: Multi-modal language modeling with image, audio, video, and text integration. arXiv preprint arXiv:2306.09093, 2023.
  • McKinzie et al. [2024] Brandon McKinzie, Zhe Gan, Jean-Philippe Fauconnier, Sam Dodge, Bowen Zhang, Philipp Dufter, and et al. Mm1: Methods, analysis & insights from multimodal llm pre-training, 2024.
  • OpenAI [2024] OpenAI. Gpt-4 technical report, 2024.
  • Oquab et al. [2023] Maxime Oquab, Timothée Darcet, Theo Moutakanni, Huy V. Vo, Marc Szafraniec, Vasil Khalidov, Pierre Fernandez, Daniel Haziza, Francisco Massa, Alaaeldin El-Nouby, Russell Howes, Po-Yao Huang, Hu Xu, Vasu Sharma, Shang-Wen Li, Wojciech Galuba, Mike Rabbat, Mido Assran, Nicolas Ballas, Gabriel Synnaeve, Ishan Misra, Herve Jegou, Julien Mairal, Patrick Labatut, Armand Joulin, and Piotr Bojanowski. Dinov2: Learning robust visual features without supervision, 2023.
  • Radford et al. [2021] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR, 2021.
  • Roziere et al. [2023] Baptiste Roziere, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi, **gyu Liu, Tal Remez, Jérémy Rapin, et al. Code llama: Open foundation models for code. arXiv preprint arXiv:2308.12950, 2023.
  • Saleh and Elgammal [2015] Babak Saleh and Ahmed Elgammal. Large-scale classification of fine-art paintings: Learning the right metric on the right feature. arXiv preprint arXiv:1505.00855, 2015.
  • Sarker et al. [2024] Laboni Sarker, Mara Downing, Achintya Desai, and Tevfik Bultan. Syntactic robustness for llm-based code generation. arXiv preprint arXiv:2404.01535, 2024.
  • Schuhmann et al. [2021] Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. Laion-400m: Open dataset of clip-filtered 400 million image-text pairs. arXiv preprint arXiv:2111.02114, 2021.
  • Sharma et al. [2018] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2556–2565, 2018.
  • Si et al. [2024] Chenglei Si, Yanzhe Zhang, Zhengyuan Yang, Ruibo Liu, and Diyi Yang. Design2code: How far are we from automating front-end engineering? arXiv preprint arXiv:2403.03163, 2024.
  • Sidorov et al. [2020] Oleksii Sidorov, Ronghang Hu, Marcus Rohrbach, and Amanpreet Singh. Textcaps: a dataset for image captioning with reading comprehension, 2020.
  • Singh et al. [2019] Amanpreet Singh, Vivek Natarajan, Meet Shah, Yu Jiang, Xinlei Chen, Dhruv Batra, Devi Parikh, and Marcus Rohrbach. Towards vqa models that can read. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 8317–8326, 2019.
  • Sun et al. [2023] Quan Sun, Yufeng Cui, Xiaosong Zhang, Fan Zhang, Qiying Yu, Zhengxiong Luo, Yueze Wang, Yongming Rao, **g**g Liu, Tiejun Huang, et al. Generative multimodal models are in-context learners. arXiv preprint arXiv:2312.13286, 2023.
  • Touvron et al. [2023] Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023.
  • Wang et al. [2023] Junke Wang, Lingchen Meng, Zejia Weng, Bo He, Zuxuan Wu, and Yu-Gang Jiang. To see is to believe: Prompting gpt-4v for better visual instruction tuning. arXiv preprint arXiv:2311.07574, 2023.
  • Ye et al. [2023] Qinghao Ye, Haiyang Xu, Jiabo Ye, Ming Yan, Anwen Hu, Haowei Liu, Qi Qian, Ji Zhang, Fei Huang, and **gren Zhou. mplug-owl2: Revolutionizing multi-modal large language model with modality collaboration, 2023.
  • Ye et al. [2024] Tong Ye, Yangkai Du, Tengfei Ma, Lingfei Wu, Xuhong Zhang, Shouling Ji, and Wenhai Wang. Uncovering llm-generated code: A zero-shot synthetic code detector via code rewriting. arXiv preprint arXiv:2405.16133, 2024.
  • Yue et al. [2023] Xiang Yue, Yuansheng Ni, Kai Zhang, Tianyu Zheng, Ruoqi Liu, Ge Zhang, Samuel Stevens, Dongfu Jiang, Weiming Ren, Yuxuan Sun, et al. Mmmu: A massive multi-discipline multimodal understanding and reasoning benchmark for expert agi. arXiv preprint arXiv:2311.16502, 2023.
  • Zellers et al. [2019] Rowan Zellers, Yonatan Bisk, Ali Farhadi, and Ye** Choi. From recognition to cognition: Visual commonsense reasoning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 6720–6731, 2019.
  • Zhang et al. [2023a] Hang Zhang, Xin Li, and Lidong Bing. Video-LLaMA: An instruction-tuned audio-visual language model for video understanding. In Yansong Feng and Els Lefever, editors, Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, 2023a.
  • Zhang et al. [2023b] Xinlu Zhang, Yujie Lu, Weizhi Wang, An Yan, Jun Yan, Lianke Qin, Heng Wang, Xifeng Yan, William Yang Wang, and Linda Ruth Petzold. Gpt-4v (ision) as a generalist evaluator for vision-language tasks. arXiv preprint arXiv:2311.01361, 2023b.
  • Zhang et al. [2023c] Yanzhe Zhang, Ruiyi Zhang, Jiuxiang Gu, Yufan Zhou, Nedim Lipka, Diyi Yang, and Tong Sun. Llavar: Enhanced visual instruction tuning for text-rich image understanding. arXiv preprint arXiv:2306.17107, 2023c.
  • Zhao et al. [2023] Bo Zhao, Boya Wu, and Tiejun Huang. Svit: Scaling up visual instruction tuning. arXiv preprint arXiv:2307.04087, 2023.
  • Zong et al. [2024] Zhuofan Zong, Bingqi Ma, Dazhong Shen, Guanglu Song, Hao Shao, Dongzhi Jiang, Hongsheng Li, and Yu Liu. Mova: Adapting mixture of vision experts to multimodal context. arXiv preprint arXiv:2404.13046, 2024.

Appendix

Appendix A Training Details and Hyperparameters

We follow the instruction-tuning protocol of LLaVA-1.5 [33]. In the pretraining step, we employ the caption data to optimize the projector, while kee** the vision encoder and LLM frozen. Meanwhile, we optimize the projector and LLM in the instruction tuning step. During the pretraining phase, we utilize a batch size of 256, while for the instruction tuning phase, we employ a batch size of 128. The learning rate is set at 1e31superscript𝑒31e^{-3}1 italic_e start_POSTSUPERSCRIPT - 3 end_POSTSUPERSCRIPT during pretraining and adjusted to 2e52superscript𝑒52e^{-5}2 italic_e start_POSTSUPERSCRIPT - 5 end_POSTSUPERSCRIPT for instruction tuning, with both phases incorporating a cosine decay schedule. We also apply a learning rate warmup with a decay factor of 0.03, and no weight decay is used. Both pretraining and instruction tuning are conducted for one epoch each, consistently using the AdamW optimizer.

Appendix B More Effects of Web2Code on General Domain

Here, we first perform instruction tuning using Web2Code on various LLM backbones and then we evaluate those MLLMs on the general domain of visual language understanding.

Comparison on different LLM backbones. We compare the general domain abilities of various LLM backbones under the same data configuration of LLaVA + DWU + DWCG; Table 6 summarizes the results of instruction-tuned MLLMs. Specifically, we found that instruction-tuned CrystalChat-7B, Vicuna1.5-7B, and LLaMA2-7B show superior performances in the general domain compared to CrystalCoder and CodeLlama. For example, CrystalChat shows +132.89 points higher than CodeLlama in MME-P (i.e. perception domain). Somewhat surprisingly, instruction-tuned CrystalChat showed the strongest performance on TextVQA, which requires visual reasoning based on text in images.

LLM Backbone MME-P MME-C POPE SciQA TextVQA
CodeLlama-7B [45] 1345.93 258.92 85.28 61.87 55.23
CrystalCoder-7B [37] 1351.22 274.64 86.05 61.63 50.11
CrystalChat-7B [37] 1478.82 297.14 86.14 67.92 57.41
Vicuna1.5-7B [11] 1488.26 268.21 87.05 69.31 56.40
LLaMA2-7B [54] 1448.58 304.29 86.87 67.87 55.62
Table 6: Comparison of different LLM backbones on visual language understanding benchmarks. All models are instruction-tuned on the general domain data (i.e. LLaVA) with DWU and DWCG.

Appendix C Qualitative Data Examples in WUB Benchmark

The qualitative data examples in our WUB benchmark are shown in Figure 10. It covers different aspects of webpage understanding based on "yes" / "no" question-answer pairs.

Refer to caption

Figure 10: Qualitative data examples in our WUB benchmark. It covers different aspects of webpage understanding based on "yes" / "no" question-answer pairs.

Appendix D WCGB Criteria

Our proposed WCGB framework consists of 10 distinct criteria, which we group into four categories, each encompassing specific criteria that are scored on a 0-10 scale:

  1. 1.

    Visual Structure and Alignment

    • Layout Consistency: Measures the arrangement of structural webpage elements like headers, footers, and sidebars.

    • Element Alignment: Assesses the alignment of images, buttons, and text boxes.

    • Proportional Accuracy: Checks for consistency in sizes and aspect ratios of visual elements.

    • Visual Harmony: Examines the overall balance and harmony in design.

  2. 2.

    Color and Aesthetic Design

    • Color Scheme and Aesthetic Match: Focuses on the similarity in color schemes, including hues and saturation.

    • Aesthetic Resemblance: Looks at the overall aesthetic appeal and style (modern, minimalistic, traditional, etc.).

  3. 3.

    Textual and Content Consistency

    • Font Characteristics and Consistency: Assesses uniformity in font type, size, style, and weight.

    • Textual Content Match: Evaluates the match in words and sentences.

    • Numeric and Special Character Accuracy: Checks for consistency in numbers, dates, and special characters.

  4. 4.

    User Interface and Interactivity

    • User Interface Consistency: Assesses the similarity in design language and appearance of UI elements like menus, buttons, and forms.

Appendix E Prompt Templates

E.1 Prompt Used to Question and Answer Generation for DWU Data

Refer to caption

Figure 11: Prompt used to generate Question Answer pairs using GPT4 for DWU data.

E.2 Prompts Used For Instruction generation of DWCG and DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT

Refer to caption

Figure 12: Prompt used to generate instructions for DWCG using GPT4, feeding input as Seed instructions and output as GPT generated instructions shown in Figure 16.

Refer to caption

Figure 13: Prompt used to generate webpage style instruction for DWCG using GPT4, feeding input as Seed instructions and output as GPT generated webpage style instructions shown in Figure 16.

E.3 Prompt Used For GPT4-Vision Evaluation in WCGB benchmark

Refer to caption

Figure 14: The prompt utilized for evaluation in WCGB with the employment of GPT4-Vision.

E.4 Prompt Used For QA Generation for WUB benchmark

Refer to caption

Figure 15: The prompt employed to generate "yes" / "no" Question Answer pairs for the WUB benchmark through the utilization of GPT4-Vision.

Appendix F Data samples

Refer to caption
Figure 16: Examples of webpage to code generation instruction tuning data. These web image-code pairs were converted into an instruction-following data format close to the LLaVA data format.
Refer to caption
Figure 17: Examples of webpage to code generation instruction tuning data in DWCG. These web image-code pairs were converted into an instruction-following data format close to the LLaVA data format.
Refer to caption
Figure 18: Examples of webpage to code generation instruction tuning data in DWCGRR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT. The refined instruction tuning dataset for webpage code generation, by utilizing GPT-4.
Refer to caption
Figure 19: Examples of webpage understanding data in DWU. For a webpage, there is a set of diverse question-answer pairs about web understanding.
Refer to caption
Figure 20: Examples of webpage understanding data in DWURR{}_{\texttt{R}}start_FLOATSUBSCRIPT R end_FLOATSUBSCRIPT. The refined instruction tuning dataset for web understanding tasks.
Refer to caption
Figure 21: Examples of Modern styles webpages.
Refer to caption
Figure 22: Examples of Bootstrap styles webpages.