Skip to content

Agent-driven creation of editable, tastefully crafted visual artifacts.

Python

Restore context-distillation rationale and frame semantic addressing as the core direction

yejy53c87b16f6d7c1
diff --git a/site/content/blog/genclaw-next.en.md b/site/content/blog/genclaw-next.en.md
index f1e916f..d3bb3d1 100644
--- a/site/content/blog/genclaw-next.en.md
+++ b/site/content/blog/genclaw-next.en.md
@@ -83,25 +83,37 @@ item: | /blog/genclaw-next/robot-3d.mp4
## Distilling design behavior from design.md
-The earlier observations led to a further question: can **the design decisions in `design.md` become part of a model's default page-generation behavior**? We explore **context distillation** with a concrete design plan as the starting point, organized into four steps:
+The earlier observations led to a further question: can **the design decisions in `design.md` become part of a model's default page-generation behavior**?
-1. **Write the design plan: turn the brief into `design.md`.** Start from the page's content and use case. Specify the focal image, information hierarchy, reading order, typography, whitespace, and section proportions, giving the subsequent implementation a concrete design direction.
+In the **non-agentic setup**, the model emits HTML, CSS, and JavaScript in a single pass. The page can contain motion and interaction, but the model does not call search or image-generation tools during generation. So where do the images come from? What we observed is that models **activate memorized Unsplash IDs**: they write image addresses such as `photo-xxxxxxx-xxxxxxx` directly, and the browser fetches them when the page loads. This [image-ID usage pattern](https://www.designarena.ai/blog/kimi-k3s-design-secret-may-be-in-its-thinking-traces) has also attracted discussion. Stronger models such as Kimi K3 and GPT-5.6 sol tend to use Unsplash IDs as image assets in single-pass web generation, rather than relying only on SVG. GPT-5.5, by contrast, uses Unsplash IDs less often and fills the page with purple gradients or SVG instead, and its completeness and preference scores drop accordingly.
-2. **Plan assets and motion together: give the page a distinct expression.** Describe where photography, illustration, or texture belongs and how it works with the palette, text, and layout. Where useful, plan entrance sequences, scroll reveals, hover feedback, and state transitions so visual assets and the dynamic experience work together to guide attention.
+We also observed that once we add `design.md` planning, as in the agentic flow, and suggest using Unsplash IDs, most models, including Gemini, GPT, Opus, Kimi, MiniMax, and GLM, show some ability to recall Unsplash IDs. Smaller models such as Qwen-3.6 27B are no exception; what differs is mainly how inclined they are to use them. **The problem, then, is not teaching the model new image IDs, but activating its tendency to use the memory it already has.**
-3. **Generate from the plan, then curate the pages.** Guide Qwen-3.6 27B with `design.md` and asset suggestions to generate complete pages. Check whether the results address the original request and whether image URLs are valid; filter or rewrite unsuitable samples. Retain implementations that express the design intent through HTML, CSS, and JavaScript as training targets.
+This is the main reason we chose **context distillation**: use the context to activate the Unsplash ID knowledge the model already acquired in pretraining, then distill that behavior back into the model itself, rather than making it fit a new batch of arbitrary IDs. Starting from a concrete design plan, we organized this path into four steps:
-4. **Distill design decisions into default generation behavior.** Train on the original user request paired with the selected page code, omitting the `design.md` used during sample generation from the training input. The aim is for the model to learn to organize layouts, choose assets, and arrange interactions from ordinary requests—making where assets belong, how information unfolds, and how interactions respond more natural generation choices.
+1. **Write the design plan: require `design.md` in the system prompt.** On top of the default Design Arena prompt, we add a system prompt asking the model to start from the page's content and use case and write a `design.md` that specifies the focal image, information hierarchy, reading order, typography, whitespace, and section proportions, giving the subsequent implementation a concrete design direction.
-In the **non-agentic setup**, the model emits HTML, CSS, and JavaScript in a single pass. The resulting page can contain motion and interaction, although the model does not call search or image-generation tools during generation. It can write external image URLs for the browser to fetch when the page loads. In some samples we observed Unsplash IDs such as `photo-xxxxxxx-xxxxxxx`; this [image-ID usage pattern](https://www.designarena.ai/blog/kimi-k3s-design-secret-may-be-in-its-thinking-traces) has also attracted discussion. With design planning and asset suggestions, some models, including Qwen-3.6 27B, became more inclined to use these image resources.
+2. **Plan assets and motion together: give the page a distinct expression.** The system prompt also suggests image resources such as Unsplash IDs. The design plan describes where photography, illustration, or texture belongs and how it works with the palette, text, and layout. Where useful, it also plans entrance sequences, scroll reveals, hover feedback, and state transitions so visual assets and the dynamic experience work together to guide attention.
-For seed prompts we drew on [SamuelBang/AesCode-358K](https://huggingface.co/datasets/SamuelBang/AesCode-358K), collecting roughly 100K web-related entries and sampling and deduplicating them with reference to Design Arena's [What people are building with AI](https://www.designarena.ai/about) categories, yielding 20K prompt samples. Image IDs were the entry point for this exploration; the broader habit of interest is selecting and organizing assets to suit the page's content.
+3. **Generate from the plan, then validate and rewrite the thinking.** Qwen-3.6 27B generates complete pages from its own `design.md` and asset suggestions, producing self-distillation data. We check whether each page addresses the original request and whether its image UIDs are valid, filtering or replacing broken images. We also rewrite the thinking so its design reasoning matches the final page and carries no traces of the system-prompt guidance, keeping the training content independent of the extra prompt. The retained training targets are page implementations that express the design intent through HTML, CSS, and JavaScript, together with the corresponding design reasoning.
-We also check image-UID validity and rewrite generated samples. This exploratory sample set records a decline in page-level broken-image rate from 17% to 3%, reflecting a change in asset-loading quality. In the simplified simulation below, the context-distilled version also references images more often and receives a higher simulated preference score.
+4. **Distill design decisions into default generation behavior.** For training, we remove the system prompt that asks for `design.md` and suggests Unsplash IDs, pairing the original user request with the curated, rewritten thinking and page code. The aim is for the model to organize layouts, choose assets, and arrange interactions from ordinary requests without extra instructions, making where assets belong, how information unfolds, and how interactions respond natural choices during generation.
+
+For seed prompts we drew on [SamuelBang/AesCode-358K](https://huggingface.co/datasets/SamuelBang/AesCode-358K), collecting roughly 100K web-related entries and sampling and deduplicating them with reference to Design Arena's [What people are building with AI](https://www.designarena.ai/about) categories, yielding 20K prompt samples. Image IDs were the entry point for this exploration; the broader habit we hope the model learns is selecting and organizing assets to suit the page's content.
+
+The validation and rewriting in step 3 are not optional. With simple prompt activation alone, the broken-image rate of generated pages exceeds 15%, and only about 20% of deduplicated unique UIDs may be valid; training directly on such data would teach the model even more skewed UID knowledge. In our ablation, the model trained on validated and rewritten data saw its broken-image rate fall from 17% to 3%, to the point where it barely affects how the page looks.
![Internal simulation of single-pass web generation](/blog/genclaw-next/charts/en/wide_oneshot_board.png "Simulated scores and image counts for single-pass web generation; Qwen SFT scores +209 relative to Base.")
-For non-agentic web generation, one direction worth exploring is **semantic addressing**: the model states what the image needs to be—keywords, dimensions—and an external asset service matches an image at render time. [LoremFlickr](https://loremflickr.com), for example, matches and returns an image from the keywords and size in the URL, so `https://loremflickr.com/640/480/fox?lock=7` requests a 640×480 image related to the keyword "fox." The model only has to write that address into the HTML; when the browser loads the page, LoremFlickr returns the image and it appears in place. The model still generates HTML in a single pass, while training can focus more on choosing assets that fit the content, style, and layout—and depend less on memorizing arbitrary image UIDs.
+The results show that context distillation effectively activates the model's tendency to use Unsplash IDs: across 50 single-pass web-generation tasks, the distilled Qwen-3.6 27B uses images more often and scores 209 points higher than the Base version.
+
+Still, recalling arbitrary IDs from memory is fragile. We believe the more fundamental direction is **semantic addressing**: having the model state what kind of image it needs, rather than remember the ID of a particular image.
+
+An Unsplash ID is a string with no relation to the image's content, so the model has to memorize an arbitrary mapping from ID to image. That memory cannot be derived from any pattern: smaller models remember less of it, it rarely covers new topics, and once an image is removed or a link breaks, the memorized ID breaks with it. The image need itself, meaning the content, style, size, and role the image plays in the layout, is exactly the kind of design decision `design.md` is meant to capture.
+
+In non-agentic web generation, semantic addressing works like this: the model states the image need from the page content, such as keywords and dimensions, and an external asset service matches an image at render time. [LoremFlickr](https://loremflickr.com), for example, matches and returns an image from the keywords and size in the URL, so `https://loremflickr.com/640/480/fox?lock=7` requests a 640×480 image related to the keyword "fox." The model only has to write that address into the HTML; when the browser loads the page, LoremFlickr returns the image and it appears in place.
+
+This way, deciding which image to use stays with the model's design judgment, while finding that image is handed to a photo library, a search service, or an image generator, and the backend can be swapped at any time. The model still generates HTML in a single pass, while training can focus more on choosing assets that fit the content, style, and layout, and depend less on memorizing arbitrary image UIDs.
![From memorizing image IDs to stating image needs](/blog/genclaw-next/semantic-addressing.png "Two paths compared: on the left the model writes an address from a memorized image UID; on the right it emits only keywords and a size, and the asset service matches an image at render time")
diff --git a/site/content/blog/genclaw-next.zh.md b/site/content/blog/genclaw-next.zh.md
index f094b5b..379eb79 100644
--- a/site/content/blog/genclaw-next.zh.md
+++ b/site/content/blog/genclaw-next.zh.md
@@ -83,25 +83,37 @@ item: | /blog/genclaw-next/robot-3d.mp4
## 从 design.md 到设计行为的蒸馏
-前面的观察给了我们一个进一步的问题:能否把 **`design.md` 中的设计决策,沉淀为模型生成页面时的默认行为**?我们尝试以设计稿为起点做 **context distillation**,把这条路径组织成四步:
+前面的观察给了我们一个进一步的问题:能否把 **`design.md` 中的设计决策,沉淀为模型生成页面时的默认行为**?
-1. **先写设计稿:把页面需求落到 `design.md`。** 从页面内容和使用场景出发,明确主视觉、信息主次、阅读顺序、字体层级、留白与区域比例,形成后续代码生成可以遵循的具体设计规划。
+在 **Non-Agentic 设置**中,模型单轮输出 HTML、CSS 和 JavaScript,页面可以包含动效与交互,但生成过程中不调用搜索或生图工具。那么图片素材从哪里来?我们观察到,答案是**激活记忆中的 Unsplash ID**:模型直接写出形如 `photo-xxxxxxx-xxxxxxx` 的图片地址,由浏览器在加载页面时获取;相关的[图片 ID 使用现象](https://www.designarena.ai/blog/kimi-k3s-design-secret-may-be-in-its-thinking-traces)也受到过讨论。Kimi K3、GPT-5.6 sol 等较强模型在单轮生成网页时,会倾向用 Unsplash ID 充当图像素材,而不只是用 SVG 填充。相比之下,GPT-5.5 使用 Unsplash ID 的次数偏少,更常用紫色渐变或 SVG 填充画面,完成度和偏好得分也随之下降。
-2. **联合规划素材与动效:让页面有自己的表达。** 在设计稿中写清哪些位置需要摄影、插画或纹理,以及素材与配色、文字和布局如何配合;再按页面需要规划入场顺序、滚动揭示、悬停反馈和状态切换,让视觉素材与动态体验共同引导注意力。
+我们还观察到,加入类似 agentic 流程中的 `design.md` 规划、并建议使用 Unsplash ID 之后,Gemini、GPT、Opus、Kimi、MiniMax、GLM 等大部分模型都表现出一定的 Unsplash ID 记忆能力,Qwen-3.6 27B 这样的小尺寸模型也不例外,差别主要在于使用倾向。**所以问题不在于教会模型新的图片 ID,而在于如何激活模型使用已有记忆的倾向。**
-3. **按设计稿生成,再筛选页面。** 用 `design.md` 和素材建议引导 Qwen-3.6 27B 生成完整页面,检查结果是否回应原始需求、图片地址是否有效,并对不合格样本过滤或改写。保留的训练目标,是设计意图已经落实到 HTML、CSS 和 JavaScript 中的页面实现。
+这也是我们选择 **context distillation** 的主要原因:通过上下文激活模型在预训练中已经掌握的 Unsplash ID 知识,再把这种行为蒸馏回模型本身,而不是让模型重新拟合一批新的、无规则的 ID。我们以设计稿为起点,把这条路径组织成四步:
-4. **把设计决策蒸馏进默认生成行为。** 训练时,以原始用户请求为输入,以筛选后的页面代码为目标;样本生成时使用的 `design.md` 不随训练输入提供。我们希望模型逐步学会在普通请求下自行组织版式、选择素材、安排交互,让“素材放在哪里、信息如何展开、交互怎样响应”成为生成过程中的自然选择。
+1. **先写设计稿:在系统提示中要求模型先产出 `design.md`。** 我们在默认的 Design Arena prompt 之上增加系统提示,要求模型从页面内容和使用场景出发写出 `design.md`,明确主视觉、信息主次、阅读顺序、字体层级、留白与区域比例,形成后续代码生成可以遵循的具体设计规划。
-在 **Non-Agentic 设置**中,模型单轮输出 HTML、CSS 和 JavaScript,页面可以包含动效与交互,但模型在生成过程中不调用搜索或生图工具。图片则可以通过写入外部 URL,由浏览器在加载页面时获取。在我们观察的样本中,一些模型会引用形如 `photo-xxxxxxx-xxxxxxx` 的 Unsplash ID;相关的[图片 ID 使用现象](https://www.designarena.ai/blog/kimi-k3s-design-secret-may-be-in-its-thinking-traces)也受到过讨论。加入设计规划和素材建议后,我们观察到包括 Qwen-3.6 27B 在内的一些模型更倾向于使用这些图片资源。
+2. **联合规划素材与动效:让页面有自己的表达。** 系统提示同时建议使用 Unsplash ID 等图片资源。在设计稿中写清哪些位置需要摄影、插画或纹理,以及素材与配色、文字和布局如何配合;再按页面需要规划入场顺序、滚动揭示、悬停反馈和状态切换,让视觉素材与动态体验共同引导注意力。
+
+3. **按设计稿生成,再做有效性检测与 thinking 改写。** Qwen-3.6 27B 依据自己写出的 `design.md` 和素材建议生成完整页面,产生自蒸馏数据。我们检查页面是否回应原始需求、图片 UID 是否有效,过滤或替换无效图片;同时改写 thinking,使其中的设计推理与最终页面一致,并去掉受系统提示引导的痕迹,确保训练内容不依赖额外提示。保留的训练目标,是设计意图已经落实到 HTML、CSS 和 JavaScript 中的页面实现,以及与之对应的设计思考。
+
+4. **把设计决策蒸馏进默认生成行为。** 训练时去掉要求写 `design.md`、建议使用 Unsplash ID 的系统提示,以原始用户请求为输入,以筛选、改写后的思考与页面代码为目标。我们希望模型在没有额外要求的普通请求下,也会自行组织版式、选择素材、安排交互,让“素材放在哪里、信息如何展开、交互怎样响应”成为生成过程中的自然选择。
种子 prompt 来自 [SamuelBang/AesCode-358K](https://huggingface.co/datasets/SamuelBang/AesCode-358K):我们从约 100K 条网页相关数据中,参考 Design Arena 的 [What people are building with AI](https://www.designarena.ai/about) 类别进行抽样与去重,构建了 20K 个 prompt 样本。图片 ID 是这次探索的切入点;更希望模型学到的,是根据页面内容选择与组织素材的习惯。
-我们还对生成样本中的图片 UID 进行有效性检测与改写。这组探索性样本记录的页面碎图率由 17% 降至 3%,用于观察素材加载质量的变化。在下方的简化模拟中,context distillation 后的版本也更倾向于使用图片,并获得了更高的模拟偏好分数。
+第 3 步的有效性检测和改写并不是可有可无的。如果只靠简单的 prompt 激活,生成页面的碎图率超过 15%,去重后的独立 UID 有效率可能只有约 20%;直接用这样的数据训练,反而会让模型学到更多有偏差的 UID 知识。消融实验显示,经过检测与改写的数据训练出的模型,碎图率从 17% 降到 3%,几乎不再影响页面观感。
![单轮网页生成的内部模拟比较](/blog/genclaw-next/charts/zh/wide_oneshot_board.png "单轮网页生成的模拟分数与配图数;Qwen SFT 相对 Base 的分数变化为 +209。")
-在 Non-agentic 的网页生成中,一个值得探索的方向是**语义寻址**:模型根据页面内容输出关键词、尺寸等图片需求,由外部素材服务在渲染时匹配图片。例如 [LoremFlickr](https://loremflickr.com) 支持根据 URL 中的关键词和尺寸自动匹配并返回图片,`https://loremflickr.com/640/480/fox?lock=7` 就会请求一张 640×480、与“狐狸”关键词相关的图片。模型只需要把这个地址写入 HTML,浏览器加载页面时,LoremFlickr 就会返回图像并显示在对应位置。模型仍然是单轮生成 HTML,而训练可以更多关注如何选择与内容、风格和布局相适配的素材,减少对无规则图片 UID 的记忆依赖。
+从结果来看,context distillation 能够有效激活模型使用 Unsplash ID 的倾向:在 50 个任务的单轮网页生成评估中,蒸馏后的 Qwen-3.6 27B 更倾向于使用图片,相对 Base 版本的分数提升 209。
+
+不过,依靠记忆调取无规则的 ID 终究比较脆弱。我们认为,更本质的方向是**语义寻址**:让模型表达“需要什么样的图片”,而不是记住“某张图片的编号”。
+
+Unsplash ID 是一串与内容无关的编号,模型要记住的是“编号 → 图片”的任意映射。这种记忆无法从规律中推导:模型越小记得越少,也很难覆盖新的主题;图片一旦下架或链接失效,记住的 ID 也随之失效。而图片需求本身,即内容、风格、尺寸以及它在版面中的作用,恰恰是 `design.md` 里本来就要做的设计决策。
+
+在 Non-agentic 的网页生成中,语义寻址的做法是:模型根据页面内容输出关键词、尺寸等图片需求,由外部素材服务在渲染时匹配图片。例如 [LoremFlickr](https://loremflickr.com) 支持根据 URL 中的关键词和尺寸自动匹配并返回图片,`https://loremflickr.com/640/480/fox?lock=7` 就会请求一张 640×480、与“狐狸”关键词相关的图片。模型只需要把这个地址写入 HTML,浏览器加载页面时,LoremFlickr 就会返回图像并显示在对应位置。
+
+这样,“决定用什么图”留给模型的设计判断,“找到这张图”交给图库、检索或生图服务,后端可以随时替换。模型仍然是单轮生成 HTML,而训练可以更多关注如何选择与内容、风格和布局相适配的素材,减少对无规则图片 UID 的记忆依赖。
![从记忆图片 ID 到表达图片需求](/blog/genclaw-next/semantic-addressing.png "两条路径的对比:左侧靠记忆图片 UID 直接写地址,右侧只输出关键词与尺寸,由素材服务在渲染时匹配图片")