AI Scope
136 subscribers
193 photos
21 videos
18 files
113 links
Download Telegram
چرا شبکه‌های عصبی؟

🔬هوش مصنوعی مدرن روی دوش شبکه‌های عصبی بنا شده. اما قبل از اینکه تبدیل به موتور پشت LLMها و مدل‌های بینایی بشن، از چیزی خیلی ساده‌تر شروع شدن: تقلید ریاضی از مغز.


Why Neural Networks?

Modern AI is powered by neural networks. But before they became the engines behind LLMs and vision models, they started from something much simpler: a mathematical imitation of the brain. To appreciate the cutting-edge, we need to grasp the basics.


🦴 @scopeofai | #concepts
یک نورون دقیقاً چیکار می‌کنه؟

در زیست‌شناسی، نورون سیگنال‌ها رو دریافت می‌کنه، پردازش می‌کنه و اگه قوی باشن، خروجی می‌ده.
در شبکه عصبی هم همین اتفاق می‌افته:

1️⃣ورودی‌ها به شکل عدد میان.

2️⃣هر ورودی در یک وزن (اهمیت) ضرب می‌شه.

3️⃣همه با هم جمع می‌شن.

4️⃣یک بایاس هم اضافه می‌شه (برای تغییر نقطه حساسیت).

5️⃣ در نهایت، تابع فعال‌سازی تصمیم می‌گیره خروجی چی باشه.


این واحد ساده، آجر اولیه تمام مدل‌های غول‌پیکر امروزیه.

What Does a Neuron Actually Do?

In biology, a neuron receives signals through its dendrites, processes them, and fires an output if the signal is strong enough.
In neural networks, we mimic this:

1️⃣Inputs come in as numbers (features).

2️⃣Each input is multiplied by a weight (importance).

3️⃣All weighted inputs are added together.

4️⃣A bias is added (shifts the decision boundary).

5️⃣Finally, an activation function decides the output.

This simple unit is the foundation of everything from perceptrons to GPT-4.


🦴 @scopeofai | #concepts
شبکه عصبی چطور یاد می‌گیره؟

یادگیری یعنی تنظیم وزن‌ها و بایاس‌ها تا پیش‌بینی درست انجام بشه.

۱. ورودی وارد شبکه می‌شه.
۲. خروجی ساخته می‌شه.
۳. با جواب درست مقایسه می‌کنیم.
۴. خطا (loss) حساب می‌شه.
۵. وزن‌ها طوری تغییر می‌کنن که خطا کمتر بشه.

🌀این چرخه بارها تکرار می‌شه تا شبکه الگوها رو درست یاد بگیره.

How Does a Neural Network Learn?

Learning means adjusting weights and biases so that predictions match reality.

1-Input goes through the network.

2-Network produces an output.

3-Compare output with the correct answer (label).

4-Calculate the error (loss).

5-Update the weights to reduce that error.

🌀 Repeat this thousands (or millions) of times, and the network gradually internalizes patterns. This is called training.


🦴 @scopeofai | #concepts
وزن و بایاس؛ اهرم‌های پنهان

🔹وزن: اهمیت هر ورودی رو مشخص می‌کنه.

🔹بایاس: مثل یه ثابت عمل می‌کنه و کل تابع رو جابه‌جا می‌کنه.

بدون بایاس، شبکه‌ها قدرت انعطاف کمتری داشتن.

📣 فرض کن یک نورون داریم که ورودی‌ها رو می‌گیره، هر کدوم رو در وزن خودش ضرب می‌کنه و بعد جمع می‌کنه. بدون بایاس، خروجی نورون همیشه از صفر عبور می‌کنه وقتی همه ورودی‌ها صفر باشن یعنی شبکه محدود می‌شه و نمی‌تونه بعضی الگوها رو یاد بگیره.


وزن = قدرت تاثیر ورودی

بایاس = خط پایه یا نقطه شروع نورون


بدون بایاس، شبکه مجبور می‌شه خط پاسخ از مبدا (0,0) عبور کنه. با بایاس، می‌تونه این خط رو جابه‌جا کنه و هرجایی که لازمه تصمیم بگیره.

Weights and Biases — The Hidden Levers

Weight: Determines the importance of each input.

Bias: Acts like a constant that shifts the entire function.

Without bias, networks would have much less flexibility.
Think of weight as the volume knob, and bias as shifting the baseline level.

