Lesson 6: Output Formatting (Controlling the Layout)
1. Introduction
By now, you know how to make AI think clearly and act under a specific persona. But what happens when the AI gives you a great answer, but it is trapped inside a massive wall of text that takes you 10 minutes to clean up?
Professionals don't just prompt for content; they prompt for structure. Output Formatting is the process of explicitly commanding the AI engine to deliver its response in a highly specific, clean layout—such as a Markdown table, a bulleted summary, or code formats like JSON.
2. Why Structure Matters for SEO & Communities
When managing platforms, databases, or social communities, consistency is everything. If you are extracting data (like sorting user feedback or organizing content calendars), structured layouts allow you to copy-paste directly into Excel, Google Sheets, or web applications without wasting time rewriting.
Common professional formats include:
Tables: Perfect for comparisons, schedules, and metrics.
Bullet Points: Best for quick scannability and fast reading.
JSON / Code Blocks: Essential for developers feeding data directly into software or automation pipelines.
3. How to Define the Structure
To get the perfect layout, you must define the exact columns, headers, or keys you want. Do not leave the visual presentation up to the AI's imagination.
The Structure Blueprint:
Act as an expert data analyst."

Analyze the following text and present the results only as a Markdown table."

Use these exact column headers: [Column 1], [Column 2], [Column 3]."

4. Raw Text vs. Structured Table Examp

Unstructured Request (Messy Output)
Analyze the top global news trends this week and give me a summary of what's happening."

Structured Request (Clean & Professional)

Act as a global media analyst for a digital magazine. Analyze the top 3 global news trends this week.

Present your findings strictly in a Markdown table with the following headers: **Region

image

What is Prompt Engineering?
Prompt: The input, question, or instruction you give to the AI.
Prompt Engineering: The art and science of phrasing your request so the AI gives you the exact output you want.

