Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 22 of 39
❮Prev Next❯

Prompt Engineering, Parameters and Self-Critique

Module 2: GenAI & Agents ⏱ 12 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Tune generation in two places. Prompts set role, rules, format and examples, and a few-shot example often fixes format faster than more rules. Parameters shape the sampling: a low temperature gives steady, factual wording, a high one gives variety, and max output tokens caps length, so a reply cut off with an incomplete status needs a higher cap. A self-critique loop drafts, checks against a checklist and revises once. Reasoning models use reasoning effort instead of temperature.

    Simulate it » No Azure account needed

    Exam objective: 2.3.1 Tune generation behavior, such as prompt engineering and adjusting model parameters. 2.3.2 Implement model reflection, chain-of-thought evaluations and self-critique loops. (Skills measured as of April 16, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Tune instructions and generation parameters Change the instructions and parameters in the playground.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Start with clear <strong>instructions</strong>: who the model is, the audience, the rules and the length.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Start with clear instructions: who the model is, the audience, the rules and the length.
    2. For facts and extraction use a low temperature. Raise it for brainstorming. Max output tokens limits the reply, and too low a value cuts it off.
    3. One worked example often fixes format and tone faster than more rules.
    4. Compare outputs side by side, then lock in the winner with an evaluation. A reasoning model such as o4-mini ignores temperature and uses reasoning effort instead.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    Product descriptions are wildly different each time, and some stop mid-sentence.

    😊 THE SOLUTION

    Tighten the instructions, add an example and set sensible parameters.

    • Too creative or too flat✓ Temperature or top P
    • Cut-off replies✓ Raise max output tokens and check the status
    • Wrong facts in the draft✓ A self-critique pass with a checklist
    🛠️ Solved with: Prompt engineering and model parameters

    Start with a question

    Why do two cooks make different dishes from the same recipe?

    One recipe says “season to taste”. One cook adds a pinch, another adds a fistful. One follows the recipe card exactly, another improvises. If you want the same dish every time, you write clearer steps, show a photo of the finished plate and tell them how much to use.

    A model is the cook. Instructions are the recipe. A worked example is the photo. Temperature is how much the cook improvises. Max output tokens is the size of the plate.

    Explain it like I’m 10

    The technical explanation

    1. Prompt: say it clearly

    A good instruction names the role, the audience, the rules, the format and the length.

    You are Contoso's product copywriter. Write a product description for an Indian online shop.
    Use plain English, mention the warranty, and stay under 60 words.
    
    Example
    Input: steel water bottle
    Output: Keeps chai hot for 12 hours. Leak-proof lid, 1-year warranty.

    Put separate parts in clear sections, give the answer format, and add one or two examples when the format matters. That’s few-shot prompting.

    2. Parameters: shape the sampling

    SettingEffectUse
    TemperatureLow is steady, high is varied0 to 0.3 for facts and extraction, higher for ideas
    Top PLimits to the most likely wordsChange it or temperature, not both
    Max output tokensCaps reply lengthToo low cuts the answer. Check the status
    r = openai.responses.create(model="support-chat", instructions=instructions, input=product,
                                temperature=0.2, top_p=1, max_output_tokens=300)
    print(r.output_text, r.status, r.incomplete_details)   # status "incomplete" means a cap was hit

    Reasoning models such as o4-mini don’t take temperature. You steer them with reasoning effort (low, medium or high), and a higher effort costs more tokens and time.

    3. Reflection and self-critique

    Let the model check its work. Draft, then critique against a checklist, then revise once:

    draft = openai.responses.create(model=m, instructions=instructions, input=product).output_text
    critique = openai.responses.create(model=m, input=f"Check this against the rules and list problems: {draft}").output_text
    final = openai.responses.create(model=m, input=f"Rewrite fixing: {critique}\n{draft}").output_text

    Keep the checklist short and the loop to one or two rounds. It costs extra calls, so measure whether it raises evaluation scores. For reasoning, a chain-of-thought style prompt (“work through the steps, then answer”) can help standard models on multistep problems. Reasoning models think by themselves, so you don’t need to ask. You can evaluate the reasoning by scoring intermediate steps against a rubric, or by comparing several attempts and keeping the consistent answer.

    Architect level Change one thing at a time

    If you change the prompt, the temperature and the model together, you won’t know which helped. Change one setting, run your evaluation set, and keep the change only if scores improve. Prompts are code: store them in Git, version them, and compare versions on the same data.

    Real-world business scenario

    Consumer goods

    Fabrikam Appliances (fictional)

    The problem
    Product descriptions changed tone every time, some got the warranty wrong, and a few stopped mid-sentence.
    What they used
    Instructions with role, audience, a 60-word limit and one worked example, temperature 0.2, max output tokens 300 with a check of the response status, and a self-critique pass against a three-line checklist.
    Why that choice
    The example fixed the format, the low temperature steadied the wording, the higher cap stopped cut-offs, and the critique caught the wrong warranty.
    The result
    Descriptions came out consistent, and the evaluation score for rule-following rose by a clear margin.

    When to use it and when not to

    ✓ Use it when…

    • Output format, tone or length is inconsistent.
    • You need steadier answers for facts or extraction.
    • A draft benefits from a check against rules before it is used.

    ✕ Think twice when…

    • Using the prompt to enforce exact business rules. Use code.
    • Raising temperature for factual answers.
    • Endless critique loops that cost more than they help.

    ↔ Alternatives to consider

    • RAG when the problem is missing knowledge, not wording.
    • Structured outputs when code must parse the reply.
    • Fine-tuning only when prompts can't hold a style at high volume.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A contract-summary tool must produce consistent, factual output.

    Which temperature setting is most appropriate?

    Question 2

    Question 2 of 5

    A reply ends mid-sentence and the response status is incomplete.

    What should you increase?

    Question 3

    Question 3 of 5

    A product description must always follow a specific format and tone. Instructions alone give inconsistent results.

    Which technique should you add?

    Question 4

    Question 4 of 5

    A team wants a draft checked against a checklist and revised once before it is returned.

    Which technique does this describe?

    Question 5

    Question 5 of 5

    A call to a reasoning model with a temperature parameter is rejected.

    What should you use to influence its behaviour instead?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner What does temperature do?

    Model answer

    It controls how adventurous the wording is. Near 0 the model picks the most likely words and the answer is steady. Higher, the answers vary more, which is nice for ideas and risky for facts.

    Intermediate A reply stops mid-sentence. What do you check?

    Model answer

    The response status. If it says incomplete because of max output tokens, the cap was too low. I raise it, or I ask for a shorter answer in the instructions.

    Experienced developer How do you design a self-critique loop?

    Model answer

    I draft with the normal prompt, then ask the model to check the draft against a short checklist and list problems, then revise once with those problems. I limit it to one or two rounds, and I evaluate whether it really improves the score, because it costs extra calls.

    Scenario Product descriptions vary wildly and sometimes get the warranty wrong. What do you change?

    Model answer

    I lower the temperature, add a worked example in the instructions that shows the format and the warranty line, state the length, and add a verification step that compares the warranty with the product data.

    Quick revision

    Key points

    • Instructions set role, audience, rules and length.
    • A few-shot example fixes format and tone quickly.
    • Low temperature for facts; higher for ideas.
    • Incomplete status points to the output token cap.
    • Reasoning models take reasoning effort, not temperature.

    Important terminology

    Temperature
    A sampling setting. Lower values give steadier wording, higher values give more varied wording.
    Top P
    A sampling setting that limits choices to the most likely words. Change it or temperature, not both.
    Max output tokens
    A cap on how many tokens the model may generate. Too low cuts the reply short.
    Few-shot prompting
    Putting one or more worked examples in the prompt so the model copies the format and tone.
    Self-critique
    A loop where the model checks its own draft against criteria and revises it.
    Reasoning effort
    A setting on reasoning models that controls how much the model thinks before answering.

    Common mistakes

    • Changing temperature and top_p together.
    • Setting max output tokens so low that replies are cut.
    • Running endless self-critique loops.

    Exam tips

    • "Consistent, factual output" = low temperature.
    • "Reply cut off, status incomplete" = raise max output tokens.
    • "Reasoning model rejects temperature" = use reasoning effort.

    Five quick revision questions

    1. 1.What does a low temperature give?Show

      Steady, repeatable wording.

    2. 2.What fixes a cut-off reply?Show

      A higher max output tokens value.

    3. 3.What does a few-shot example do?Show

      It shows the format and tone.

    4. 4.What is a self-critique loop?Show

      Draft, check against criteria, revise.

    5. 5.What replaces temperature on reasoning models?Show

      Reasoning effort.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Tracing, Token Analytics and Latency

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.