🔈 Imagine a neuron that takes inputs, multiplies each by its weight, and then sums them up. Without bias, the neuron’s output will always pass through zero when all inputs are zero. That limits the network and prevents it from learning certain patterns.

Weight = strength of influence of an input

Bias = the baseline or starting point of the neuron


Without bias, the network is forced to have its decision boundary pass through the origin (0,0). With bias, it can shift that boundary and make decisions wherever needed.


🦴 @scopeofai | #concepts
👍1
پس‌انتشار خطا (Backpropagation)؛ قلب یادگیری شبکه

برای اینکه شبکه عصبی یاد بگیره، باید بدونیم کدوم ورودی‌ها و وزن‌ها باعث خطا شدن و چقدر باید تغییر کنن.

اینجاست که پس‌انتشار خطا وارد می‌شه:

شبکه یه پیش‌بینی می‌کنه و ما خطا (فرق بین جواب واقعی و جواب شبکه) رو حساب می‌کنیم.

🗝 این خطا به تدریج از خروجی به سمت لایه‌های قبلی منتقل می‌شه تا مشخص بشه هر وزن چقدر مسئول خطاست.

حالا می‌تونیم هر وزن رو به اندازه سهمش در خطا تغییر بدیم.

📍 تصور کن شبکه مثل یه گروه آدمه که با هم پروژه‌ای انجام دادن. نتیجه نهایی اشتباه بود. پس همه به عقب نگاه می‌کنن و می‌فهمن هر کس چقدر تو اشتباه تاثیر داشت و بر اساس اون، کارش رو اصلاح می‌کنه.

پس‌انتشار خطا روشیه که باعث شد شبکه‌های عمیق و پیشرفته ممکن بشن، چون بدون اون نمی‌تونستیم لایه‌ها رو درست آموزش بدیم.

Backpropagation — The Real Breakthrough

Training requires knowing which weights to tweak and how much. That’s where backpropagation enters.

It’s essentially calculus at scale:

Compute the gradient of the loss function with respect to every weight.

🖇 Use the chain rule to propagate errors backward from output → hidden layers → input.

Update each parameter in proportion to its contribution to the error.

Backpropagation was the key innovation that unlocked deep learning in the 1980s. Without it, we wouldn’t have today’s AI revolution.


🦴 @scopeofai | #concepts
نرخ یادگیری؛ اندازه قدم‌ها برای اصلاح

وقتی وزن‌ها رو تغییر می‌دیم، باید میزان تغییر رو کنترل کنیم. این همون چیزی‌یه که بهش می‌گیم نرخ یادگیری (η):

⚫️اگه زیاد باشه شبکه ممکنه مسیر رو اشتباه بره و نره سر جای درست.

⚪️اگه کم باشه آموزش خیلی آهسته پیش می‌ره

روش‌های مدرن مثل Adam یا RMSProp این مقدار رو به صورت هوشمند تنظیم می‌کنن تا هم سرعت مناسب باشه هم پایدار.

The Learning Rate — The Dial of Progress

When updating weights, we don’t apply the raw gradient. We multiply it by a small constant: the learning rate (η).

Too high → the network overshoots, oscillates, or fails to converge.

Too low → training crawls, maybe never reaching a good solution.

Tuning the learning rate is both an art and a science. Modern optimizers (Adam, RMSProp, etc.) adapt it dynamically.


🦴 @scopeofai | #concepts
ساخت اولین شبکه عصبی (پرسیپترون)

ساده‌ترین شبکه عصبی پرسیپترونه: دو ورودی و یک خروجی.

مثل یاد دادن دروازه منطقی OR یا AND به ماشین. همه ورودی‌ها به شبکه داده می‌شن، خروجی با جواب مقایسه می‌شه، وزن‌ها تغییر می‌کنن تا جدول درست پیاده بشه.

اینجا کل چرخه یادگیری رو در کوچک‌ترین مقیاس می‌بینیم:
ورودی ⬅️ جمع وزنی ⬅️ تابع فعال‌سازی ⬅️ خروجی ⬅️ خطا ⬅️ به‌روزرسانی وزن‌ها.

با کنار هم گذاشتن چند پرسیپترون ساده، به شبکه‌های چندلایه (MLP) می‌رسیم که می‌تونن تقریباً هر تابعی رو مدل کنن.

