Interaction2Code
收藏Interaction2Code: 互动网页生成数据集
数据集概述
Interaction2Code 是一个用于互动网页生成的网页数据集,包含以下内容:
- 数据集:实验数据的样本位于
/sample目录下。 - 代码:代码位于
/code目录下,包括互动网页生成和指标计算。 - 人类评估结果:人类评估的结果位于
/human_evaluation目录下。
数据集结构
. ├── assets ├── code │ ├── metric # 指标计算 │ └── prompting # 互动页面生成 ├── human_evaluation │ └── failure # 失败案例注释 │ └── figure └── sample # 采样的数据集
基准统计
| 指标 | 最小值 | 最大值 | 平均值 | 标准差 |
|---|---|---|---|---|
| 长度(tokens) | 2457 | 726,317 | 141,084 | 160,438 |
| 标签计数 | 34 | 12,694 | 1,291 | 1,574 |
| DOM 深度 | 6 | 37 | 18 | 6 |
| 唯一标签 | 8 | 58 | 31 | 9 |
| 总大小 | - | - | - | 97 |
| 元素 | 频率 | 元素 | 频率 | 类型 | 频率 |
|---|---|---|---|---|---|
| button | 145 | summary | 16 | new component | 94 |
| input | 80 | output | 16 | text | 93 |
| link | 47 | image | 14 | color | 61 |
| iframe | 47 | video | 12 | new window | 25 |
| textarea | 43 | dialog | 11 | position | 21 |
| option | 43 | audio | 7 | size | 16 |
| select | 45 | template | 6 | switch | 15 |
| form | 26 | text | 4 | - | - |
| label | 25 | area | 2 | - | - |
| detail | 24 | span | 2 | - | - |
| progress | 19 | table | 2 | - | - |
| datalist | 16 | - | - | - | - |
数据集格式
sample/ 目录下的数据集格式如下:
文件夹名称是网页的编号。 x.png: 交互 "x" 的截图。 x-1.png: 交互 "x" 之前的网页截图。 x-2.png: 交互 "x" 之后的网页截图。 x-1-mark.png: 交互 "x" 之前带有交互元素标记的网页截图。 x-2-mark.png: 交互 "x" 之后带有交互效果区域标记的网页截图。 placeholder.jpg: 生成的网页的占位图。 type: url, topic 和交互类型。
代码使用
代码生成
在 /code/prompting/key.json 中添加你的密钥:
json
{
"gemini": "your_gemini_key",
"gpt": "your_openai_key",
"claude": "your_anthropic_key"
}
在 /code/prompting 目录下运行 gemini.py, gpt.py 和 claude.py 生成互动网页:
python
generate_page(path="../../sample/", web_number=1, interact_number=1, prompt_method="direct_prompt")
执行后,网页文件 {interact_numer}-{prompt_method}-{model}.html 将生成在 sample/{web_number} 文件夹中。
运行自动评估
在 /code/metric 目录下运行 calculate_metric.py 进行评估:
步骤1:自动与生成的网页交互 python interact_by_id(file_name=prediction_path+f"{web_name}/{interact_name}-{prompt_name}-{model_name}.html", folder_path=prediction_path+f"{web_name}/{interact_name}-{prompt_name}-{model_name}/")
步骤2:计算指标 python full_page_results, interact_results, message = get_all_score_new(web_name, interact_name, model_name, prompt_name)
失败类型描述
互动元素的失败
(a) 互动元素缺失:MLLMs 未生成互动元素。 (b) 无交互:生成的网页中没有交互。 (c) 错误的互动元素:MLLMs 在错误的元素上实现了互动功能。 (d) 错误的互动元素类型:MLLMs 生成的互动元素类型错误。 (e) 互动元素位置错误:MLLMs 生成的互动元素位置不正确。
互动效果的失败
(f) 交互后位置错误:MLLMs 生成的互动效果位置错误。 (g) 错误的交互效果类型:MLLMs 生成的交互效果类型错误。 (h) 效果作用于错误元素:MLLMs 在错误的元素上实现了交互效果。 (i) 部分实现:MLLMs 仅实现了部分互动功能。 (j) 错误的功能:MLLMs 实现了错误的功能。




