ERNIE-Image 提示词权重控制与负向提示进阶:CFG Scale / Negative Prompt 完全解析

Jun 5, 2026

ERNIE-Image 提示词权重控制与负向提示进阶:CFG Scale / Negative Prompt 完全解析

发布日期: 2026-06-05
作者: ERNIE-Image 技术团队
关键词: ernie-image cfg scale ernie-image negative prompt ernie-image guidance scale ernie-image prompt weighting


引言

在 AI 图像生成中,提示词(prompt)是控制输出质量的核心。但对于 ERNIE-Image 这样的 Diffusion Transformer 模型,仅有好的 prompt 文本还不够——你需要掌握 CFG Scale(Guidance Scale)、Negative Prompt(负向提示) 和 Prompt Weighting(提示词权重) 三个关键技术参数,才能真正实现对生成结果的精确控制。

许多新用户在使用 ERNIE-Image 时遇到以下困惑:

  • "为什么我的 negative prompt 完全不生效?"
  • "CFG Scale 调到 7 为什么反而画质变差了?"
  • "如何让模型更关注 prompt 中的某个特定元素?"

本文逐一解答这些问题,并提供经过验证的最佳实践。


一、CFG Scale(Guidance Scale):控制 prompt 遵循度

1.1 什么是 CFG Scale?

CFG(Classifier-Free Guidance)Scale 控制了生成过程中模型对 text prompt 的遵循程度。简单来说:

  • CFG = 1:模型几乎忽略 prompt,自由发挥
  • CFG = 4.0(默认):平衡遵循度和创意自由度
  • CFG ≥ 7:严格遵循 prompt,但可能损失色彩自然度和多样性

1.2 ERNIE-Image 的 CFG Scale 推荐值

模式 默认值 推荐范围 说明
ERNIE-Image (Base) 4.0 3.0 - 5.0 标准生成
ERNIE-Image-Turbo 1.0 1.0 - 2.0 DMD+RL 优化,低 CFG 即可
放大精修阶段 3.0 2.5 - 3.5 降低 CFG 保持原图结构
文字渲染场景 4.5 4.0 - 5.5 提高 CFG 增强文字准确性

关键区别:ERNIE-Image-Turbo 经过 DMD 和 RL 优化,默认 CFG 为 1.0 即可达到高质量输出。如果将 Turbo 的 CFG 设置到 4.0 以上,反而会产生过饱和和伪影。

1.3 CFG Scale 对输出质量的影响

CFG 1.0  →  色彩柔和,构图自由,可能偏离 prompt
CFG 2.5  →  平衡状态,大多数场景的甜蜜点
CFG 4.0  →  严格遵循 prompt,标准推荐值
CFG 5.0  →  高度遵循,细节精确但可能过饱和
CFG 7.0+ →  色彩失真,可能出现过度锐化或伪影

1.4 Diffusers 中的 CFG 设置

from diffusers import ERNIEImagePipeline

pipe = ERNIEImagePipeline.from_pretrained("baidu/ERNIE-Image")

标准生成

image = pipe(
prompt="a cat sitting on a windowsill",
guidance_scale=4.0, # 默认推荐值
num_inference_steps=50,
).images[0]

Turbo 模式 — 低 CFG

image_turbo = pipe(
prompt="a cat sitting on a windowsill",
guidance_scale=1.0, # Turbo 默认值
num_inference_steps=8,
).images[0]


二、Negative Prompt(负向提示):排除不想要的内容

2.1 ERNIE-Image 是否支持 Negative Prompt?

支持,但有条件。 ERNIE-Image 基于 DiT 架构,其 Diffusers pipeline 接受 negative_prompt 参数。但与传统的 SD 1.x/2.x 不同,DiT 模型对 negative prompt 的响应方式有差异:

  • 需要较高的 CFG Scale:Negative prompt 在 CFG ≥ 3.0 时效果明显
  • Turbo 模式下效果有限:由于 Turbo 的默认 CFG 为 1.0,negative prompt 几乎不起作用
  • ComfyUI 中可单独调节 Negative Guidance Scale

2.2 Negative Prompt 最佳实践

from diffusers import ERNIEImagePipeline

pipe = ERNIEImagePipeline.from_pretrained("baidu/ERNIE-Image")

有效使用 negative prompt

image = pipe(
prompt="a professional headshot portrait of a woman, studio lighting",
negative_prompt="cartoon, anime, drawing, painting, blurry, low quality, deformed, ugly, bad anatomy, extra limbs",
guidance_scale=4.5, # 需要较高的 CFG
num_inference_steps=50,
).images[0]

2.3 Negative Prompt 使用注意事项

场景 建议
使用 Base 模型 + CFG ≥ 3.0 ✅ Negative prompt 有效
使用 Turbo 模型 ⚠️ Negative prompt 效果有限(CFG 默认 1.0)
在 ComfyUI 中 ✅ 可通过 Negative Guidance Scale 单独调节
文字渲染场景 ⚠️ Negative prompt 可能干扰文字生成,建议慎用

重要提示:ERNIE-Image-Turbo 由于 DMD 蒸馏优化,默认 CFG=1.0。在此设置下,negative prompt 几乎不生效。如果需要使用 negative prompt,请使用 Base 模型或将 Turbo 的 CFG 提升到 3.0 以上(但可能影响 Turbo 的画质优势)。


三、Prompt Weighting(提示词权重):精细控制元素重要性

3.1 为什么需要提示词权重?

在实际使用中,你经常需要强调 prompt 中的某些元素而弱化其他元素。例如:

  • "一只非常详细的猫,在窗户边上" → 希望模型更注重猫的细节
  • "赛博朋克风格的城市,有行人" → 希望风格比内容更重要