Building Our First Neural Network (Perceptron)

The simplest neural network is the Perceptron. Imagine two inputs feeding into one output neuron.

Training it on logic gates (like OR/AND) is the classic exercise. You feed in all possible inputs, compare the output to the truth table, and adjust weights until the perceptron reproduces the logic perfectly.

This shows the full learning cycle in miniature:

Inputs → weighted sum → activation → output → error → weight update.

From here, stacking multiple perceptrons leads to multi-layer networks, which can approximate almost any function.


🦴 @scopeofai | #concepts
پنجره زمینه (Context Window) چیه؟

🪟 پنجره‌ی زمینه (یا طول زمینه) یعنی مقدار متنی که مدل زبانی بزرگ (LLM) می‌تونه همزمان «ببینه» یا «به خاطر بسپاره»، که با واحدی به اسم «توکن» اندازه‌گیری می‌شه.

مثل حافظه‌ی کاری بشره. مدل وقتی داره متن تولید می‌کنه، بخش‌هایی از مکالمه یا سند قبلی رو به یاد داره تا خروجی مناسبی بده.

اگر مقداری که وارد می‌کنی از این حد فراتر بره، بخشی از متن باید بریده بشه یا خلاصه شه تا مدل بتونه ادامه بده.

The context window (also called “context length”) is how much text (in tokens) a large language model (LLM) can “see” or “remember” at once.

It’s like working memory: it lets the model use prior parts of a conversation or document when generating output.
IBM

If you give a prompt + conversation that exceed the context window, the extra parts have to be truncated (cut off) or summarized.


🦴 @scopeofai | #concepts
♨️ پنجره زمینه بزرگ‌تر به مدل‌ها اجازه می‌ده ورودی‌های بلندتری رو پردازش کنن: اسناد طولانی، کدهای زیاد، سابقه مکالمه‌ها بدون اینکه جزئیات اوایلشون رو فراموش کنن.

مدل‌هایی که مقدار context بزرگ‌تری دارن معمولا پاسخ‌های منسجم‌تری می‌دن، خطاهای توهمی‌شون کمتره، مخصوصاً وقتی درخواست یا پرامپت طولانی باشه.

اما بزرگ‌تر کردن پنجره زمینه هزینه‌ها هم داره: محاسبات بیشتر، مصرف حافظه بالاتر، هزینه مالی و زمان پاسخ‌دهی بیشتر. همچنین ریسک‌های امنیتی، مثل این که ورودی‌های مخرب بتونن توی متون بلند پنهان بمونن، افزایش پیدا می‌کنن.

Bigger context windows let LLMs handle longer inputs: long documents, code, chat histories without forgetting early details.

Models with larger context length tend to be more coherent, make fewer hallucinations, and give more accurate responses when prompts are long.

But increasing context window has trade-offs: more computation, higher memory, more cost, potentially slower responses. Also, security risks like adversarial prompt injections grow.


🦴 @scopeofai | #concepts
🔅 دونستن اندازه پنجره زمینه کمک می‌کنه پرامپت‌ها رو بهتر طراحی کنی: اطلاعات مهم رو در ابتدا یا انتها بذار تا از بین نرن.

بعضی مدل‌ها مثل Granite شرکت IBM الان پنجره‌هایی تا حدود ۱۲۸۰۰۰ توکن دارن، که امکان پردازش اسناد یا مکالمات خیلی طولانی رو در یک مرحله فراهم می‌کنن.

محدودیت‌ها هم وجود دارن. حتی اگر پنجره خیلی بزرگ باشه، مدل ممکنه قسمت‌های میانی ورودی رو نادیده بگیره یا کیفیت پاسخ‌ها پایین بیاد. همچنین هزینه‌ها (محاسبه، حافظه) تقریباً با مجذور تعداد توکن‌ها زیاد می‌شن.

For practical systems: if you're building chatbots or tools that use LLMs, knowing the context window size helps you design prompts better: keep key info near beginning or end so it isn’t lost.

Some models (e.g. IBM’s Granite) now have windows up to 128,000 tokens, enabling much longer documents / conversations to be handled in one go.

Limitations: even if the window is large, models might still “ignore” middle parts of the input, or performance may degrade. Also, the cost (compute, memory) scales roughly quadratically with token count.


🦴 @scopeofai | #concepts
🪤 متا پرامپت چیه؟

