AI प्रॉम्प्ट इंजीनियरिंग · पाठ

नकारात्मक प्रॉम्प्ट और बहिष्करण

क्या हटाना है: धुंधला, वॉटरमार्क, भद्दा, विकृत — प्रभावी नकारात्मक प्रॉम्प्टिंग।

पाठ 3, कुल 4 में से13 चरण

नकारात्मक प्रॉम्प्ट और बहिष्करण, CoddyKit पर AI प्रॉम्प्ट इंजीनियरिंग का एक निःशुल्क पाठ है। यह 4 में से 3वाँ पाठ है। इस अध्ययन पथ के 3 तक कोई भी पाठ पूरा पढ़ना निःशुल्क है — इसके बाद CoddyKit PRO हर पाठ अनलॉक करता है, साथ ही अंतर्निर्मित कोड संपादक और चौबीसों घंटे एआई शिक्षक के साथ व्यावहारिक अभ्यास भी उपलब्ध कराता है। यह AI प्रॉम्प्ट इंजीनियरिंग सीखने के मार्ग का हिस्सा है और आपकी प्रगति वेब तथा CoddyKit ऐप पर सिंक होती रहती है। AI प्रॉम्प्ट इंजीनियरिंग पाठ्यक्रम में कुल 4 पाठ शामिल हैं।

Negative प्रॉम्प्ट क्या होते हैं

Negative प्रॉम्प्ट चित्र मॉडल को बताते हैं कि generate किए गए चित्र में क्या शामिल नहीं करना है। ये सकारात्मक प्रॉम्प्ट से अलग होते हैं और generation को अवांछित कलाकृतियों, शैलियों और तत्वों से दूर ले जाते हैं। मूल रूप से Stable Diffusion की विशेषता रहे इस विचार का प्रसार अब चित्र generation के अन्य मॉडलों में भी हो गया है।

Stable Diffusion में Negative प्रॉम्प्ट का वाक्य-विन्यास

Stable Diffusion में negative प्रॉम्प्ट को एक अलग पैरामीटर के रूप में दिया जाता है। मॉडल इन्हें विरोधी-मार्गदर्शन की तरह मानता है: negative प्रॉम्प्ट में मौजूद अवधारणाओं को generation के दौरान सक्रिय रूप से दूर किया जाता है।

import requests

SD_API_URL = 'http://localhost:7860/sdapi/v1/txt2img'

def generate_sd_image(positive_prompt, negative_prompt, steps=30, cfg_scale=7):
    payload = {
        'prompt': positive_prompt,
        'negative_prompt': negative_prompt,
        'steps': steps,
        'cfg_scale': cfg_scale,  # 7-12 recommended
        'width': 512,
        'height': 512,
        'sampler_name': 'DPM++ 2M Karras'
    }
    response = requests.post(SD_API_URL, json=payload)
    return response.json()

# Example call with negative prompt
positive = (
    'portrait of a young woman, soft natural light, '
    'professional photography, sharp focus, elegant'
)
negative = (
    'blurry, watermark, text, logo, ugly, distorted, '
    'deformed, extra fingers, extra limbs, bad anatomy, '
    'low quality, low resolution, grainy, noisy, '
    'oversaturated, harsh shadows'
)

result = generate_sd_image(positive, negative)
print('Generated:', len(result.get('images', [])), 'images')

सार्वभौमिक गुणवत्ता वाला Negative प्रॉम्प्ट

Negative प्रॉम्प्ट के शब्दों का एक मानक समूह लगभग किसी भी विषय के लिए परिणाम की गुणवत्ता सुधारता है। इसे याद कर लें या अपने डिफ़ॉल्ट शुरुआती बिंदु के रूप में save कर लें।

# Universal quality negative prompt
QUALITY_NEGATIVES = [
    # Technical quality issues
    'blurry', 'out of focus', 'low quality', 'low resolution',
    'pixelated', 'grainy', 'noisy', 'compressed artifacts', 'jpeg artifacts',

    # Anatomical distortions (common AI failure mode)
    'extra fingers', 'extra limbs', 'extra arms', 'deformed hands',
    'bad anatomy', 'malformed', 'mutated', 'disfigured',

    # Unwanted elements
    'watermark', 'text', 'logo', 'signature', 'caption',
    'border', 'frame', 'username',

    # Stylistic failures
    'ugly', 'poorly drawn', 'amateur', 'sketch',
    'unfinished', 'rough draft',

    # Color problems
    'oversaturated', 'washed out', 'overexposed', 'underexposed'
]

