Uni-Edit: Intelligent Editing Is A General Task For Unified Model Tuning
Paper: arXiv:2605.21487
代码状态:论文首页给出 https://github.com/zhengdian1/Uni-Edit 与 https://huggingface.co/Uni-Edit,但本次创建笔记时 GitHub repo 返回 404,HF model/dataset API 返回 401;因此下面的伪代码是基于论文流程的 paper-level reconstruction,不是 released-code mapping。
1. Motivation(研究动机)
Unified Multimodal Model(UMM)的目标是让同一个模型同时做 visual understanding、image generation 和 image editing;理想情况下,这三种能力应该共享 latent space 并互相促进。但论文指出现有 UMM 训练通常仍停留在“折中”:understanding 希望深层表征偏高层语义,generation/editing 又需要细粒度结构与外观细节;把多任务数据简单混在一起时,往往需要多阶段 pipeline、大规模数据配比、复杂 balancing tricks,最后只是避免一边崩掉,而不是让生成和理解真正互相增强。
这篇工作的具体问题不是重新设计一个 UMM 架构,而是问:有没有一个单一 post-training task,可以在不改架构、不做多任务混合的情况下,同时提升 understanding、generation 和 editing? 作者选择从 image editing 入手,因为 editing 天然要求模型先理解原图/指令,再生成符合逻辑的新图;如果理解错了,编辑目标就错,如果生成能力弱,编辑结果也无法落地。
关键动机在于:已有 editing dataset(例如 AnyEdit)虽然也含世界知识或复杂编辑,但指令通常仍偏“加/删/替换对象”等粗粒度操作,不能充分调用 UMM 的 general understanding 能力。作者在 BAGEL 上验证后发现,直接用已有 editing 数据 fine-tune 会让 understanding 和 generation 都下降。这说明“editing 是好任务”不够,真正重要的是把 VQA/推理问题变成必须先求解再编辑的 intelligent editing 数据。
2. Idea(核心思想)
核心 insight:把理解任务转成“推理密集的图像编辑任务”后,训练时虽然只优化生成/编辑路径,模型仍必须在内部解决 VQA、OCR、math、grounding、caption 等理解问题,才能生成正确目标图;因此 generation loss 可以反向推动 understanding representation 变好。
Uni-Edit 的创新是构建 Uni-Edit-148k:从 LLaVA-OneVision-1.5 的 VQA 数据出发,先用 GPT-4o 分类问题类型,再把问题改写成不能泄露答案、必须由模型自行理解原图才能完成的 edit instruction,之后用 Nano-Banana-Pro 生成 edited image,并用 GPT-4o 按 instruction following、视觉质量、逻辑一致性过滤。针对 BAGEL 当前文字渲染等弱点,作者再用 ablation 调整类别配比得到 Uni-Edit-40k。
与 BAGEL/Emu3.5 这类“混合 understanding / generation / editing 数据并调配比例”的路线不同,Uni-Edit 只保留一个任务、一个数据集、一个主要训练阶段;与 RecA 这种更偏 text-image alignment 的 tuning 不同,Uni-Edit 的指令本身包含 VQA logic,显式把“理解原图”变成“生成目标图”的前置条件。
3. Method(方法)
3.1 Overall framework:把 VQA 变成 intelligent editing
Figure 1 解读:左侧是原始 understanding QA pair,例如 color、count、grounding、OCR、caption、math、shape;右侧把每个 QA 转成 edit instruction。重要的是 instruction 不直接泄露答案,而是要求模型先从原图中找出答案,再把答案相关的变化写入/生成到目标图中。底部强调 Uni-Edit 的定位:不是额外混合多个任务,而是把 VQA data 转成 intelligent editing,作为 unified model tuning 的 general task。
整体流程可以分成四步:
- 任务分类:用 GPT-4o 对 LLaVA-OV1.5 样本分类,覆盖 shape、color、count、location、OCR、caption、math 等类型;论文正文说从 chart understanding、mathematical reasoning、OCR、image captioning、attribute recognition、spatial reasoning、world knowledge 等理解域出发,落到这些可编辑类别。
- QA-to-edit instruction:根据类别生成指令,要求模型基于原图推理出答案,再执行编辑;例如 math 要解题并把 detailed process / final answer 写到黑板或羊皮纸上,location 要定位问题涉及区域并替换该区域对象。
- target image generation:用 Nano-Banana-Pro 作为编辑 backbone。因为指令复杂,生成时额外提供原始 question/answer 作为 context,降低 target image 错误率。
- GPT-4o filtering:给 GPT-4o 原图、编辑图、edit instruction、ground-truth answer,按 instruction following、视觉质量、逻辑一致性过滤;作者报告 Nano-Pro 即使有答案 context,仍约有 10% 错误,需要过滤。
直觉上,Uni-Edit 起作用的原因是训练样本把“理解”藏进“生成目标”里:模型不是回答文字,而是必须把理解结果变成可见编辑结果;generation loss 因此会奖励那些能正确识别对象、位置、数量、颜色、文本、数学关系和世界知识的内部表征。
3.2 Data construction pipeline
Figure 2 解读:pipeline 从 VQA data 开始,先做 edit type recognition,再做 edit instruction construction,然后把 instruction 送入 edited image generation,最后通过 edited image filtering 得到 Uni-Edit-148k。图中两个例子分别展示 localization 与 math:localization 要找区域并替换对象;math 要先解题,再把过程和答案写入介质。这解释了为什么同样叫 editing,Uni-Edit 比普通编辑指令更能调用 reasoning。
Edit type selection
作者选择 LLaVA-OV1.5 作为源数据,用 GPT-4o 根据 system prompt 生成 JSON,包含 task_category 与 process_answer。分类规则比正文最终保留类别更细:appendix 中包括 shape、count、bool、color、location、caption、ocr、math、multi-choice、others。对普通 VQA,process_answer 只抽核心答案;对 caption、multi-choice、math、others,则保留完整回答,避免把复杂推理压扁。
Question-to-edit instruction
不同类别有不同转换策略:
- OCR / caption:要求模型先读原图文字或描述原图,再把结果写到黑板、信件等新媒介上,字体如 Chalk-style;这把理解输出转为可见文本生成。
- Math:保留题干要求,指令明确要求
Solving the problem with [detailed process] and [final answer],再把解题过程和答案写到指定媒介上,模拟“先解题再生成”的链条。 - Shape / color / count:设计两类变体。一类给出参考答案,要求模型验证答案是否正确,条件成立才改形状/颜色/数量;另一类不显式给答案,只要求添加与正确属性匹配的新对象。
- Location / grounding:要求模型定位原图中问题提到的对象或区域,再在该区域替换为别的对象,训练 spatial grounding。
- Knowledge:由于 LLaVA-OV1.5 中世界知识样本较少,直接并入 AnyEdit 的 knowledge subset。
所有非 knowledge 类别都会追加视觉美学增强要求,使样本同时服务 generation quality 与 editing quality。
3.3 Uni-Edit-148k 与 Uni-Edit-40k
Figure 3 解读:图 3 对比完整的 Uni-Edit-148k 和针对当前模型能力裁剪后的 Uni-Edit-40k。论文的关键取舍是:148k 追求覆盖面,40k 追求对 BAGEL 当前能力最有效。因为 BAGEL 对大规模精确文字渲染仍有限,作者降低 OCR、caption、math 这类重文字生成样本比例,保留更能稳定提升 generation/editing/understanding 的类别组合。
数据过滤分两层:第一层是图像质量,排除模糊、严重 artifact、结构不自然、色彩/光照不协调等图像;第二层是 instruction following,判断编辑是否发生在正确区域、内容是否符合指令、若涉及文字是否与 process_answer 一致。评分 prompt 继承 VIEScore 风格,质量分 1–5,其中 1/2 直接 reject。
3.4 Training scheme on BAGEL
Figure 4 解读:Stage 1 中 MOT Layer 与 generation head 可训练,understanding/generation encoders 固定,使用 generation-side MSE loss;作者把 VAE feature dropout 设为 1,迫使模型依赖 ViT / understanding branch 特征。Stage 2 中 MOT Layer 冻结,只用 80k LLaVA-OV1.5 understanding samples 对 understanding lm_head 做 CE alignment,使更新后的 understanding backbone 与输出头分布对齐。图中 Und. Head / Gen. Head 是线性层,MOT Layer 指 BAGEL 的全部 transformer blocks。
Stage 1:generation loss 反向推动 understanding representation
作者完全跟随 BAGEL official editing configuration,只做一个关键改动:把 generation branch 的 VAE feature dropout 设为 1。BAGEL 原始训练为了 CFG 会以 30% 概率丢弃 VAE features;Uni-Edit 则训练时完全丢掉 VAE input,使编辑任务不能走“只看 VAE 细节”的捷径,而必须更多依赖 ViT features。由于 understanding task 推理时只使用 ViT features,这个设置是把 editing loss 绑定到 understanding representation 的关键。
论文没有给出精确 loss 公式;按图 4 与文字,Stage 1 可概念化为: 这里 是原图, 是 intelligent edit instruction, 是 Nano-Pro 生成并通过 GPT-4o 过滤的目标图。关键不是 MSE 本身,而是 VAE dropout 让模型必须通过 ViT/understanding branch 读懂原图和 instruction。
Stage 2:可选 lm_head alignment
因为 Stage 1 只用 generation loss,understanding branch 的 language modeling head 没被直接优化。作者用 80k LLaVA-OV1.5 understanding samples 只微调 lm_head,使它适配已被 Stage 1 更新的 understanding backbone。概念上是:
Stage 2 是 optional:Table 2 灰色行显示它能进一步提升 understanding(如 MMMU 53.6→54.2、MMBench 85.5→86.0),但 generation/editing 略降(RISE 17.2→16.7,GEdit 7.29→7.25)。这说明 editing 训练确实改变了 latent concept recognition,但显式文字输出头仍存在 distribution gap。
3.5 Paper-level pseudocode(无 released code)
由于本次未找到可访问公开实现,下面只表达论文流程,不对应具体 source file。
from typing import Dict, Iterable, List
def classify_vqa_sample(gpt4o, sample: Dict) -> Dict:
"""Paper-level reconstruction of Appendix A task classification."""
prompt = build_task_type_prompt(
original_question=sample["question"],
original_answer=sample["answer"],
image_path=sample["image_path"],
)
result = gpt4o.json(prompt)
return {
"task_category": result["task_category"],
"original_question": sample["question"],
"original_answer": sample["answer"],
"process_answer": result["process_answer"],
"image_path": sample["image_path"],
}
def build_intelligent_edit_instruction(gpt4o, categorized: Dict) -> str:
"""Convert VQA into an edit that requires solving the hidden understanding task."""
category = categorized["task_category"]
prompt = select_category_prompt(category)
output = gpt4o.json(prompt, categorized)
return output["edit_instruction"]
def synthesize_and_filter(nano_pro, gpt4o, item: Dict) -> Dict | None:
"""Generate target image with extra QA context, then filter quality and logic."""
edited = nano_pro.edit(
image=item["image_path"],
instruction=item["edit_instruction"],
context={
"original_question": item["original_question"],
"process_answer": item["process_answer"],
},
)
quality = gpt4o.json(build_quality_prompt(edited))
follow = gpt4o.json(build_instruction_following_prompt(item, edited))
if quality["score"] <= 2 or follow["answer"] != "yes":
return None
return {**item, "edited_image": edited}
def train_stage1_bagel(model, batch, optimizer):
"""Conceptual Stage 1: generation/editing loss with VAE features dropped."""
optimizer.zero_grad()
pred = model.edit(
image=batch["source_image"],
instruction=batch["edit_instruction"],
target_image=batch["edited_image"],
vae_feature_dropout=1.0,
train_mot_layers=True,
train_generation_head=True,
)
loss = mse_generation_loss(pred, batch["edited_image"])
loss.backward()
optimizer.step()
return loss
def align_understanding_lm_head(model, batch, optimizer):
"""Conceptual optional Stage 2: align lm_head using 80k understanding samples."""
freeze(model.mot_layers)
optimizer.zero_grad()
logits = model.understand(batch["image"], batch["question"], train_lm_head=True)
loss = cross_entropy(logits, batch["answer_tokens"])
loss.backward()
optimizer.step()
return loss3.6 Code-to-paper mapping status
Code reference: unavailable — public GitHub/HF implementation was not accessible during this run, so no commit-anchored released-code mapping can be provided.
| Paper Concept | Released Source File | Key Class/Function | Status |
|---|---|---|---|
| GPT-4o task classification | N/A | N/A | Paper Appendix A only;GitHub 404 |
| QA-to-edit instruction generation | N/A | N/A | Paper Appendix A prompts only |
| Nano-Pro target image generation | N/A | N/A | Method description only |
| GPT-4o quality / instruction-following filter | N/A | N/A | Appendix A prompt only |
| BAGEL Stage 1 tuning with VAE dropout = 1 | N/A | N/A | Training scheme in §3.3;no launch/config script accessible |
| Stage 2 80k lm_head alignment | N/A | N/A | Training scheme in §3.3;no code/config accessible |
4. Experimental Setup(实验设置)
Datasets and scale
- Source VQA data:LLaVA-OneVision-1.5,用于抽取 understanding QA 并转换成 edit instruction。
- Full constructed data:Uni-Edit-148k,包含 reasoning-intensive instructions 与 Nano-Pro 生成/过滤后的 edited images。
- Tailored training data:Uni-Edit-40k,基于类别 ablation 为当前 BAGEL 能力调整比例;OCR、caption、math 等重文本生成类别只保留少量,因为 BAGEL 当前文本渲染能力有限。
- Stage 2 alignment data:80k LLaVA-OV1.5 understanding samples,只用于 optional lm_head alignment。
Base models and baselines
主要 base model 是 BAGEL 14B;作者还在 Janus-Pro 上验证泛化。比较对象包括:BAGEL 原始模型、BAGEL-RecA、BAGEL-AnyEdit、BAGEL-Uni-Edit、Janus-Pro 以及 Janus-Pro + Uni-Edit。Table 1 还比较了用 BAGEL data、LLaVA-OV1.5、Bee、AnyEdit 对 BAGEL 做不同类型 tuning 后的 understanding 表现。
Evaluation metrics / benchmarks
- Understanding:MME、MMBench 1.0-EN、MMMU、MathVista、MMVP;覆盖 perception、cognition、multimodal reasoning 与 general knowledge。
- Generation:GenEval 与 WISE;论文用它们衡量 spatial understanding、layout、reasoning-aware image generation,其中 WISE 以 thinking mode 测试。
- Editing:ImgEdit、GEdit、RISE;ImgEdit/GEdit 偏基础编辑,RISE 偏 knowledge-based complex editing,带 † 的 benchmark 以 thinking mode 测试。
Training config
论文只报告高层训练设置:完全跟随 BAGEL official editing configuration;14B model 使用 FSDP,在 4 nodes × 8 NVIDIA H800 80GB GPUs 上训练约 14 小时。公开代码/配置本次不可访问,因此 LR、batch size、steps 等细节不能从 launch script 验证,笔记不编造这些值。
5. Experimental Results(实验结果)
5.1 Why ordinary editing data is not enough
Table 1 显示,直接用 open-source understanding/editing 数据 fine-tune BAGEL 并不能稳定提升理解:
| Dataset | Types | MMMU | MME | MMVet | MathVista | MMVP | MMBench |
|---|---|---|---|---|---|---|---|
| BAGEL data | Uni. | 52.8 | 2381 | 66.7 | 73.2 | 69.3 | 84.6 |
| LLaVA-OV1.5 | Und. | 52.6 | 2384 | 65.4 | 73.4 | 68.7 | 84.0 |
| Bee | Und. | 51.7 | 2317 | 65.0 | 78.3 | 62.7 | 84.5 |
| AnyEdit | Edit | 52.2 | 2314 | 63.9 | 71.9 | 65.2 | 84.1 |
这组结果支撑了两个结论:第一,BAGEL 原始 unified training data 质量很强,普通 understanding 数据很难进一步提升它;第二,普通 editing 数据甚至会伤害 understanding,说明“editing task”本身不自动带来互助,必须是包含复杂知识/推理的 intelligent editing。
5.2 Main benchmark results
| Method | MMMU | MME | MathVista | MMVP | MMBench | GenEval | WISE† | ImgEdit† | RISE† | GEdit† |
|---|---|---|---|---|---|---|---|---|---|---|
| BAGEL | 52.8 | 2381 | 73.2 | 69.3 | 84.6 | 0.87 | 0.72 | 3.28 | 11.9 | 6.86 |
| BAGEL-RecA | 52.8 | 2381 | 73.2 | 69.3 | 84.6 | 0.88 | 0.74 | 3.75 | 15.7 | 7.25 |
| BAGEL-AnyEdit | 52.2 | 2314 | 71.9 | 65.2 | 84.1 | 0.86 | 0.69 | 3.39 | 14.7 | 6.95 |
| BAGEL-Uni-Edit Stage 1 | 53.6 | 2405 | 73.8 | 71.3 | 85.5 | 0.89 | 0.75 | 3.51 | 17.2 | 7.29 |
| BAGEL-Uni-Edit Stage 2 | 54.2 | 2412 | 74.3 | 72.1 | 86.0 | 0.89 | 0.74 | 3.46 | 16.7 | 7.25 |
| Janus-Pro | 41.5 | 1978 | 45.3 | 48.0 | 67.5 | 0.80 | 0.45 | 3.13 | 1.2 | 6.34 |
| Janus-Pro + Uni-Edit | 43.5 | 2067 | 49.2 | 54.3 | 70.4 | 0.82 | 0.52 | 3.43 | 3.4 | 6.87 |
Stage 1 已经在三类能力上同时提升:BAGEL 从 MMMU 52.8 到 53.6,MME 2381 到 2405,MMVP 69.3 到 71.3,GenEval 0.87 到 0.89,WISE 0.72 到 0.75,RISE 11.9 到 17.2。Stage 2 继续提升 understanding,但 generation/editing 小幅回落,符合作者对 lm_head alignment 的解释。
5.3 Qualitative generation and editing
Figure 5 解读:图 5 对比 BAGEL 与 Uni-Edit tuning 后的 image generation。作者强调提升来自 prompt understanding、knowledge reasoning、spatial perception、image composition 与 aesthetic quality;样例包含知识推理与空间关系,说明 Uni-Edit 不只是让模型更会编辑训练集分布中的图,而是提高了生成时理解复杂文本约束的能力。
Figure 6 解读:图 6 展示 image editing 对比。Uni-Edit 在 instruction following、logic、spatial reasoning 上明显更稳;论文特别指出 Rubik’s Cube 和 knowledge reasoning 样例不在训练集中,说明 intelligent editing 的收益有一定泛化,而不是只记住 Nano-Pro 生成样本。
5.4 Ablations: where the mutual-help signal comes from
| Ablation / Variant | MMMU | MME | MathVista | MMVP | MMBench | GenEval | WISE† | ImgEdit† | RISE† | GEdit† |
|---|---|---|---|---|---|---|---|---|---|---|
| BAGEL-Uni-Edit Stage 1 | 53.6 | 2405 | 73.8 | 71.3 | 85.5 | 0.89 | 0.75 | 3.51 | 17.2 | 7.29 |
| a. w/o VAE dropout | 52.9 | 2344 | 71.7 | 69.3 | 84.1 | 0.87 | 0.72 | 3.34 | 15.9 | 7.06 |
| b. w/o joint training | 52.8 | 2381 | 73.2 | 69.3 | 84.6 | 0.86 | 0.73 | 3.27 | 16.7 | 6.81 |
| c. ViT 224×224 | 52.5 | 2324 | 69.3 | 67.3 | 83.6 | 0.88 | 0.74 | 3.51 | 15.3 | 7.20 |
| c. ViT 224×980 | 51.7 | 2326 | 68.3 | 65.8 | 84.0 | 0.88 | 0.73 | 3.44 | 17.8 | 7.23 |
| c. ViT 378×980 | 51.1 | 2307 | 65.4 | 65.9 | 83.2 | 0.86 | 0.71 | 3.17 | 13.3 | 6.89 |
- VAE dropout:不用
VAE dropout=1时三类能力都下降,尤其 understanding。这说明如果编辑训练继续依赖 VAE 细节通道,loss 不会有效更新与 understanding 共享的 ViT/MOT 表征。 - Joint training:冻结 understanding branch 后,generation/editing 也没有真正变好,RISE 虽接近但 GEdit/ImgEdit/GenEval 更低;作者据此认为 BAGEL 中 understanding branch 对 generation 有辅助作用,即“理解帮助生成”。反过来,Stage 1 只用 generation loss 却提升 understanding,则是“生成/编辑训练帮助理解”。
- Resolution:改变 ViT 输入分辨率没有带来收益;224×518(官方编辑配置)最好,降到 224×224 或升到 224×980 / 378×980 都明显伤害 understanding。
5.5 Data-type ablation
Table 3 对不同 edit type 分别取 6,000 samples 做 system-level ablation:
| Dataset | MMMU | MathVista | GenEval | WISE | RISE |
|---|---|---|---|---|---|
| BAGEL (origin) | 52.8 | 73.2 | 0.87 | 0.72 | 11.9 |
| Uni-Edit Stage 1 | 53.6 | 73.8 | 0.89 | 0.75 | 17.2 |
| Attribute | 52.4 | 73.4 | 0.88 | 0.74 | 18.6 |
| Location | 53.2 | 74.2 | 0.89 | 0.75 | 15.6 |
| Math | 52.9 | 74.4 | 0.86 | 0.73 | 15.3 |
| Caption&OCR | 52.1 | 72.2 | 0.86 | 0.73 | 16.9 |
| Knowledge | 54.2 | 72.6 | 0.87 | 0.75 | 17.8 |
作者每类取 6,000 samples 做公平比较。Attribute 最利于 generation/editing,但 understanding 覆盖不足;Location 提升 GenEval/WISE,因为两者涉及空间推理;Math 提升 MathVista,但因为需要生成大量文本,对通用 generation/editing 收益有限;Caption/OCR 甚至伤害多项指标,符合 BAGEL 文本渲染能力有限的观察;Knowledge 对 MMMU 与 WISE 有帮助。最终 Uni-Edit-40k 就是根据这些细粒度结果调配比例。
5.6 Appendix examples: what “intelligent editing” looks like
Figure 7 解读:Shape 类样例要求模型识别问题目标对象的形状,再按条件改变形状或添加对应形状对象;这让编辑动作依赖视觉属性识别,而不是直接执行固定替换。
Figure 8 解读:Count 类样例把计数答案转成要生成/移除的对象数量,训练模型把数量理解与生成可数对象绑定。
Figure 9 解读:Caption 类样例先要求从原图生成描述,再把描述写入新媒介;由于不能在 instruction 中直接泄露答案,模型必须自己完成图像描述。
Figure 10 解读:Location 类样例强调 grounding:模型必须定位原问题中的对象/区域,再在该区域做替换,适合训练空间定位与局部编辑一致性。
Figure 11 解读:Color 类样例要求识别目标颜色并据此编辑,能够把属性识别映射到可见颜色生成。
Figure 12 解读:OCR 类样例要求读出原图文字再写到新媒介上,是典型的 understanding-to-generation bridge;但也因为精确文字生成难,最终 40k 数据中这类被压低比例。
Figure 13 解读:Math 类样例要求模型先做视觉数学题推理,再把 detailed process 与 final answer 可视化。它最直接体现“生成帮助理解”的训练信号,但也最容易受限于模型长文本渲染能力。
5.7 Limitations and conclusion
论文结论是:intelligent editing 可以作为 UMM tuning 的 general task,在 BAGEL 和 Janus-Pro 上都同时提升 understanding、generation、editing,并且不需要额外 auxiliary modules。主要限制也很明确:数据构建依赖 GPT-4o 和 Nano-Pro,复杂样本仍需过滤;当前模型(尤其 BAGEL)文字渲染能力限制了 OCR/caption/math 类样本比例;公开代码/数据在本文时间点承诺发布,但本次笔记创建时尚未可访问,复现实验配置无法做 released-code 验证。