متا پرامپت یه سری دستور کلیه که مشخص می‌کنه هوش مصنوعی چطوری رفتار کنه یا جواب بده.

فرقش با یه پرامپت عادی اینه که فقط برای یه سؤال یا یه جواب نیست؛ بلکه مثل یه «قالب» یا «چهارچوب» عمل می‌کنه که همه جواب‌ها توی همون خط بیاد.

مثلا می‌تونی هوش مصنوعی رو طوری تنظیم کنی که همیشه مثل یه دستیار آموزشی جواب بده، لحنش رسمی باشه، یا طبق یه برنامه‌ی درسی مشخص محتوا تولید کنه.
What is a Meta Prompt?

A meta prompt is a set of higher-level instructions that shapes how an AI behaves or responds in general, not just for a single task. Think of it as the framework or lens through which all following prompts are interpreted.

It defines the AI’s role/persona, sets rules or constraints, establishes style, tone, sometimes even procedural steps. This ensures consistency across multiple interactions.

Example: Suppose you want AI to always answer as a teaching assistant, align with a certain curriculum, use certain formatting, etc.


🦴 @scopeofai | #concepts
اجزای اصلی متا پرامپت

🔷تعریف نقش مشخص می‌کنه AI کیه. مثلا: «تو یه دستیار آموزشی هستی که کارش درست کردن ورک‌شیت برای کلاس فلان بر اساس فلان سرفصل درسیه…»

🔷هدف می‌گه قرار آخرش به چی برسیم. مثل: «کمک به معلم برای تولید ورک‌شیت جذاب و منظم که با اهداف درسی هم‌خوان باشه.»

🔷دستورالعمل مرحله‌ای قدم‌به‌قدم توضیح می‌ده چیکار کنه. مثلا: اول موضوع درس رو بپرس، بعد اهداف رو مشخص کن، بعد بخش‌های ورک‌شیت رو بساز.

🔷نکات ویژه لحن، سبک نوشتن، سطح دشواری، رعایت محدودیت‌های سنی و فرهنگی، یا حتی نوع فرمت.

🔷انعطاف‌پذیری متا پرامپت خوب باید جا برای تغییر داشته باشه. مثلا اگه کاربر گفت فلان بخش رو تغییر بده، AI بتونه خودش رو وفق بده.


Key Elements of Meta Prompts

Here are the main ingredients that good meta prompts often include:

Element Function / Why It Matters
Role Definition Sets who the AI is in this context. For example: “You are a helpful and experienced teaching assistant specialising in creating worksheets aligned with [curriculum] …” This gives the AI a clear identity.

Goal Setting Tells the AI what outcome you want. What is the end-objective? If the goal is “guide teachers through generating well-structured, engaging worksheets that complement lesson plans …”, then everything the AI does is steered toward that.

Procedural Instructions The “how” part: step-by-step directions on how the AI should proceed. Eg: ask the teacher about subject, grade, topic; wait; then produce elements. These help avoid messy or inconsistent outputs.

Specific Considerations Style or tone: how the AI should sound (friendly, supportive, formal); content constraints (age-appropriateness, cultural relevance); formatting rules. These maintain quality and relevance.

Flexibility / Adaptability Even though meta prompts are strong, good ones allow room for feedback, changing requirements, responsiveness. AI should be able to adjust when conditions change (e.g. teacher asks for adjustments)


🦴 @scopeofai | #concepts
چرا متا پرامپت مهمه؟

◽️یکدست بودن: جواب‌ها همه یه سبک دارن

◽️صرفه‌جویی در وقت: لازم نیست هر دفعه همه‌چیزو از اول توضیح بدی.

◽️تخصصی شدن: AI رو می‌تونی تبدیل به یه متخصص توی یه حوزه خاص کنی.

◽️تمرکز روی نیاز کاربر: چون هدف و قواعد روشنه، خروجی به چیزی که کاربر می‌خواد نزدیک‌تره.

Benefits of Meta Prompt

Consistency across multiple tasks or queries. AI doesn’t flip style or approach unexpectedly.


Efficiency: fewer clarifications needed each time. You set context once

Specialisation: AI can be made expert-like in a domain (education, legal, creative writing etc.)

User-Centric: better alignment with what the user or stakeholder needs, because the meta prompt encodes priorities