UNIVERSAL_NEGATIVE = ', '.join(QUALITY_NEGATIVES)
print('Universal negative prompt:')
print(UNIVERSAL_NEGATIVE[:200], '...')

शरीर-रचना संबंधी Negative प्रॉम्प्ट

AI चित्र मॉडल हाथों और उँगलियों के मामले में विशेष रूप से संघर्ष करते हैं। शरीर-रचना से जुड़े विशिष्ट negative प्रॉम्प्ट मानव आकृतियों की generation में इन कलाकृतियों को काफ़ी कम कर देते हैं।

ANATOMY_NEGATIVES = [
    # Hand and finger issues
    'extra fingers', 'missing fingers', 'deformed fingers',
    'fused fingers', 'too many fingers', 'six fingers',
    'wrong number of fingers', 'extra hands', 'floating hand',

    # Face issues
    'distorted face', 'asymmetrical face', 'multiple faces',
    'merged faces', 'duplicate head', 'two heads',
    'extra eyes', 'missing eyes', 'heterochromia (if not desired)',

    # Body proportions
    'extra legs', 'extra arms', 'floating limbs',
    'bad proportions', 'unrealistic body proportions',
    'torso too long', 'missing torso',

    # Skin
    'skin blemishes', 'skin texture issues'
]

BODY_NEGATIVE = ', '.join(ANATOMY_NEGATIVES)

# Full portrait negative prompt combining quality + anatomy
PORTRAIT_NEGATIVE = UNIVERSAL_NEGATIVE + ', ' + BODY_NEGATIVE
print('Portrait negative length:', len(PORTRAIT_NEGATIVE.split(',')), 'terms')

Negative प्रॉम्प्ट से शैली का बहिष्कार

Negative प्रॉम्प्ट अवांछित शैलियों को बाहर कर सकते हैं — यह तब उपयोगी होता है जब सकारात्मक प्रॉम्प्ट में दिए गए शैली-संबंधी शब्द उन मिलती-जुलती शैलियों को आकर्षित करते हैं जिनसे आप बचना चाहते हैं। शैली के सामान्य बहिष्कार:

style_exclusion_examples = [
    {
        'goal': 'Oil painting portrait without cartoonish look',
        'positive': 'oil painting portrait, classical technique, highly detailed',
        'negative': 'cartoon, anime, illustration, flat colors, cel-shaded, vector'
    },
    {
        'goal': 'Photorealistic image without HDR over-processing',
        'positive': 'photorealistic landscape, natural light, DSLR quality',
        'negative': 'HDR, hyper-saturated, over-processed, Instagram filter, tone-mapped'
    },
    {
        'goal': 'Dark fantasy without gore',
        'positive': 'dark fantasy warrior, dramatic lighting, detailed armor',
        'negative': 'gore, blood, violence, disturbing content, horror'
    },
    {
        'goal': 'Vintage look without actual age degradation',
        'positive': 'vintage 1960s photograph, film grain, warm tones',
        'negative': 'deteriorated, damaged, torn, stains, yellowed, faded'
    }
]

for ex in style_exclusion_examples[:2]:
    print(f'Goal: {ex["goal"]}')
    print(f'Negative: {ex["negative"][:60]}...')
    print()

DALL-E में बचाव का वाक्य-विन्यास

DALL-E 3 में अलग negative प्रॉम्प्ट फ़ील्ड नहीं होता। इसके बजाय, सकारात्मक प्रॉम्प्ट में 'बचें', 'without', 'नहीं' या 'शामिल न करें' जैसे स्वाभाविक शब्दों का उपयोग करके बहिष्करण लिखे जाते हैं।

import openai

client = openai.OpenAI(api_key='YOUR_API_KEY')

# DALL-E 3: exclusions in the positive prompt
dalle_prompt_with_exclusions = (
    'A professional portrait photograph of a businesswoman in a modern office. '
    'Natural window light, shallow depth of field, warm tones. '
    'Do not include: any text, watermarks, logos, or captions. '
    'Avoid: cartoon or illustrated style, anime, artificial-looking skin. '
    'The image should have no distracting background elements. '
    'Realistic and natural — not over-processed or filtered.'
)

