DesignAsCode: Bridging Structural Editability and Visual Fidelity in Graphic Design Generation
Paper • 2602.17690 • Published
docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "Tony1109/DesignAsCode-planner" \
--host 0.0.0.0 \
--port 30000# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Tony1109/DesignAsCode-planner",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'The Semantic Planner for the DesignAsCode pipeline. Given a natural-language design request, it generates a structured design plan — including layout reasoning, layer grouping, image generation prompts, and text element specifications.
| Base Model | Qwen3-8B |
| Fine-tuning | Supervised Fine-Tuning (SFT) |
| Size | 16 GB (fp16) |
| Context Window | 8,192 tokens |
Trained on ~10k examples sampled from the DesignAsCode Training Data, which contains 19,479 design samples distilled from the Crello dataset using GPT-4o and GPT-o3. No additional data was used.
prompt — natural-language design requestlayout_thought + grouping + image_generator + generate_textSee the training data repo for field details.
| Batch Size | 1 |
| Gradient Accumulation | 2 |
| Learning Rate | 5e-5 (AdamW) |
| Epochs | 2 |
| Max Sequence Length | 8,192 tokens |
| Precision | bfloat16 |
| Loss | Completion-only (only on generated tokens) |
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_path = "Tony1109/DesignAsCode-planner"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.float16,
device_map="auto"
)
For full pipeline usage (plan → implement → reflection), see the project repo and Quick Start.
The model generates semi-structured text with XML tags:
<layout_thought>...</layout_thought> — detailed layout reasoning<grouping>...</grouping> — JSON array grouping related layers with thematic labels<image_generator>...</image_generator> — JSON array of per-layer image generation prompts<generate_text>...</generate_text> — JSON array of text element specifications (font, size, alignment, etc.)@article{liu2026designascode,
title = {DesignAsCode: Bridging Structural Editability and
Visual Fidelity in Graphic Design Generation},
author = {Liu, Ziyuan and Sun, Shizhao and Huang, Danqing
and Shi, Yingdong and Zhang, Meisheng and Li, Ji
and Yu, Jingsong and Bian, Jiang},
journal = {arXiv preprint arXiv:2602.17690},
year = {2026},
url = {https://arxiv.org/abs/2602.17690}
}
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Tony1109/DesignAsCode-planner" \ --host 0.0.0.0 \ --port 30000# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Tony1109/DesignAsCode-planner", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'