🦴 @scopeofai | #concepts
💡نمونه یه متا پرامپت

تو یه دستیار آموزشی با تجربه‌ای هستی که کارش تولید ورک‌شیت برای معلم‌هاست، هدفت اینه که به معلم کمک کنی ورک‌شیت‌هایی منظم، جذاب و هم‌راستا با اهداف آموزشی درست کنن.

ابتدا به معلم سلام کن و بپرس برای چه درسی، چه پایه‌ای و چه موضوعی ورک‌شیت می‌خواد. هر بار یه سؤال بپرس و منتظر جواب بمون. وقتی اطلاعات رو گرفتی:

1. سرفصل مربوط رو بررسی کن تا مطمئن شی ورک‌شیت با اون هماهنگه.
2. از معلم بپرس دقیقا دنبال چه خروجی‌های یادگیری‌ایه.
3. قدم‌به‌قدم راهنمایی کن تا بخش‌های ورک‌شیت شکل بگیره: عنوان، دستورالعمل‌ها، واژگان، انواع سؤال، تمرین‌های کاربردی، شکل یا نمودار، سؤال‌های تحلیلی و… .
4. برای هر بخش مثال و پیشنهاد بده.
5. بعد از هر بخش نظر معلم رو بپرس.
6. در آخر نسخه کامل ورک‌شیت رو با کلید پاسخ آماده کن.
7. اگه لازمه، برای ارزیابی هم یه جدول نمره‌دهی (روبریک) پیشنهاد بده.
8. بپرس آیا ورک‌شیت باید برای سطح‌های مختلف دانش‌آموز هم تنظیم بشه.
9. اگه نیاز بود، المان‌های دیجیتال یا منابع آنلاین مرتبط هم پیشنهاد بده.

همیشه یادت باشه:
- لحن دوستانه و حمایتی داشته باشی
- نیاز معلم رو در اولویت بذاری ولی منطبق باشی
- محتوای سن‌متناسب، مرتبط با فرهنگ آفریقای جنوبی و هم‌خوان با سرفصل باشه
- ورک‌شیت رو جذاب و متنوع کن
- نکات کاربردی برای استفاده در کلاس یا تکلیف بده
- تفاوت‌های زبانی کلاس‌ها رو در نظر بگیر و راهکار برایش بده


🦴 @scopeofai | #concepts
Here is the full system (meta) prompt from the article. It shows all the parts coming together. You can use it as a template.


CAPS-Aligned Worksheet Generation Assistant

You are a helpful and experienced teaching assistant specialising in creating worksheets aligned with the South African Curriculum and Assessment Policy Statements (CAPS). Your goal is to guide teachers through generating well-structured, engaging worksheets that complement their lesson plans and reinforce key learning objectives as outlined in CAPS.

To begin, greet the teacher and ask about the specific subject, grade, and topic for which they need a worksheet. Ask one question at a time and wait for the teacher’s reply. Once the teacher provides this information, follow these steps:

1. Review the relevant CAPS document to ensure the worksheet aligns with the curriculum requirements, including the content, skills, and assessment standards for the specific subject and grade.
2. Ask the teacher which specific learning outcomes they want to focus on for the worksheet, referring to the CAPS-specified outcomes for that subject and grade.
3. Guide the teacher through the worksheet creation process, prompting them to consider the following elements:
- Title and clear instructions in the language of instruction
- Vocabulary section (5-10 key terms related to the topic, including any necessary translations for multilingual classrooms)
- Variety of question types (e.g., multiple choice, short answer, fill-in-the-blanks, matching)
- Application questions or problem-solving tasks relevant to the South African context
- Visual elements (e.g., diagrams, charts, or images to label or analyse)
- Higher-order thinking questions aligned with Bloom’s Taxonomy
- Extension or challenge section for advanced learners
4. For each section of the worksheet, provide suggestions and examples based on CAPS guidelines and best practices in worksheet design. Encourage a mix of question types and difficulty levels to cater to diverse learners and meet CAPS assessment requirements.

5. After completing each section, confirm with the teacher if they want to refine it or if they’re happy to proceed to the next section.

6. Once all sections are approved, present the complete worksheet layout, including an answer key and marking guidelines as per CAPS requirements.

7. Offer to create a rubric or scoring guide for the worksheet that aligns with CAPS assessment standards.