تعارف (Introduction)
کیا کبھی ایسا ہوا ہے کہ جلدی میں کسی پیچیدہ مسئلے کا جواب دیتے ہوئے آپ سے کوئی چھوٹی سی غلطی ہو گئی ہو کیونکہ آپ نے اسے سکون سے مرحلہ وار نہیں سوچا تھا؟ AI انجن بھی بالکل ایسا ہی کرتے ہیں! اگر آپ AI سے کوئی مشکل حساب کتاب، منطقی الجھن، یا کاروباری حکمتِ عملی کا سوال پوچھیں، تو وہ اکثر تیزی سے غلط جواب دے دیتا ہے۔
چین آف تھاٹ پرامپٹنگ (Chain-of-Thought Prompting) اس مسئلے کو حل کرتی ہے۔ یہ تکنیک AI کو مجبور کرتی ہے کہ وہ آخری جواب دینے سے پہلے اپنی سوچ اور منطق کو چھوٹے چھوٹے اقدامات میں تقسیم کر کے "اونچا سوچے"۔
2. یہ طریقہ کیوں کارآمد ہے؟
AI جب بھی کوئی جملہ لکھتا ہے، تو اس کا اگلا لفظ پچھلے لکھے ہوئے الفاظ پر منحصر ہوتا ہے۔ جب آپ AI کو اپنے منطقی مراحل پہلے لکھنے پر مجبور کرتے ہیں، تو وہ درست حقائق کی ایک مضبوط بنیاد بنا لیتا ہے، جس سے آخری جواب کے درست ہونے کا امکان کئی گنا بڑھ جاتا ہے۔
یہ طریقہ ان کاموں کے لیے بہترین ہے:
پیچیدہ ریاضی، بجٹ یا مالیاتی حساب کتاب۔
کوڈنگ، ویب سائٹ ڈیٹا اسٹرکچرز، یا آٹومیشن کے مسائل کو حل کرنا۔
کاروباری حالات اور اسٹریٹجک فیصلوں کا تجزیہ کرنا۔
3. جادوئی جملے (The Magic Phrases)
اس طاقتور خصوصیت کو استعمال کرنے کے لیے آپ کو کسی مشکل فارمولے کی ضرورت نہیں ہے۔ اپنے سوال کے آخر میں بس ان میں سے کوئی ایک جملہ لکھ دیں:
"آئیں مرحلہ وار سوچتے ہیں۔" (Let's think step-by-step.)
"آخری جواب دینے سے پہلے اپنی منطق کو ترتیب وار مراحل میں واضح کریں۔"
"اپنے حساب کتاب کا طریقہ کار اور منطق تفصیل سے دکھائیں۔"
4. عام پرامپٹ اور چین آف تھاٹ پرامپٹ کا موازنہ
عام پرامپٹ (غلطی کا امکان)
ایک کسان کم بجٹ سے بھیڑوں کا فارم شروع کرنا چاہتا ہے۔ اگر زمین کی قیمت 2,000 ڈالر ہو، اور وہ 150 ڈالر فی بھیڑ کے حساب سے 25 بھیڑیں خریدے، تو کل ابتدائی لاگت کیا ہوگی؟

چین آف تھاٹ پرامپٹ (بالکل درست جواب)

ایک کسان 25 بھیڑوں کے ابتدائی اسٹاک کے ساتھ بھیڑوں کا فارم شروع کرنا چاہتا ہے۔ اگر زمین کی قیمت 2,000 ڈالر ہو اور ایک بھیڑ کی قیمت 150 ڈالر ہو، تو کل ابتدائی لاگت کیا ہوگی؟

ہدایات: آئیں مرحلہ وار سوچتے ہیں۔ سب سے پہلے بھیڑوں کے اسٹاک کی کل قیمت نکالیں۔ دوسرے مرحلے میں اس میں زمین کی قیمت جمع کریں۔ آخر میں کل لاگت واضح طور پر لکھیں۔"

image

Chain-of-Thought Prompting (Logical Reasoning)

1. Introduction
Have you ever rushed into a complex problem and made a careless mistake because you didn’t take the time to think it through step-by-step? AI engines do the exact same thing! If you ask an AI a complicated math, logic, or business strategy question, it often generates a fast but incorrect answer.
Chain-of-Thought (CoT) Prompting fixes this by instructing the AI to break down its reasoning into sequential steps before giving the final conclusion.
2. Why Does It Work?
When an AI generates text word-by-word, its subsequent words depend on the words it just wrote. By forcing the AI to draft its logical steps first, it builds a solid foundation of correct intermediate facts, which dramatically increases the accuracy of the final answer.
This framework is highly effective for:
Complex math, analytical, or financial calculations.
Troubleshooting code, website data structures, or workflow automations.
Evaluating complex business scenarios or strategic decisions.
3. The Magic Phrases to Use
You don't need a complicated formula to unlock this capability. Simply appending one of these phrases to the end of your query forces the AI engine to activate its reasoning chain:
"Let's think step-by-step."
"Break down your reasoning into logical stages before giving the final answer."
"Show your work and explain your logic sequentially."
4. Direct Prompt vs. Chain-of-Thought Example

Direct Prompt (Prone to Errors)
A farmer starts with a small budget and wants to build a sheep farm. If land costs $2,000, and he buys 25 sheep at $150 each, what is his total initial setup cost?"

Chain-of-Thought Prompt (Highly Accurate)

A farmer wants to build a sheep farm with an initial stock of 25 sheep. If land costs $2,000, and each sheep costs $150, what is his total initial setup cost?

Instructions: Let's think step-by-step. First, calculate the cost of the sheep stock. Second, add the land cost. Show the final total clearly at the end."

image

سبق 4: فیو-شاٹ پرامپٹنگ (مثالوں کے ذریعے AI کو سکھانا)
1. تعارف (Introduction)
اب تک آپ سیکھ چکے ہیں کہ کس طرح تفصیلات (Specificity) کا استعمال کرنا ہے، AI کو کوئی خاص کردار یا پرسنلٹی (Persona) کیسے دینی ہے، اور اس کے جواب کو قابو میں رکھنے کے لیے حدود (Constraints) کیسے لگانی ہیں۔ لیکن بعض اوقات صرف الفاظ کے ذریعے AI کو کوئی مشکل انداز، تحریر کا لہجہ، یا فارمیٹنگ کا اصول سمجھانا کافی نہیں ہوتا۔
یہیں پر کام آتی ہے فیو-شاٹ پرامپٹنگ (Few-Shot Prompting)۔ اس تکنیک میں آپ AI کو صرف یہ نہیں بتاتے کہ آپ کو کیا چاہیے، بلکہ آپ اسے چند عملی مثالیں دے کر دکھاتے ہیں کہ آپ کو کیسا جواب پسند ہے۔
زیرو-شاٹ پرامپٹنگ (Zero-Shot Prompting): AI کو بغیر کسی مثال کے براہ راست کوئی کام کہنا۔
فیو-شاٹ پرامپٹنگ (Few-Shot Prompting): اپنے سوال کے ساتھ AI کو چند مثالیں (عام طور پر 1 سے 3) فراہم کرنا تاکہ وہ آپ کا مطلوبہ پیٹرن (Pattern) سمجھ سکے۔
2. مثالیں دینے کا فائدہ کیوں ہے؟
AI ماڈلز "پیٹرن ریکگنیشن" (دکھائے گئے ڈیزائن یا طریقے کو سمجھنے) میں لاجواب ہوتے ہیں۔ اگر آپ AI کو ان پٹ (سوال) اور آؤٹ پٹ (جواب) کا ایک خاص طریقہ کار دکھا دیں، تو وہ اس کے ڈھانچے، لہجے اور منطق کا تجزیہ کرتا ہے اور آپ کے نئے ڈیٹا پر بالکل اسی طرح کا جواب تیار کر دیتا ہے۔
یہ طریقہ ان کاموں کے لیے سب سے زیادہ کارآمد ہے:
ایک ہی اسٹائل کی کیچی سرخیاں (Headlines) یا سوشل میڈیا پوسٹس لکھنا۔
ڈیٹا کی درجہ بندی (Classification) کرنا۔
ایسے پیچیدہ فارمیٹس بنانا جنہیں صرف الفاظ میں سمجھانا مشکل ہو۔
3. فیو-شاٹ پرامپٹ لکھنے کا فارمیٹ (The Blueprint)
جب بھی فیو-شاٹ پرامپٹ لکھیں، تو واضح ہیڈنگز یا لیبلز جیسے ⁠Input:⁠ (ان پٹ) اور ⁠Output:⁠ (آؤٹ پٹ) یا ⁠Example:⁠ (مثال) کا استعمال کریں
ڈھانچہ:
[AI کا کردار / پرسنلٹی]
مثال
1:
ان پٹ: [نمونہ سوال 1]
آؤٹ پٹ: [مطلوبہ جواب 1]

مثال 2:
ان پٹ: [نمونہ سوال 2]
آؤٹ پٹ: [مطلوبہ جواب 2]

نیا ٹاسک:
ان پٹ: [آپ کا اصل ڈیٹا یا سوال]
آؤٹ پٹ:

4. زیرو-شاٹ اور فیو-شاٹ پرامپٹ کا موازن

زیرو-شاٹ پرامپٹ (بغیر مثال کے)
ایک نئے سوشل میڈیا پلیٹ فارم کے لیے ایک پرکشش سرخی (Headline) لکھو۔"

فیو-شاٹ پرامپٹ (مثالوں کے ساتھ)

"ایک پروفیشنل کاپی رائٹر کا کردار ادا کرو۔ نیچے دیے گئے پیٹرن کے مطابق ایک نئے سوشل میڈیا پلیٹ فارم کے لیے سرخی لکھو۔

مثال 1:
موضوع: فٹنس ایپ
سرخی: اندازے لگانا چھوڑیں، پسینہ بہانا شروع کریں: آپ کا پرسنل ٹرینر، آپ کی جیب میں۔

مثال 2:
موضوع: بجٹ بنانے والا ٹول
سرخی: اپنے پیسے کے مالک بنیں: ٹریک کریں، بچائیں اور بغیر کسی پریشانی کے دولت بڑھائیں۔

نیا ٹاسک:
موضوع: ایک لوکل سوشل میڈیا کمیونٹی پلیٹ فارم جس کا نام Partvibe ہے۔
سرخی:"


📝 سبق 4 کا ہوم ورک (Homework)
ابھی اپنے AI پلے گراؤنڈ کو کھولیں اور اس پیٹرن کو سمجھنے کی تکنیک کا خود تجربہ کریں:

اس اسٹرکچرڈ پرامپٹ کو بالکل اسی طرح کاپی کر کے پیسٹ کریں:

ایک تخلیقی نام رکھنے والے اسسٹنٹ (Naming Assistant) کا کردار ادا کرو۔ کاروباری تفصیلات کو مختصر اور جاندار 1 لفظی برانڈ ناموں میں تبدیل کرو۔

مثال 1:
تفصیل: گھر کے بنے ہوئے فوری کھانے شیئر کرنے کے لیے ایک موبائل ایپ۔
نام: Dishy

مثال 2:
تفصیل: پیشہ ورانہ اوزار شیئر کرنے کے لیے محلے کا ایک مقامی نیٹ ورک۔
Name: ToolShare

نیا ٹاسک:
تفصیل: ایک عام سوشل میڈیا کمیونٹی پلیٹ فارم جو محلے کی نیٹ ورکنگ اور پروفیشنل رابطوں پر مرکوز ہو۔
نام:

image
Sur

Prompt Engineering Guide examines generative AI tools, how they work. We'll explore how to combine Google Cloud knowledge with prompt engineering to improve Gemini responses.