Files
2nd/10_Wiki/Topic_Programming/AI_and_ML/Negative_Prompt.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

6.8 KiB
Raw Blame History

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-negative-prompt Negative Prompt 10_Wiki/Topics verified self
Negative Prompts
Anti-Prompt
Exclusion Prompt
--no
Unwanted Tokens
none A 0.92 applied
generative-ai
image-generation
stable-diffusion
midjourney
prompt-engineering
classifier-free-guidance
2026-05-10 pending
language framework
python diffusers

한 줄

Negative prompt는 이미지 생성 모델에 "포함되지 말아야 할" 개념을 명시하여 classifier-free guidance(CFG) 분기에서 해당 방향으로부터 멀어지게 유도하는 텍스트 입력이다.

핵심

작동 원리 (Stable Diffusion)

  • Diffusion model은 매 step에서 noise prediction을 수행한다.
  • CFG는 두 분기를 결합한다: conditional (positive prompt) + unconditional (empty / negative prompt).
  • 공식: eps = eps_uncond + cfg_scale * (eps_cond - eps_uncond).
  • Negative prompt를 사용하면 eps_uncond 자리에 negative prompt embedding을 넣어, 결과를 negative 방향에서 멀어지게 한다.
  • CFG scale이 높을수록 negative 효과가 강해진다 (보통 7~12).

Midjourney --no

  • --no blurry, text, watermark 형식으로 prompt 끝에 추가.
  • 내부적으로 weighted negative prompt와 유사한 방식으로 처리.
  • v6 이후 더 정교하게 작동.

Weighting / Attention

  • Stable Diffusion WebUI: (blurry:1.4), [bad anatomy:0.7]로 weight 조정.
  • ((extra fingers)) 같은 괄호 중첩으로 강조 (×1.1 per pair).

흔한 negative tokens

  • 품질: low quality, worst quality, blurry, jpeg artifacts, lowres
  • 해부학: bad anatomy, extra fingers, malformed limbs, missing arms
  • 텍스트: text, watermark, signature, logo
  • 스타일: cartoon, anime, 3d render (사진 스타일 원할 때)

응용

  • 사진 사실성 향상 (illustration 제거)
  • NSFW / 폭력 방지 (safety negative)
  • 손가락 / 얼굴 결함 보정
  • 특정 색상 / 구도 회피

💻 패턴

# 1. diffusers 라이브러리 — 기본 negative prompt
from diffusers import StableDiffusionPipeline
import torch

pipe = StableDiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-1",
    torch_dtype=torch.float16,
).to("cuda")

image = pipe(
    prompt="a photorealistic portrait of a woman, natural lighting, 8k",
    negative_prompt="blurry, low quality, cartoon, deformed, extra limbs, watermark",
    num_inference_steps=30,
    guidance_scale=7.5,
).images[0]
# 2. SDXL — dual text encoder, 별도 negative prompt 2개
from diffusers import StableDiffusionXLPipeline

pipe = StableDiffusionXLPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
).to("cuda")

image = pipe(
    prompt="cinematic photo of a samurai in rain",
    prompt_2="dramatic lighting, ultra detailed",
    negative_prompt="cartoon, anime, low quality, blurry",
    negative_prompt_2="text, watermark, signature",
).images[0]
# 3. ComfyUI / API — weighted negative
negative = "(low quality:1.3), (bad anatomy:1.4), (extra fingers:1.5), watermark, text"
# 4. Midjourney --no 플래그
/imagine prompt: a serene japanese garden at dusk --no people, text, watermark --ar 16:9 --v 6
# 5. Embeddings 기반 negative (Textual Inversion)
# EasyNegative, BadDream 같은 학습된 embedding 활용
negative_prompt = "easynegative, badhandv4, (worst quality:1.2)"
# 텍스트 인코더가 학습된 token으로 매핑
# 6. 동적 negative — 사용자 선호 학습
def build_negative(user_dislikes: list[str]) -> str:
    base = ["blurry", "low quality", "watermark"]
    return ", ".join(base + user_dislikes)

negative_prompt = build_negative(["cartoon", "people"])
# 7. ControlNet + negative
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny")
pipe = StableDiffusionControlNetPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
).to("cuda")

image = pipe(
    prompt="a futuristic city",
    negative_prompt="blurry, low res, oversaturated",
    image=canny_edges,
).images[0]
# 8. CFG scale 동적 조절 — negative 영향력 강화
image = pipe(
    prompt="...", negative_prompt="...",
    guidance_scale=12.0,  # 7.5 → 12.0: negative 효과 강화
).images[0]
# 9. Region-specific negative (Regional Prompter)
# 이미지 영역별 다른 negative 적용 (얼굴 영역만 anatomy negative)
# 10. Automatic negative — LLM이 prompt에서 추론
def auto_negative(positive: str, llm) -> str:
    return llm.complete(f"Given prompt '{positive}', list undesired artifacts: ")

결정 기준

상황 추천
사진 사실성 cartoon, anime, illustration, 3d 제외
손/얼굴 결함 bad anatomy, extra fingers, deformed + EasyNegative embedding
텍스트 노이즈 text, watermark, signature, logo
CFG 7~9 (기본) negative 적당히 작동
CFG 11~13 negative 강하게, 그러나 saturation 위험
Midjourney v6 --no 짧고 명시적으로
SDXL 두 encoder 모두에 negative 분리 권장
ComfyUI weighted syntax (token:1.3) 활용

기본값: blurry, low quality, watermark, bad anatomy + CFG 7.5.

🔗 Graph

🤖 LLM 활용

  • LLM이 사용자의 positive prompt를 분석해 적절한 negative prompt 자동 생성.
  • ChatGPT / Claude로 "이 이미지 스타일에 맞는 negative prompt 추천" 요청.
  • Vision LLM이 생성 결과를 평가하여 다음 generation의 negative를 강화 (RLHF 유사 루프).

안티패턴

  • Negative에 너무 많은 토큰 나열 → 모델 혼란, 의도치 않은 영향. 10~15개 이내 권장.
  • Positive와 모순되는 negative (e.g., positive dog, negative animal).
  • CFG scale 너무 높이기 → 색상 saturation, 디테일 손실.
  • 학습되지 않은 추상어 사용 (bad, ugly만 단독으로 — 효과 약함).

🧪 검증 / 중복

  • 중복 문서: Negative_Prompts.md → REDIRECT 처리.
  • 동일 개념: Anti-Prompt, Exclusion-Prompt (별칭 통합).
  • 검증: A/B 테스트 (negative 유무로 동일 seed 비교)로 효과 측정.

🕓 Changelog

  • Phase 1 (2026-05-08): 초기 생성.
  • Manual cleanup (2026-05-10): canonical 확정, 패턴 10개 정비, SDXL dual encoder / Midjourney v6 추가, 별칭 통합.