Skip to content

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

Python

Clarify system-prompt self-distillation in three stages

yejy53fadd9d99e4bc
diff --git a/site/content/blog/genclaw-next.en.md b/site/content/blog/genclaw-next.en.md
index d3bb3d1..e732a30 100644
--- a/site/content/blog/genclaw-next.en.md
+++ b/site/content/blog/genclaw-next.en.md
@@ -81,27 +81,25 @@ item: | /blog/genclaw-next/animation-studio.mp4
item: | /blog/genclaw-next/robot-3d.mp4
```
-## Distilling design behavior from design.md
+## Distilling design behavior from system prompts
-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**?
+The earlier observations led to a further question: can **the asset use and visual organization encouraged by extra design instructions become part of a model's default page-generation capabilities**?
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.
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.**
-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:
+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. The procedure is to **guide generation with a system prompt, repair and curate the generated data, then train without the extra prompt**. It has three stages:
-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.
+1. **Design a system prompt that specifies asset use and visual design.** Alongside the page-generation request, we inject extra design instructions that suggest using image links from sources such as Unsplash for focal images or backgrounds, and planning the layout, typography, whitespace, visual effects, and interaction feedback around the page's content. The prompt asks the model to first write a `design.md` explaining where assets belong, how they work with the palette and text, and how motion guides attention, then implement the page from that plan. This turns the abstract request to make a page look good into concrete design requirements the model can act on.
-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.
+2. **Generate self-distillation data with the prompt, then repair CoT and curate the samples.** For requests covering Design Arena's priority categories, we give Qwen-3.6 27B both the original user request and the design system prompt, producing self-distillation samples containing design reasoning (CoT) and page code. We then check whether each page addresses the request and whether its image links work, filtering unsuitable samples or repairing invalid images. We also repair and rewrite the CoT so its design reasoning matches the final code, removing references such as “as required by the extra system prompt” that depend on the additional context. Category coverage and data repair improve sample quality and broaden the range of layouts, visual styles, and asset use.
-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.
-
-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.
+3. **Remove the design system prompt during training to internalize the behavior.** We use the original user request as the training input and the curated, repaired CoT and HTML, CSS, and JavaScript page code as the learning target, omitting the extra design system prompt used during generation. What we remove is the guidance to write `design.md` and use image assets; what we retain is the high-quality data it helped generate. The aim is for the model to choose assets, organize visual content, and arrange motion and interaction from ordinary requests without extra design instructions, improving page quality and aesthetic preference results.
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.
+The validation and rewriting in stage 2 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.")
diff --git a/site/content/blog/genclaw-next.zh.md b/site/content/blog/genclaw-next.zh.md
index 379eb79..260b67b 100644
--- a/site/content/blog/genclaw-next.zh.md
+++ b/site/content/blog/genclaw-next.zh.md
@@ -81,27 +81,25 @@ item: | /blog/genclaw-next/animation-studio.mp4
item: | /blog/genclaw-next/robot-3d.mp4
```
-## 从 design.md 到设计行为的蒸馏
+## 从系统提示到设计行为的蒸馏
-前面的观察给了我们一个进一步的问题:能否把 **`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 填充画面,完成度和偏好得分也随之下降。
我们还观察到,加入类似 agentic 流程中的 `design.md` 规划、并建议使用 Unsplash ID 之后,Gemini、GPT、Opus、Kimi、MiniMax、GLM 等大部分模型都表现出一定的 Unsplash ID 记忆能力,Qwen-3.6 27B 这样的小尺寸模型也不例外,差别主要在于使用倾向。**所以问题不在于教会模型新的图片 ID,而在于如何激活模型使用已有记忆的倾向。**
-这也是我们选择 **context distillation** 的主要原因:通过上下文激活模型在预训练中已经掌握的 Unsplash ID 知识,再把这种行为蒸馏回模型本身,而不是让模型重新拟合一批新的、无规则的 ID。我们以设计稿为起点,把这条路径组织成四步:
+这也是我们选择 **context distillation** 的主要原因:通过上下文激活模型在预训练中已经掌握的 Unsplash ID 知识,再把这种行为蒸馏回模型本身,而不是让模型重新拟合一批新的、无规则的 ID。具体做法是:**用系统提示引导生成,修复并筛选生成的数据,再移除额外提示进行训练**。这条路径分为三个环节:
-1. **先写设计稿:在系统提示中要求模型先产出 `design.md`。** 我们在默认的 Design Arena prompt 之上增加系统提示,要求模型从页面内容和使用场景出发写出 `design.md`,明确主视觉、信息主次、阅读顺序、字体层级、留白与区域比例,形成后续代码生成可以遵循的具体设计规划。
+1. **设计 system prompt,明确素材引用与视觉设计要求。** 我们在页面生成请求之外,额外注入一段设计引导系统提示:建议模型使用 Unsplash 等图像素材站的图片链接作为主视觉或背景,并根据页面内容规划布局、字体层级、留白、视觉特效与交互反馈。提示中要求先写出 `design.md`,说明素材放在哪里、如何与配色和文字配合,以及动效如何引导注意力,再据此生成页面。这样,系统提示就把抽象的“做得好看”转化为模型可以执行的具体设计要求。
-2. **联合规划素材与动效:让页面有自己的表达。** 系统提示同时建议使用 Unsplash ID 等图片资源。在设计稿中写清哪些位置需要摄影、插画或纹理,以及素材与配色、文字和布局如何配合;再按页面需要规划入场顺序、滚动揭示、悬停反馈和状态切换,让视觉素材与动态体验共同引导注意力。
+2. **携带系统提示进行自蒸馏,并修复 CoT、筛选数据。** 围绕 Design Arena 的重点类别,将原始用户请求与上述系统提示一起输入 Qwen-3.6 27B,生成包含设计思考(CoT)和页面代码的自蒸馏数据。随后检查页面是否回应需求、图片链接是否有效,过滤不合格样本或修复无效图片;同时修复、改写 CoT,使设计推理与最终代码一致,并去掉“按额外系统提示要求”等依赖提示上下文的表述。通过类别覆盖与数据修复,提升样本质量,丰富布局、视觉风格和素材使用方式。
-3. **按设计稿生成,再做有效性检测与 thinking 改写。** Qwen-3.6 27B 依据自己写出的 `design.md` 和素材建议生成完整页面,产生自蒸馏数据。我们检查页面是否回应原始需求、图片 UID 是否有效,过滤或替换无效图片;同时改写 thinking,使其中的设计推理与最终页面一致,并去掉受系统提示引导的痕迹,确保训练内容不依赖额外提示。保留的训练目标,是设计意图已经落实到 HTML、CSS 和 JavaScript 中的页面实现,以及与之对应的设计思考。
-
-4. **把设计决策蒸馏进默认生成行为。** 训练时去掉要求写 `design.md`、建议使用 Unsplash ID 的系统提示,以原始用户请求为输入,以筛选、改写后的思考与页面代码为目标。我们希望模型在没有额外要求的普通请求下,也会自行组织版式、选择素材、安排交互,让“素材放在哪里、信息如何展开、交互怎样响应”成为生成过程中的自然选择。
+3. **训练时移除设计系统提示,将设计行为内化为默认能力。** 以原始用户请求为训练输入,以筛选、修复后的 CoT 和 HTML、CSS、JavaScript 页面代码为学习目标,移除生成阶段额外注入的设计 system prompt。这里去掉的是要求写 `design.md`、建议使用图片素材等引导指令,保留的是这些指令引导生成的优质数据。我们希望模型在无需额外设计提示的普通请求下,也能自主选择素材、组织视觉内容、安排动效与交互,进而提升页面质量与美学偏好表现。
种子 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 是这次探索的切入点;更希望模型学到的,是根据页面内容选择与组织素材的习惯。
-第 3 步的有效性检测和改写并不是可有可无的。如果只靠简单的 prompt 激活,生成页面的碎图率超过 15%,去重后的独立 UID 有效率可能只有约 20%;直接用这样的数据训练,反而会让模型学到更多有偏差的 UID 知识。消融实验显示,经过检测与改写的数据训练出的模型,碎图率从 17% 降到 3%,几乎不再影响页面观感。
+第 2 个环节的有效性检测和改写并不是可有可无的。如果只靠简单的 prompt 激活,生成页面的碎图率超过 15%,去重后的独立 UID 有效率可能只有约 20%;直接用这样的数据训练,反而会让模型学到更多有偏差的 UID 知识。消融实验显示,经过检测与改写的数据训练出的模型,碎图率从 17% 降到 3%,几乎不再影响页面观感。
![单轮网页生成的内部模拟比较](/blog/genclaw-next/charts/zh/wide_oneshot_board.png "单轮网页生成的模拟分数与配图数;Qwen SFT 相对 Base 的分数变化为 +209。")