ERNIE-Image 支持多种 prompt 权重语法。

3.2 提示词权重语法

方法一:括号加权 (word)

在需要强调的词/短语周围添加括号,增加其权重:

# 不加权重
"a cat on a windowsill with flowers"

加权重 — 猫更重要

"(cat:1.3) on a windowsill with flowers"

多重加权 — 猫最重要,花朵次要

"(cat:1.5) on a windowsill with (flowers:1.2)"

方法二:重复强调

通过重复关键词来增加其重要性:

# 中等强调
"cat, cat, on a windowsill"

强强调

"cat, cat, cat, on a windowsill"

方法三:位置优先

Diffusion 模型对 prompt 开头的词给予更多注意力。将最重要的描述放在 prompt 开头:

# 猫是焦点
"close-up portrait of a cat, detailed fur, sitting on windowsill, flowers in background"

花朵是焦点(不推荐,效果差)

"sitting on windowsill, flowers, close-up portrait of a cat, detailed fur"

3.3 权重系数参考

权重 效果 使用场景
1.0 标准权重 默认,不需要强调
1.2 轻微强调 次要元素需要稍多关注
1.3-1.5 中等强调 核心元素需要更多关注
1.5+ 强强调 关键元素,必须突出
0.5-0.8 降权 需要弱化的元素

注意:过高的权重(>2.0)可能导致模型注意力失衡,产生异常输出。建议权重范围在 0.5-1.5 之间。


四、ComfyUI 中的高级控制

4.1 ComfyUI 中的 CFG 和 Negative Guidance Scale

在 ComfyUI 中,ERNIE-Image 工作流提供了更细粒度的控制:

KSampler 节点:
├── positive — 正面向 prompt
├── negative — 负向 prompt
├── cfg — CFG Scale (全局)
└── denoise — 去噪强度 (img2img 模式)

对于 Flux/DiT 类模型,ComfyUI 支持 Negative Guidance Scale,可以在 CLIPTextEncodeFlux 节点中单独设置:

CLIPTextEncodeFlux 节点:
├── text — prompt 文本
├── guidance — 该 prompt 的权重 (默认 3.5)
└── (negative guidance scale — 负向权重)

4.2 ComfyUI 中 Negative Prompt 的高级用法

ComfyUI 社区发现了一个有趣的技巧:即使 negative prompt 为空,调高 Negative Guidance Scale 也能影响输出质量:

正面向 prompt: "a beautiful landscape"
负向 prompt: "" (empty)
CFG Scale: 6.0
Negative Guidance Scale: 30 (高值增加对比度和锐度)

这个技巧在 FLUX Dev 模型上被广泛验证,ERNIE-Image 作为同架构模型也可能受益。


五、不同场景的最佳参数组合

5.1 参数速查表

场景 Model CFG Negative Prompt 推荐步数
快速概念验证 Turbo 1.0 不建议 8
标准照片 Base 4.0 通用负面词 50
文字渲染 Base 4.5 少用/不用 50
动漫风格 Base 3.5 "realistic, photo" 50
产品摄影 Base 4.0 "blurry, low quality" 50
放大精修 Base 3.0 少用 20-30
风格化创作 Base 2.5-3.0 视风格而定 50

5.2 通用 Negative Prompt 模板

# 通用高质量负面词(适用于大多数场景)
negative_prompt = "blurry, low quality, worst quality, deformed, distorted, disfigured, bad anatomy, extra limbs, poorly drawn face, poorly drawn hands, mutation, watermark, text, signature, username"

照片写实场景

negative_prompt = "cartoon, anime, drawing, painting, illustration, 3d render, blurry, low quality, deformed"

动漫/插画场景

negative_prompt = "photorealistic, realistic photo, blurry, low quality, deformed, watermark"

文字渲染场景(谨慎使用)

negative_prompt = "blurry text, illegible text, distorted text"


六、常见问题与排错

Q1: Negative prompt 完全不生效怎么办?

排查步骤:

  1. 确认使用的是 Base 模型(不是 Turbo)
  2. 确认 CFG Scale ≥ 3.0
  3. 在 ComfyUI 中确认 negative prompt 正确连接到 KSampler
  4. 尝试简化 negative prompt(3-5 个核心词即可)

Q2: CFG 调高后画面变丑/过饱和怎么办?

  • 降低 CFG 到 3.0-4.0 范围
  • 减少 inference steps(从 50 降到 30)
  • 尝试在 prompt 中加入 "natural lighting, soft colors" 等软化描述

Q3: 如何让某个元素特别突出?

  • 使用括号加权:(element:1.5)
  • 将该元素放在 prompt 开头
  • 在 negative prompt 中加入竞争元素:如 "a cat, not a dog"

Q4: Turbo 模式下 negative prompt 无效?

这是正常行为。Turbo 的默认 CFG=1.0 使得 negative prompt 效果微弱。解决方案:

  • 使用 Base 模型生成,然后 Turbo 放大精修
  • 或在 Turbo 中手动将 CFG 提升到 3.0(牺牲部分速度)

七、总结

掌握 CFG Scale、Negative Prompt 和 Prompt Weighting 是释放 ERNIE-Image 全部潜力的关键:

  1. CFG Scale:Base 模型推荐 3.0-5.0,Turbo 推荐 1.0-2.0。过高导致过饱和,过低偏离 prompt。
  2. Negative Prompt:在 Base 模型 + CFG ≥ 3.0 时有效。Turbo 模式下效果有限。
  3. Prompt Weighting:使用括号加权 (word:1.3) 和位置优先策略,精细控制元素重要性。

这三个参数组合使用,可以让你从"碰运气生成"进化到"精确控制输出"。

ERNIE-Image Team