8. Ask if the teacher would like the worksheet to be differentiated for various ability levels, ensuring it still meets CAPS requirements for all learners.

9. Inquire if the teacher needs any digital or interactive elements added to the worksheet, such as links to relevant

South African educational resources or online activities, if appropriate for their classroom context.

Always remember:

- Maintain a friendly and supportive tone throughout the conversation
- Prioritise the teacher’s needs and goals for the worksheet while ensuring CAPS compliance
- Ensure all content is age-appropriate, culturally relevant to South Africa, and aligns with CAPS standards
- Suggest ways to make the worksheet visually appealing and engaging for students
- Offer tips on how to use the worksheet effectively in class or as homework, considering potential resource constraints in various South African school settings
- Be mindful of the multilingual nature of South African classrooms and suggest ways to support language development alongside subject content

Always be ready to adjust the worksheet based on the teacher’s feedback, specific classroom needs, and any recent updates to C


🦴 @scopeofai | #concepts
دمای LLM چیه؟

🌡 وقتی از LLM (مدل‌های زبانی بزرگ) حرف می‌زنیم، دمـا (Temperature) یکی از پارامترهای کلیدیه که مشخص می‌کنه خروجی مدل چقدر «تصادفی» یا «خلاقانه» باشه.

مدل‌های زبانی همیشه پیش‌بینی می‌کنن که کدوم کلمه (یا توکن) بعدی با چه احتمالی بیاد.

دما این توزیع احتمالات رو دستکاری می‌کنه:

دمای پایین: احتمال بیشتر برای انتخاب مطمئن‌ترین کلمه ⬅️ متن قابل پیش‌بینی‌تر و منظم‌تر.

دمای بالا: فرصت بیشتر برای انتخاب کلمات غیرمنتظره ⬅️ متن متنوع‌تر و خلاقانه‌تر، ولی پرریسک‌تر.

پس بسته به هدف، می‌تونی دما رو تغییر بدی: برای جواب دقیق و محکم، دمای پایین؛ برای ایده‌پردازی یا داستان‌نویسی، دمای بالاتر.

What is LLM Temperature?

When we talk about LLMs (Large Language Models), temperature is a key parameter that controls how “random” the generated text will be.

LLMs predict the next token (word or part of a word) based on a probability distribution over possible tokens.
The temperature setting modifies that distribution:

Lower temperature → pushes probability more toward the highest-probability tokens → more predictable, more coherent text.

Higher temperature → flattens the distribution (or gives more chance to less probable tokens) → more variety, more creativity, but also risks of incoherence.

Why it matters: depending on your use case, you might want precision and consistency (e.g. factual answers, documentation) or you might want creativity (e.g. story-writing, brainstorming)


🦴 @scopeofai | #concepts
تنظیم دما

برای کنترل خروجی LLM فقط دما نیست، چندتا پارامتر مهم دیگه هم نقش دارن

🔹Temperature: دما مستقیماً میزان تصادفی بودن خروجی رو تعیین می‌کنه. دمای پایین یعنی مدل خیلی دقیق و قابل پیش‌بینی جواب می‌ده، دمای بالا یعنی متن خلاقانه‌تر ولی کم‌ثبات‌تر

🔹do_sample: اگه فعال باشه، مدل به‌جای انتخاب همیشه مطمئن‌ترین کلمه، از بین چند گزینه انتخاب می‌کنه. در واقع بدون فعال بودنش، تغییر دما هم بی‌فایده‌ست

🔹top_k: این پارامتر تعداد گزینه‌هایی رو که مدل می‌تونه انتخاب کنه محدود می‌کنه. عدد کم یعنی مدل محتاط‌تر و جواب‌ها قابل‌اعتمادتر. عدد بالا یعنی آزادی عمل بیشتر

🔹top_p: به‌جای تعداد مشخص، مدل از بین مجموعه‌ای انتخاب می‌کنه که مجموع احتمالش به یه حد خاص برسه (مثلاً ۹۵٪). این باعث میشه متن تنوع داشته باشه ولی پرت و پلا هم نشه


Configuring Temperature

To control LLM output, temperature isn’t the only factor. Several other parameters also shape the results:

Temperature: Directly controls the randomness of the output. Low values make the model very precise and predictable. Higher values add creativity but reduce stability.

do_sample: If enabled, the model samples from multiple possible tokens instead of always choosing the most likely one. Without this, temperature adjustments won’t matter.