response = client.images.generate(
    model='dall-e-3',
    prompt=dalle_prompt_with_exclusions,
    size='1024x1024',
    quality='hd',
    n=1
)

image_url = response.data[0].url
print('Generated image URL:', image_url[:60], '...')

Negative प्रॉम्प्ट की शक्ति और CFG पैमाना

Stable Diffusion में CFG (वर्गीकारक-रहित मार्गदर्शन) पैमाना यह नियंत्रित करता है कि प्रॉम्प्ट (सकारात्मक और negative दोनों) generation को कितनी दृढ़ता से प्रभावित करे। अधिक CFG = अधिक कड़ाई से पालन, लेकिन इससे कलाकृतियाँ उत्पन्न हो सकती हैं।

# CFG scale guide for Stable Diffusion
cfg_guide = {
    3: 'Very loose adherence, creative/random, may ignore negative prompts',
    5: 'Balanced: creative but follows prompts generally',
    7: 'Standard: good balance of quality and adherence (recommended default)',
    10: 'Strong adherence: follows both positive and negative prompts closely',
    12: 'Very strong: highly literal, may oversaturate colors or cause artifacts',
    15: 'Extreme: usually causes artifacts, rarely useful'
}

# Parenthetical weighting in Stable Diffusion
# Surround a term with () to increase its weight
# surround with [] to decrease its weight
weighted_negative = (
    '(blurry:1.3), (extra fingers:1.5), watermark, '
    '[slight noise:0.5], text'
    # extra fingers gets 1.5x negative weight (most important to avoid)
    # blurry gets 1.3x negative weight
    # slight noise gets reduced 0.5x weight (tolerate a little)
)

print('CFG=7 (recommended default) balances quality and prompt adherence')
print('Weighted negative example:', weighted_negative[:80], '...')

Negative प्रॉम्प्ट की लाइब्रेरी बनाना

अलग-अलग उपयोग-प्रसंगों के लिए अलग-अलग negative प्रॉम्प्ट समूहों की आवश्यकता होती है। क्षेत्र-विशिष्ट negative प्रॉम्प्ट की ऐसी लाइब्रेरी बनाएँ जिन्हें किसी भी generation कार्य के लिए एक साथ संयोजित किया जा सके।

NEGATIVE_PROMPT_LIBRARY = {
    'quality_base': (
        'blurry, low quality, low resolution, pixelated, '
        'watermark, text, logo, signature'
    ),
    'anatomy': (
        'extra fingers, deformed hands, bad anatomy, '
        'extra limbs, distorted face'
    ),
    'portrait_specific': (
        'double chin exaggerated, skin blemishes, '
        'red eye, harsh shadows on face'
    ),
    'landscape_specific': (
        'overcast flat light, washed out colors, '
        'lens flare, chromatic aberration'
    ),
    'product_photo': (
        'shadow on product, uneven background, '
        'reflection glare, dust spots'
    ),
    'no_style_bleed': (
        'anime, cartoon, illustration, painting, '
        'sketch (when photorealism is desired)'
    )
}

def compose_negative(*keys):
    return ', '.join(NEGATIVE_PROMPT_LIBRARY[k] for k in keys)

# Portrait generation
portrait_neg = compose_negative('quality_base', 'anatomy', 'portrait_specific')
print('Portrait negative:', portrait_neg[:100], '...')

# Product photo generation
product_neg = compose_negative('quality_base', 'product_photo', 'no_style_bleed')
print('Product negative:', product_neg[:100], '...')

जब Negative प्रॉम्प्ट विफल हो जाएँ

Negative प्रॉम्प्ट कोई गारंटी नहीं होते — वे अवांछित तत्वों की संभावना कम करते हैं, लेकिन उन्हें पूरी तरह समाप्त नहीं करते। यह समझना कि वे कब विफल होते हैं, यथार्थवादी अपेक्षाएँ तय करने में मदद करता है।

