File size: 6,572 Bytes
3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 48a8688 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca 0c044ed 3e8adca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | ---
pretty_name: Pattern2Code
license: odc-by
task_categories:
- image-to-text
- text-generation
language:
- en
tags:
- screenshot-to-code
- multimodal
- html
- css
- visual-grounding
- benchmark
size_categories:
- n<1K
configs:
- config_name: default
default: true
data_files:
- split: train
path: data/train-*.parquet
dataset_info:
features:
- name: standard_image
dtype: image
- name: noise_image
dtype: image
- name: example_id
dtype: string
- name: source_id
dtype: string
- name: pattern_family
dtype: string
- name: pattern_name
dtype: string
- name: attribute_name
dtype: string
- name: attribute_token
dtype: string
- name: position
dtype: string
- name: target_value
dtype: string
- name: target_value_from_filename
dtype: string
- name: bias_value
dtype: string
- name: pattern_description
dtype: string
- name: element_description
dtype: string
- name: code_snippet_line
dtype: string
- name: code_snippet_context
dtype: string
- name: html_path
dtype: string
- name: standard_image_path
dtype: string
- name: noise_image_path
dtype: string
- name: modified_index
dtype: int32
splits:
- name: train
num_examples: 720
---
# Pattern2Code
**Benchmark for the ASE 2026 paper *"Pattern Over Pixels: Measuring Pattern Completion Bias in Multimodal Code Generation."***
Project page: https://pattern2code.github.io/ · Artifact (Zenodo): https://doi.org/10.5281/zenodo.19341952
Pattern2Code measures *visual pattern-completion bias* in screenshot-to-code
generation: when a webpage contains a repeated UI pattern and exactly **one**
element deviates from it, does a multimodal LLM write the code that matches the
**pixels**, or the code that matches the **pattern**?
Each example pairs a rendered screenshot with the element's HTML snippet in which
the deviating CSS value is masked as `__`. The model must recover the masked
value from the image.
## Key results (5 frontier MLLMs)
| Family | Mean accuracy | Mean bias rate |
|---|---|---|
| Card patterns (`width`) | 21.17% | **69.78%** |
| Text patterns (`font-size`) | 7.89% | **80.22%** |
*Bias rate* = fraction of predictions equal to the repeated baseline `100%`.
## Contents
- **720** perturbed instances = 30 webpages × 2 pattern families × 3 positions × 4 magnitudes
- **360** structural-card (`width`) + **360** text-style (`font-size`) examples
- **1,440** screenshots — every instance rendered under 2 conditions (`standard_image`, `noise_image`)
- Perturbation magnitudes: `80%`, `90%`, `110%`, `120%`; unperturbed baseline is `100%`
## Layout
```text
data/train-*.parquet # the dataset: one row per instance, screenshots embedded
data/examples.jsonl # the same rows as raw JSON (image columns are paths only)
metadata/dataset_info.json # summary statistics
metadata/validation_report.json
html/{cards,texts}/ # perturbed HTML
images/{cards,texts}/{standard,noise}/ # the screenshots as loose PNG files
```
The Parquet files carry the screenshots inline, so both image columns render
directly in the dataset viewer and decode to `PIL.Image` with no extra setup.
The loose PNGs under `images/` are the same files, kept for anyone who wants to
work with them outside the `datasets` library.
## Row schema
| Field | Description |
|---|---|
| `standard_image` | **Image** — the rendered screenshot |
| `noise_image` | **Image** — the same page with eight opaque rectangles overlaid |
| `example_id` | Unique instance id |
| `source_id` | Seed webpage id (Design2Code) |
| `pattern_family` | `structural_card` or `text_style` |
| `pattern_name`, `pattern_description`, `element_description` | The repeated pattern being probed |
| `attribute_name` | Masked CSS property (`width` or `font_size`) |
| `attribute_token` | The mask token (`__`) |
| `position` | Which element was perturbed: `first`, `mid`, `last` |
| `modified_index` | Index of the perturbed element within the pattern |
| `target_value` | **Ground truth** — the perturbed value (e.g. `120%`) |
| `bias_value` | The pattern-consistent baseline (always `100%`) |
| `code_snippet_line` | The masked element's HTML |
| `code_snippet_context` | Masked element plus its sibling elements (model input) |
| `html_path` | Relative path to the full perturbed HTML |
| `standard_image_path` / `noise_image_path` | Relative paths to the two screenshot files |
## Loading
```python
from datasets import load_dataset
ds = load_dataset("knguyennguyen/pattern2code", split="train")
ex = ds[0]
ex["standard_image"] # PIL.Image — already decoded, no cast_column needed
ex["noise_image"] # PIL.Image
print(ex["attribute_name"], ex["target_value"], "vs baseline", ex["bias_value"])
print(ex["code_snippet_context"])
```
## Evaluation protocol
Prompt the model with `standard_image` (or `noise_image`) plus `code_snippet_context`:
```
You are doing a visual code fill-in-the-blank task. Given the webpage screenshot
and HTML snippet below, fill the blank token __ with ONLY the missing CSS/HTML
value. The goal is to predict the masked value to recreate the {pattern} in the
webpage design. Return the final answer in JSON format: {"answer":"<value>"}.
The blank must be a percentage value divisible by 10.
```
Score each prediction into three mutually exclusive outcomes:
- **Correct** — equals `target_value`
- **Bias-aligned** — equals `bias_value` (`100%`)
- **Other error** — neither
## Citation
```bibtex
@inproceedings{nguyen2026pattern,
title = {Pattern Over Pixels: Measuring Pattern Completion Bias in
Multimodal Code Generation},
author = {Nguyen, Khai-Nguyen and Chaparro, Oscar and Mastropaolo, Antonio},
booktitle = {Proceedings of the 41st IEEE/ACM International Conference on
Automated Software Engineering (ASE)},
year = {2026}
}
```
## License & provenance
The seed webpages come from the
[Design2Code](https://github.com/NoviScl/Design2Code) dataset, which is released
under the **Open Data Commons Attribution License (ODC-By)** as it is built on
the C4 corpus (also ODC-By). All perturbed HTML and screenshots here are
derivative works and are redistributed under **ODC-By** with attribution.
Copyright in the original website content remains with the respective site
owners; the material is shared for research and reproducibility purposes.
|