top_k: Limits the model’s choices to the top k most probable tokens. A small value keeps it conservative and reliable; a larger value gives more freedom.

top_p: Instead of a fixed number, the model chooses from the smallest set of tokens whose cumulative probability passes a threshold (e.g., 95%). This keeps variety while avoiding nonsense.


🦴 @scopeofai | #concepts
کنترل خروجی فراتر از دما

دما تنها ابزار کنترل نیست. برای گرفتن خروجی دقیق‌تر، اینا هم کاربرد دارن:

❇️حداکثر طول (max length): جلوی پرحرفی یا بی‌راهه رفتن مدل رو می‌گیره.

✳️Stop sequences: به مدل می‌گه کجا متوقف بشه.

Frequency penalty: جلوی تکرار زیاد یه کلمه رو می‌گیره.

Presence penalty: تنوع ایجاد می‌کنه و باعث میشه مدل دنبال همون کلمات قبلی نره.

ترکیب این‌ها با دما می‌تونه خروجی خیلی دقیق‌تر و قابل‌مدیریت‌تر بده.

Controlling Output Beyond Temperature

Temperature isn't the only knob. To get output that better fits what you want, you often combine parameters and control mechanisms.


Here are other levers:

❇️Maximum length: how many tokens the model can output. Keeps responses from going off-tangent.

❇️Stop sequences: define sequences that tell the model, “stop here.” Handy for structured output: emails, lists, dialogues.

❇️Frequency penalty: penalizes tokens (words) that are used often in output; discourages repetition.

❇️Presence penalty: penalizes simply for whether a token has already appeared (not how many times). Helps ensure variety.


Combining these with temperature + sampling parameters gives you fine-grained control over what the LLM produces.


🦴 @scopeofai | #concepts
مقایسه خروجی با IBM Granite

برای روشن‌تر شدن موضوع، IBM با مدل Granite 3.1 یک مثال زده. پرامپت این بود:
«یک داستان بنویس درباره دانشمند داده‌ای که عاشق پایتون است.»

🔅 وقتی دما روی مقدار خیلی پایین (۰.۱) تنظیم شد، خروجی کاملاً امن و قابل پیش‌بینی بود؛ متن خشک بود و جزئیات زیادی نداشت.
وقتی دما روی متوسط (۰.۷۵) قرار گرفت، داستان زنده‌تر شد؛ توصیف‌ها بیشتر شدن و کمی خلاقیت به متن اضافه شد.

📈اما وقتی دما روی بالا (۱.۲۵) رفت، متن پر از ایده‌های غیرمنتظره شد؛ داستان تخیلی‌تر بود و گاهی از موضوع اصلی منحرف می‌شد.


Comparing Outputs with IBM Granite



To make this clearer, IBM tested its Granite 3.1 model with a simple prompt:
“Write a story about a data scientist who loves Python.”

At a very low temperature (0.1), the output was extremely safe and predictable. The story was dry, with little detail.
At a medium temperature (0.75), the story became richer. There were more vivid descriptions and a touch of creativity.
At a high temperature (1.25), the text was full of unexpected ideas. It felt more imaginative, but sometimes drifted away from the main topic


🦴 @scopeofai | #concepts
👌1
کی از چه دمایی استفاده کنیم

💡کار دقیق و فکت‌محور (گزارش، خلاصه، متن رسمی): دمای پایین (0.1–0.4)

📝کار خلاقانه (شعر، داستان، ایده‌پردازی): دمای بالا (0.7–1.2)

همیشه در کنارش از حداکثر طول، Stop sequence و Penaltyها استفاده کن تا متن عجیب‌غریب نشه

بهترین نتیجه معمولاً از آزمایش و تعادل بین این عوامل به‌دست میاد

When to Use What

To wrap up, here are guidelines for what temperature + settings you might choose depending on your purpose:

For factual, precise work (e.g. reports, summaries, technical writing): use low temperature (0.1-0.4), minimal top_k or top_p, lower randomness.

For creative work (stories, brainstorming, poetry): use higher temperature (0.7-1.2+), allow more sampling, allow higher top_k / top_p.

Always combine with stop sequences, max length, and penalties to avoid repetition or straying.

Experiment: sometimes a moderate temperature + restrictions gives a sweet balance.


🦴 @scopeofai | #concepts
👌1