negative_prompt_limitations = {
    'Failure: Concept too abstract': {
        'problem': '"bad" is too vague for the model to act on',
        'fix': 'Use specific concrete terms: "blurry", "deformed", "watermark"'
    },
    'Failure: Contradiction with positive prompt': {
        'problem': 'Positive: "detailed painting" | Negative: "painting"',
        'fix': 'Narrow negative to the specific aspect: negative: "amateur painting, rough sketch"'
    },
    'Failure: Too many negative terms dilute effect': {
        'problem': '200-word negative prompt where each term gets minimal weight',
        'fix': 'Limit to 15-20 terms. Use weighting for most critical: "(extra fingers:1.5)"'
    },
    'Failure: Watermarks still appear': {
        'problem': 'Some model checkpoints are strongly trained on watermarked data',
        'fix': 'Use a different model checkpoint or use an inpainting pass to remove'
    }
}

for failure, info in negative_prompt_limitations.items():
    print(f'{failure}')
    print(f'  Problem: {info["problem"]}')
    print(f'  Fix: {info["fix"]}')
    print()

Negative प्रॉम्प्ट की प्रभावशीलता जाँचना

व्यवस्थित रूप से जाँचें कि आपके विशिष्ट उपयोग-प्रसंग के लिए कौन-से negative प्रॉम्प्ट वास्तव में परिणाम सुधारते हैं। negative प्रॉम्प्ट के साथ और उनके बिना generate करें और स्थिर बीज पर परिणामों की तुलना करें।

import requests

SD_API_URL = 'http://localhost:7860/sdapi/v1/txt2img'

def test_negative_prompts(positive, negative_variants, seed=42, steps=30):
    results = []
    for label, negative in negative_variants.items():
        payload = {
            'prompt': positive,
            'negative_prompt': negative,
            'seed': seed,  # fixed seed for fair comparison
            'steps': steps,
            'cfg_scale': 7
        }
        response = requests.post(SD_API_URL, json=payload)
        results.append({
            'label': label,
            'negative': negative[:60] + '...',
            'image_count': len(response.json().get('images', []))
        })
    return results

# Test different negative prompt levels
variants = {
    'no_negative': '',
    'quality_only': 'blurry, low quality, watermark',
    'anatomy_added': 'blurry, low quality, watermark, extra fingers, bad anatomy',
    'full_library': compose_negative('quality_base', 'anatomy', 'portrait_specific')
}

print('Testing negative prompt variants with fixed seed...')
print('Compare output images to identify which negative terms have the most impact.')

Midjourney का निषेध-पैरामीटर

Midjourney negative प्रॉम्प्ट के समकक्ष के रूप में --no पैरामीटर का उपयोग करता है। वाक्य-विन्यास अलग है, लेकिन अवधारणा समान है: प्रॉम्प्ट के अंत में --no [term1] [term2] append करें।

# Midjourney negative prompt syntax using --no parameter
midjourney_prompts = [
    # Basic exclusion
    'professional headshot portrait, soft studio lighting, --no text watermark logo background',

    # Style exclusion
    'oil painting of a medieval castle, dramatic lighting --no modern cars people telephone wires',

    # Anatomy
    'full body character art, hero pose --no extra fingers deformed limbs bad anatomy',

    # Content exclusion
    'children\'s book illustration of a forest --no violence scary dark horror'
]

# Midjourney also supports emphasis with :: weighting
weighted_midjourney = (
    'A serene Japanese garden::2, cherry blossoms::1.5, '
    'koi pond, stone lantern --no people tourists modern buildings::3'
    # ::2 = 2x weight on the garden
    # ::3 on the no-people exclusion = very strong exclusion
)

for prompt in midjourney_prompts[:3]:
    print('Midjourney:', prompt[:70], '...')

त्वरित जाँच

Stable Diffusion की कौन-सी तकनीक किसी विशिष्ट negative शब्द के प्रभाव को अन्य शब्दों की तुलना में बढ़ाती है?

Negative प्रॉम्प्ट का सार

Negative प्रॉम्प्ट generation को अवांछित गुणों से दूर ले जाने का एक शक्तिशाली साधन हैं:

  • Stable Diffusion: अलग negative_prompt पैरामीटर; कोष्ठकीय भारांकन का समर्थन
  • DALL-E 3: सकारात्मक प्रॉम्प्ट में 'बचें', 'without' और 'शामिल न करें' का उपयोग करें
  • Midjourney: प्रॉम्प्ट के अंत में --no [terms] जोड़ें
  • सार्वभौमिक निषेध: धुंधला, निम्न गुणवत्ता, वॉटरमार्क, पाठ, अतिरिक्त उँगलियाँ
  • CFG पैमाना: यह नियंत्रित करता है कि सकारात्मक और negative प्रॉम्प्ट generation का कितनी दृढ़ता से मार्गदर्शन करें
  • सीमाएँ: संभावना कम करते हैं, लेकिन बहिष्कार की गारंटी नहीं देते; अधिकतम 15–20 शब्द
शुरुआत निःशुल्क

एआई शिक्षक के साथ AI प्रॉम्प्ट इंजीनियरिंग सीखें — निःशुल्क

अपने ब्राउज़र में वास्तविक कोड लिखें और चलाएँ, चौबीसों घंटे एआई शिक्षक से तुरंत सहायता पाएँ, और वेब या ऐप पर वहीं से शुरू करें जहाँ आपने छोड़ा था।

पाठ्यक्रम
53
पाठ
199

अक्सर पूछे जाने वाले प्रश्न

क्या “नकारात्मक प्रॉम्प्ट और बहिष्करण” पाठ निःशुल्क है?

हाँ — AI प्रॉम्प्ट इंजीनियरिंग अध्ययन पथ के 3 तक कोई भी पाठ, जिसमें “नकारात्मक प्रॉम्प्ट और बहिष्करण” भी शामिल है, यहाँ वेब पर पूरा पढ़ना निःशुल्क है। इसके बाद CoddyKit PRO हर पाठ अनलॉक करता है, साथ ही अंतर्निर्मित कोड संपादक और चौबीसों घंटे एआई शिक्षक के साथ इंटरैक्टिव अभ्यास भी उपलब्ध कराता है। AI प्रॉम्प्ट इंजीनियरिंग पाठ्यक्रम में कुल 4 पाठ शामिल हैं।

“नकारात्मक प्रॉम्प्ट और बहिष्करण” में मैं क्या सीखूँगा?

क्या हटाना है: धुंधला, वॉटरमार्क, भद्दा, विकृत — प्रभावी नकारात्मक प्रॉम्प्टिंग। आप ब्राउज़र में सीधे चलाए जाने वाले व्यावहारिक कोड के साथ AI प्रॉम्प्ट इंजीनियरिंग का अभ्यास करते हैं, और पाठ पूरा करते समय 24/7 एआई ट्यूटर आपके प्रश्नों के उत्तर देता है।

क्या AI प्रॉम्प्ट इंजीनियरिंग शुरू करने के लिए मुझे किसी अनुभव की आवश्यकता है?

पहले के अनुभव की आवश्यकता नहीं है। CoddyKit पर AI प्रॉम्प्ट इंजीनियरिंग शुरुआती से लेकर उन्नत शिक्षार्थियों तक सभी के लिए व्यवस्थित किया गया है, इसलिए आप यहीं से या शुरुआत से सीखना शुरू कर सकते हैं और अपनी गति से आगे बढ़ सकते हैं। यह 4 में से 3वाँ पाठ है।

“नकारात्मक प्रॉम्प्ट और बहिष्करण” पाठ पूरा करने में कितना समय लगता है?

CoddyKit का अधिकांश पाठ लगभग 5–10 मिनट में पूरा हो जाता है। हर पाठ छोटा और संवादात्मक है, इसलिए आप लगातार प्रगति करते हैं और वेब या ऐप पर वहीं से सीखना जारी रख सकते हैं जहाँ आपने छोड़ा था।

क्या मैं इस AI प्रॉम्प्ट इंजीनियरिंग पाठ में कोड लिख और चला सकता हूँ?

हाँ। हर AI प्रॉम्प्ट इंजीनियरिंग पाठ में एक अंतर्निर्मित कोड संपादक शामिल है, जिससे आप सीधे अपने ब्राउज़र में वास्तविक कोड लिख और चला सकते हैं और तुरंत एआई प्रतिक्रिया पा सकते हैं—स्थानीय सेटअप की आवश्यकता नहीं है।

इस पाठ्यक्रम के सभी पाठ

  1. इमेज जनरेशन प्रॉम्प्ट की संरचना
  2. शैली और कलात्मक माध्यम का विनिर्देशन
  3. नकारात्मक प्रॉम्प्ट और बहिष्करण
  4. इमेज प्रॉम्प्ट का क्रमिक परिष्कार
← AI प्रॉम्प्ट इंजीनियरिंग पर वापस जाएँ