Reliability, Safety and Best Practices in Prompting

Reliability, Safety and Best Practices in Prompting

GenAI-Powered .NET Β· double-click any text to add a note Β· hover dotted terms for definitions
Tutorial 6 of 27 Beginner to Intermediate C#

1 Overview

Everything you have learned so far makes model output better. This tutorial is about the other half of the job: what to do because output can still be wrong. Language models are probabilistic text generators with a gift for sounding right — and building reliably on such a component requires habits that no amount of clever prompting replaces.

You will learn the beginner mistakes that account for most AI misuse, the techniques that measurably reduce incorrect output, how to use self-verification and explicit assumptions as cheap safety nets, what data may and may not enter a prompt, and — the judgment skill that ties it together — recognizing the situations where AI output should not be trusted at all without independent verification.

The theme is defense in depth: no single technique makes model output safe, but grounding plus constraints plus verification plus validation plus human review, layered, makes failures rare, visible, and recoverable. That layered mindset is what separates teams that ship AI features from teams that ship AI incidents.

This is tutorial 6 of 27 and completes the core prompting module. It draws on hallucination and validation concepts from tutorials 1–2 and the review discipline of tutorials 3–5.

2 Learning Objectives

After completing this tutorial, you will be able to:

  • Recognize and avoid the common beginner mistakes in prompt engineering.
  • Apply the techniques that reduce incorrect output: grounding, honesty rules, constraints, examples, and low temperature for factual tasks.
  • Use self-verification prompts effectively — and know exactly what they cannot catch.
  • Make the model surface its assumptions explicitly, turning silent gap-filling into reviewable statements.
  • Apply data-privacy discipline: what never enters a prompt, what gets redacted, and how enterprise platforms change the calculus.
  • Identify the situations where AI output must not be trusted without independent verification.
  • Layer these techniques into defense in depth for any AI-assisted workflow.

3 Prerequisites

  • Tutorials 1–2: hallucination, non-determinism, tokens, prompt anatomy, and output validation basics.
  • Tutorials 3–5 helpful but not required: the patterns and review habits deepen everything here.
  • No code prerequisites beyond basic C# reading; the examples are small and self-contained.

4 Why Reliability Is a Discipline, Not a Feature

A language model optimizes for plausible continuation, not truth. Most of the time plausible and true coincide — that is why the technology is useful. When they diverge, you get a hallucination delivered in the same fluent, assured tone as every correct answer. This is the fact that shapes everything in this tutorial: confidence is a writing style, not a reliability signal. Wrong answers do not sound wrong.

Three boundaries define where wrongness concentrates. The knowledge cutoff: anything after training data ends is invisible — the model will discuss it anyway if asked. The knowledge boundary: your codebase, your data, your organization are unknown unless supplied in the prompt. And non-determinism: the same question can get different answers on different runs, so a correct answer once is not a correct answer always.

Because no single defense is complete, reliability engineering for prompts is defense in depth: reduce errors at the source (better prompts, grounding), catch them in flight (self-verification, explicit assumptions), block them at the exit (output validation in code), and keep a human in the loop where consequences warrant it. Each layer is leaky; the stack is strong.

5 Common Beginner Mistakes in Prompt Engineering

Most AI trouble is not exotic — it is a handful of habits that every beginner exhibits and every practitioner has to unlearn:

Mistake What it looks like The fix
Trusting the first answer Copy, paste, ship — it sounded right Ask → Review → Improve against written acceptance criteria; the first draft is a draft
Vague prompts 'Fix this', 'make it better', 'summarize' Full anatomy: instruction, context, input data, constraints
Treating confidence as correctness 'It sounded so sure' as a review standard Verify claims; confident tone is free, facts are not
Asking beyond the knowledge boundary Current events, your private systems, post-cutoff APIs Supply the context or don't ask
One giant prompt Whole feature, whole file, every question at once Decompose; small prompts with verified boundaries
Ignoring non-determinism Testing once, assuming stability Run variable tasks multiple times; validate outputs in code
Pasting secrets and personal data Connection strings, customer records in prompts Privacy discipline — section 8
Arguing instead of re-prompting Long corrective back-and-forth in one thread Fix the prompt and restart; context pollution compounds

The last row deserves a note: when a conversation goes wrong, the wrong turns stay in the conversation history and keep conditioning later answers. Beginners argue with the model; practitioners take what they learned, improve the prompt, and start a clean session. Ten minutes of arguing loses to thirty seconds of re-prompting almost every time.

6 Techniques to Reduce Incorrect Output

Error reduction starts at the source — the prompt — with five techniques that compound:

  • Grounding: supply the authoritative material (docs, code, data) and instruct 'use only the information provided'. The single biggest hallucination reducer — the model answers from your facts instead of its statistical memory.
  • Honesty rule: explicitly permit uncertainty — 'if the information is not present, answer unknown; do not guess'. Without permission to say 'I don't know', the model fills gaps with plausible inventions.
  • Tight output constraints: restrict answers to checkable shapes and allowed values. A response forced into { "severity": "low|medium|high" } cannot hallucinate a severity of 'catastrophic-ish'.
  • Few-shot prompting for format-sensitive tasks: worked examples pin the pattern and reduce format drift across runs.
  • Low temperature for factual and extraction work: sampling randomness is a feature for brainstorming and a defect for facts — turn it down where correctness matters.
🎬 Defense in depth: where each layer catches errors
Follow a request through the layers — each one leaky, the stack strong.
Better prompt grounding + rules
➜
Generation still fallible
➜
Self-verify model re-checks
➜
Code validation schema, values
➜
Human review where it matters
Order matters economically: prompt-level fixes cost nothing per request, self-verification costs one extra call, validation costs code once, human review costs attention forever. Push as much reliability as possible into the cheap early layers.

7 Self-Verification and Explicit Assumptions

Self-verification is asking the model to check its own answer before you do: 'Review your answer above. Verify each claim against the provided context, re-check any calculations, and confirm every requirement in my request was addressed. List anything questionable.' It works because verification is a different task than generation — reading a draft against criteria has a different error profile than producing the draft — so the model catches real mistakes: dropped requirements, internal contradictions, arithmetic slips, constraint violations.

🎬 The self-verification loop
One extra turn, surprisingly many catches — but note where it goes blind.
First answer fluent draft
➜
Verify prompt explicit criteria
➜
Issues found mechanical slips
➜
Revised answer corrected
➜
Your review still required

The technique's hard limit: the verifier shares the generator's blind spots. If the model believes a wrong fact, it verifies the wrong fact as true. Self-verification is a pre-filter that raises average quality — it is never evidence of correctness. Treat 'I have verified my answer' with exactly the same skepticism as the original answer.

Explicit assumptions attack a quieter failure: for every detail your prompt leaves open, the model decides silently — and its silent choices look identical to your requirements in the output. The fix is one line: 'Before answering, list every assumption you are making about anything I did not specify.' Now the gap-filling is visible: 'Assuming amounts are decimal; assuming UTC timestamps; assuming duplicates should be removed.' Each assumption is a decision you get to confirm or correct before it hardens into code — and a wrong assumption caught at this stage costs one sentence to fix.

Power combo for consequential asks: 'List your assumptions first. Then answer. Then verify your answer against the requirements and your stated assumptions.' Three safety nets, one prompt.

8 Data-Privacy Considerations When Prompting

Every prompt is data leaving your control toward someone's servers. Data privacy in prompting reduces to three questions: what is this data, where is it going, and what happens to it there — with different answers for a consumer chat tool, GitHub Copilot under a business plan, and an Azure OpenAI deployment inside your own subscription.

Data class Examples Rule of thumb
Secrets API keys, connection strings, passwords, certificates Never in a prompt. No exceptions. A pasted secret is a rotated secret.
Personal data (PII) Names, emails, addresses, national IDs, health/financial records Minimize or redact; real records only where the platform and your policies explicitly allow
Proprietary code & docs Source code, internal designs, contracts Follow organizational policy; enterprise platforms with no-training guarantees change the answer
Public/synthetic data Open-source code, made-up examples, anonymized structures Safe — and usually all the model actually needs

Two working practices carry most of the weight. Redaction: replace sensitive values with placeholders before prompting — 'CUSTOMER_1 (email EMAIL_1) reported...' — and map them back afterward; the model reasons about structure identically well. Synthetic substitution: for debugging and code questions, invented data with the same shape works perfectly — the model needs your schema, not your customers. Platform choice does the rest: Azure OpenAI processes prompts inside your Azure tenant boundary and does not use them to train foundation models, which is precisely why enterprises route AI workloads through it rather than consumer tools.

Prompt injection is the privacy risk in reverse: when your application pastes untrusted content (user messages, web pages, documents) into prompts, that content may contain instructions the model follows — including 'reveal your system prompt' or 'ignore your rules'. Delimit untrusted data clearly, never grant prompts more capability than the task needs, and treat this as a standing threat — tutorial 24 covers defenses in depth.

9 Platform Safety Nets in the Microsoft Ecosystem

  • Azure OpenAI data handling: prompts and completions stay within your Azure boundary, are not used to train foundation models, and inherit your tenant's compliance posture — the platform-level answer to most proprietary-data questions.
  • Azure AI Content Safety and built-in content filtering: classify and block harmful content in prompts and responses — a platform layer beneath your application's own validation.
  • Microsoft Entra ID + private endpoints: who can call your deployments, over which network paths — reliability includes controlling who can prompt at all.
  • GitHub Copilot business/enterprise controls: policy settings for code-suggestion privacy and telemetry — the organizational answer for editor-side prompting.
  • Your own layer: output validation code, redaction helpers, prompt templates with honesty rules baked in — the application-level defenses this tutorial teaches, which no platform supplies for you.

The division of labor is clean: the platform secures where data goes and filters egregious content; your prompts and code secure whether outputs are correct and what data enters. Teams get into trouble when they assume the platform layer covers the application layer — no Azure setting can make a hallucinated discount rate false.

10 When NOT to Trust AI Outputs

The judgment skill that caps this module: recognizing the task types where model output must be independently verified before use — or not solicited at all. The pattern behind the list: trust falls as consequences rise and as verifiability drops.

Situation Why trust fails Required discipline
Facts after the knowledge cutoff The model cannot know them; it answers anyway Current sources; treat any post-cutoff claim as invention
Citations, references, quotes Plausible-looking sources are routinely invented Verify every citation exists and says what's claimed
Exact numbers: prices, limits, versions, dosages Statistical recall of specifics is unreliable Authoritative source, always
Legal, medical, financial advice High consequence + jurisdiction/context specificity Qualified professional; model output as background at most
Security-critical code and configs Subtle wrongness with severe blast radius Expert review + testing; never paste-and-deploy
Anything about YOUR systems not in the prompt Knowledge boundary — it's guessing from patterns Supply the context or distrust the answer
Claims the model 'verified' itself Verifier shares generator's blind spots Independent verification for anything consequential
Output feeding irreversible actions Errors can't be caught after the fact Human-in-the-loop approval before the action fires

Notice what is NOT on the list: drafting, summarizing reviewed by a reader, brainstorming, code that faces tests and review, explanations you can check against source. That is the calibration — AI output is a first-rate input to verification processes and a poor terminal authority. Position it accordingly and almost every use is safe; position it as an oracle and every use is a gamble.

11 Code Examples in C#

A prompt-builder that bakes the reliability rules — grounding, honesty rule, constraints — into every factual query:

Reliability-hardened prompt template
public static class ReliablePrompts
{
    // v2: added assumptions + verification clauses (2026-09).
    public static string BuildGroundedQuery(string question, string context) => $"""
        Answer the question using ONLY the reference material below.
        Rules:
        - If the material does not contain the answer, reply exactly: UNKNOWN.
        - Do not use outside knowledge. Do not guess.
        - Before answering, list any assumptions you are making.
        - After answering, verify: does every claim trace to the material?

        Question: {question}

        Reference material:
        \"\"\"
        {context}
        \"\"\"
        """;
}

A minimal redaction helper — placeholders out, real values back in after the response:

PII redaction before prompting (illustrative patterns)
using System.Text.RegularExpressions;

public sealed class PromptRedactor
{
    private readonly Dictionary<string, string> _map = new();
    private int _counter;

    public string Redact(string text)
    {
        // Illustrative: real systems use vetted PII-detection libraries/services.
        text = Regex.Replace(text, @"[\w.+-]+@[\w-]+\.[\w.]+", m => Placeholder("EMAIL", m.Value));
        text = Regex.Replace(text, @"\b\d{3}[- ]?\d{3}[- ]?\d{4}\b", m => Placeholder("PHONE", m.Value));
        return text;
    }

    public string Restore(string text)
    {
        foreach (var (placeholder, original) in _map)
            text = text.Replace(placeholder, original);
        return text;
    }

    private string Placeholder(string kind, string original)
    {
        var token = $"{kind}_{++_counter}";
        _map[token] = original;
        return token;
    }
}

And the exit layer — validation that turns bad output into a handled failure path instead of a production bug (the pattern from tutorial 2, now with an explicit UNKNOWN branch):

Validation with an honest-uncertainty branch
public enum AnswerStatus { Answered, Unknown, Invalid }

public static (AnswerStatus Status, string? Answer) ValidateGroundedAnswer(string raw)
{
    var trimmed = raw.Trim();

    if (trimmed.Equals("UNKNOWN", StringComparison.OrdinalIgnoreCase))
        return (AnswerStatus.Unknown, null);   // honest gap — route to human/fallback

    if (string.IsNullOrWhiteSpace(trimmed) || trimmed.Length > 2000)
        return (AnswerStatus.Invalid, null);   // malformed — retry or fail loudly

    return (AnswerStatus.Answered, trimmed);   // still subject to any schema checks
}

12 Step-by-Step: Hardening a Prompt from Naive to Production

Take one realistic feature — answering customer questions from your product documentation — and walk it through every layer of this tutorial.

  1. Naive baseline: 'Answer this customer question: {question}'. Test it with a question your docs don't cover — watch it confidently invent product behavior. This is the failure you are engineering away.
  2. Add grounding: paste the relevant documentation section and require 'using ONLY the reference material'. Re-test the uncovered question — better, but it may still stretch.
  3. Add the honesty rule: 'If the material does not contain the answer, reply exactly UNKNOWN.' Re-test — the uncovered question now returns UNKNOWN. Verify the covered questions still answer correctly.
  4. Add explicit assumptions: 'List any assumptions before answering.' Test with an ambiguous question ('does it work offline?' — which product tier?) and watch the ambiguity surface instead of being silently resolved.
  5. Add self-verification: 'After answering, confirm every claim traces to the material.' Spot-check: it catches a stretched claim in one of your test answers.
  6. Privacy pass: questions may contain customer PII — wire the redactor from section 11 before the prompt, restore after. Confirm placeholders survive the round trip.
  7. Exit validation: handle the UNKNOWN branch (route to support), length-check, and log every UNKNOWN — those are your documentation gaps, gift-wrapped.
  8. Set temperature low, run your test set of 10 questions (covered, uncovered, ambiguous, PII-bearing) three times each, and record results. This regression set is now the feature's safety harness for every future prompt or model change.
Total added engineering: perhaps an hour. The naive version and the hardened version cost the same per API call — reliability here is mostly thinking, not spending.

13 Limitations and Caveats

  • Every technique here reduces error rates; none reaches zero. Grounded models still occasionally stretch beyond the material; honesty rules are followed probabilistically, not contractually.
  • Self-verification shares the generator's blind spots: it catches mechanical slips, never wrong beliefs. 'Verified' output is unverified output with better grooming.
  • Assumption listing depends on the model recognizing its assumptions — the deepest ones (interpretations so natural the model doesn't see them as choices) stay silent.
  • Redaction by regex is illustrative: production PII detection needs vetted libraries or services, and redaction can subtly change what the model infers (a placeholder carries less context than a real value).
  • Platform guarantees have scopes — read them: 'not used to train foundation models' is not the same as 'never logged', and content filters block categories of harm, not factual errors.
  • The when-not-to-trust list is a floor, not a ceiling: your domain adds its own entries (regulated industries especially).
  • All settings and platform behaviors described (temperature, content filtering, data handling) evolve — verify against current documentation when you build.
API-accuracy disclosure: the C# in section 11 is standard, version-safe C# (raw string literals require C# 11+; the regex patterns are deliberately simplistic illustrations, not production PII detection). Azure OpenAI data-handling and content-filtering descriptions reflect the platform's documented design; confirm specifics against current Microsoft documentation before relying on them in compliance contexts.

14 Best Practices and Common Mistakes

The reliability habit set, condensed:

  • Ground factual tasks in supplied material with 'use only' + an honesty rule permitting UNKNOWN.
  • Constrain outputs to checkable shapes; validate them in code; design the failure path before shipping.
  • Ask for assumptions on anything ambiguous; ask for self-verification on anything consequential — and still review.
  • Low temperature for facts and extraction; multiple runs before trusting stability; a regression set per prompt.
  • Secrets never enter prompts; PII gets redacted or synthesized; proprietary data follows platform + policy.
  • Route enterprise workloads through platforms with contractual data handling (Azure OpenAI) rather than consumer tools.
  • Keep humans in the loop wherever actions are irreversible or consequences are high.

The mistakes that undo it all:

  • Equating confident tone with correctness — the original sin of AI adoption.
  • Accepting 'I have verified my answer' as verification.
  • Letting the model resolve ambiguity silently instead of demanding its assumptions.
  • Trusting citations, numbers, and post-cutoff claims without checking.
  • Pasting a connection string 'just this once'.
  • Treating platform compliance as application correctness.
  • Skipping the UNKNOWN branch — forcing the model to answer is forcing it to hallucinate.
  • Arguing with a polluted conversation instead of restarting with a better prompt.

20 Summary & Key Takeaways

  • Confidence is a writing style: hallucinations sound exactly like facts, so review checks claims, never tone.
  • The beginner mistakes are few and fixable: trusting draft one, vague prompts, boundary-crossing questions, single tests, polluted conversations, pasted secrets.
  • Reduce errors at the source: grounding + honesty rule + constraints + examples + low temperature — free per call, prevents the majority.
  • Catch errors in flight: explicit assumptions make silent choices reviewable; self-verification catches mechanical slips — and shares the generator's blind spots.
  • Privacy is classification plus technique: secrets never; PII redacted or synthesized; proprietary data per platform contract and policy; Azure OpenAI answers the enterprise where-does-data-go question.
  • Know when not to trust: post-cutoff facts, citations, exact numbers, high-consequence advice, security-critical code, your undescribed systems, self-verified claims, irreversible actions.
  • Defense in depth is the strategy: every layer leaks, the stack holds — and the cheap early layers should do the heavy lifting.
  • Instrument everything: UNKNOWN rates, validation failures, edit rates, and a regression set gate every prompt and model change.

This completes the core prompting module: you can now craft prompts, apply patterns, generate code, tests, and docs — and wrap all of it in the reliability discipline that makes it shippable. The next tutorial turns the lens on yourself: prompting as a learning and productivity multiplier for your own growth as a developer.

21 Next Steps

Continue with the next tutorial in the path: Prompt Engineering for Learning & Productivity — using models to learn technologies faster, build personal workflows, and multiply your day-to-day output as a developer.

  • Practice: run section 12's hardening walkthrough on any Q&A-style prompt you use — measure the before/after on a question the source material doesn't cover.
  • Practice: add 'list your assumptions first' to your next three ambiguous prompts and count how many surfaced assumptions you needed to correct.
  • Practice: build the PromptRedactor from section 11 into a small console tool and run it over a sample support ticket.
  • Audit: search your recent AI conversations for the beginner mistakes table — most practitioners find at least two.
  • Reading: Microsoft Learn on Azure OpenAI data privacy and content filtering; your organization's AI usage policy (read it before you need it).
Path position: tutorial 6 of 27 · Previous: prompting-for-testing-and-docs · Next: prompting-for-learning-productivity

15 Quiz

Pick an answer for each question, then press Check answer. (Notes are disabled in this tab.)

1. Why is a model's confident tone not a reliability signal?

βœ… Correct!
❌ Not quite β€” the correct answer is .
The model optimizes plausible continuation, and plausible text sounds assured. Hallucinations arrive in exactly the same register as facts — which is why review checks claims, never vibes.

2. Which mistake does 'Ask → Review → Improve' most directly correct?

βœ… Correct!
❌ Not quite β€” the correct answer is .
The most common beginner failure is treating draft one as final. The quality loop institutionalizes the review step that turns probabilistic output into dependable output.

3. What is the single most effective technique for reducing hallucinations on factual tasks?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Grounding replaces statistical recall with reading comprehension — the model answers from your supplied facts. Paired with an honesty rule, it converts most inventions into honest UNKNOWNs.

4. What does an honesty rule like 'answer UNKNOWN if not in the material' actually prevent?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Models complete text; a question demands an answer-shaped completion. Explicitly permitting uncertainty makes 'UNKNOWN' an acceptable completion — and your validation code can route it to a fallback instead of shipping a guess.

5. When should temperature be set low?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Sampling randomness adds variety — a defect where correctness and consistency matter. Facts, extraction, classification: low. Ideation: higher. Temperature doesn't cause or cure hallucination; it trades consistency for variety.

6. What does self-verification reliably catch?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Checking is a different task than generating, so re-reading against criteria catches real mistakes. But the verifier shares the generator's blind spots — a wrong belief verifies as true. Pre-filter, never proof.

7. Why does 'I have verified my answer' deserve the same skepticism as the answer itself?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Self-verification raises average quality but is not evidence of correctness. For consequential output, verification must be independent: your review, tests, authoritative sources.

8. What does 'list your assumptions before answering' accomplish?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Every ambiguity in your prompt gets resolved somehow; by default, silently and invisibly. Surfaced assumptions ('assuming UTC', 'assuming duplicates removed') cost one sentence to correct — before they harden into wrong output.

9. Which item must NEVER appear in a prompt, on any platform?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Secrets in prompts leave your control and enter logs and histories you don't govern. The operational rule is absolute: a pasted secret is a compromised secret — rotate it. PII and proprietary code have policy-dependent answers; secrets don't.

10. What is redaction in the prompting context?

βœ… Correct!
❌ Not quite β€” the correct answer is .
'CUSTOMER_1 (EMAIL_1) reported...' preserves the structure the model needs while the real values never leave. Synthetic substitution is the sibling technique: invented data with the real shape.

11. Which Azure OpenAI property answers most enterprise proprietary-data concerns?

βœ… Correct!
❌ Not quite β€” the correct answer is .
The data-handling contract — tenant boundary, no foundation-model training on your prompts, your compliance posture — is why enterprises route AI workloads through Azure OpenAI instead of consumer tools. Note what it doesn't do: make outputs correct.

12. A model provides a perfectly formatted citation for a claim. What do you know?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Citations are exactly the kind of specific, structured text models generate fluently from patterns. Real-looking is the default; real requires checking. Citations, quotes, exact numbers, and versions all share this rule.

13. Which situation most demands a human-in-the-loop before the output acts?

βœ… Correct!
❌ Not quite β€” the correct answer is .
Trust calibrates to consequence and reversibility. Reviewed drafts fail safely; irreversible actions amplify any error. The approval gate belongs exactly where mistakes can't be recalled.

14. Why is asking about your own systems (not described in the prompt) untrustworthy?

βœ… Correct!
❌ Not quite β€” the correct answer is .
The model will answer fluently about 'your' architecture — pattern-matched from every system it has read about. Without your context in the prompt, that's polished guesswork. Supply the context or discount the answer.

15. What is the core claim of defense in depth for prompting?

βœ… Correct!
❌ Not quite β€” the correct answer is .
No single defense reaches zero errors. Cheap early layers (grounding, honesty rules) prevent most; verification catches some; validation converts the rest to handled failures; humans gate what matters. Reliability is the stack.

16 Exam Questions

Try answering each question yourself before expanding the model answer.

1. Explain why 'confidence is a writing style, not a reliability signal' and derive its practical consequences for review.
Models optimize plausible continuation; assured, fluent prose is the register of most training text, so it is applied uniformly to correct and incorrect content. There is no internal fact-checker modulating tone. Consequences: review must check claims against sources, never assess tone; 'it sounded right' is disqualified as a review standard; specific, checkable elements (numbers, citations, API names) get verified first since fluent specificity is exactly what generation fakes best; and teams train members explicitly that hallucinations arrive confident — the expectation itself is a defense.
2. Catalog five common beginner mistakes in prompt engineering, and for each give the practitioner correction.
(1) Trusting the first answer → Ask → Review → Improve with acceptance criteria; drafts are drafts. (2) Vague prompts ('fix this') → full anatomy: instruction, context, input data, output constraints. (3) Asking beyond the knowledge boundary (current events, private systems) → supply context or don't ask; treat boundary-crossing answers as guesses. (4) Ignoring non-determinism (testing once) → multiple runs, regression sets, validation in code. (5) Arguing with a polluted conversation → take the lesson, improve the prompt, restart clean; history conditions future answers, so wrong turns compound. (Also worthy: giant undecomposed prompts; secrets/PII pasted; confidence equated with correctness.)
3. Present the five prompt-level techniques for reducing incorrect output and explain the mechanism of each.
(1) Grounding — supply authoritative material + 'use only the information provided': replaces statistical recall with reading comprehension over your facts. (2) Honesty rule — 'if not present, answer UNKNOWN': makes uncertainty an acceptable completion, removing the pressure to fill gaps with plausible inventions. (3) Tight output constraints — allowed values and shapes: shrinks the space where errors can live and makes violations machine-detectable. (4) Few-shot examples — demonstrated patterns pin format and boundary judgments, reducing drift across runs. (5) Low temperature for factual work — reduces sampling randomness, trading unneeded variety for consistency. They compound: each closes a different door.
4. Describe self-verification: why it works, what it catches, its hard limit, and its correct position in a workflow.
Mechanism: verification is a different task than generation — re-reading a draft against explicit criteria (claims vs context, calculations, requirements coverage) has a different error profile than producing it, so real defects surface: dropped requirements, internal contradictions, arithmetic slips, constraint violations. Hard limit: the verifier is the same model with the same blind spots — a wrongly believed fact verifies as true, so 'I have verified' is grooming, not evidence. Position: a cheap pre-filter after generation and before human review; it raises average quality for one extra turn but never substitutes for independent verification on consequential output. Best combined: assumptions first, answer, then self-verify — three nets in one prompt.
5. Explain the silent-assumption problem and how explicit assumption elicitation changes the economics of ambiguity.
Every detail a prompt leaves open gets resolved by the model somewhere — currency, timezone, duplicate handling, tier of product — and by default the resolution is silent and invisible: the output reads identically whether the choice matched your intent or not. Elicitation ('list every assumption you are making about anything I did not specify') converts each silent choice into a reviewable statement. Economics: a wrong assumption caught at the list stage costs one corrective sentence; embedded in generated code it costs debugging something that looks right; in production it costs an incident. The technique also feeds back into requirements: recurring assumptions mark chronic ambiguities your specs should close. Limit: the deepest interpretations may not register as assumptions to the model — elicitation reduces, not eliminates.
6. Construct the data-classification rules for prompting: four data classes, their rules, and the two working techniques that make compliance practical.
Classes: (1) Secrets — keys, connection strings, passwords: never in prompts, no exceptions; a pasted secret is rotated. (2) PII — names, emails, IDs, health/financial data: minimize or redact; real records only where platform guarantees and organizational policy explicitly allow. (3) Proprietary code/docs: policy-dependent; enterprise platforms with contractual no-training guarantees (Azure OpenAI) typically permit what consumer tools don't. (4) Public/synthetic: safe, and usually sufficient. Techniques: redaction — placeholder substitution (EMAIL_1) with post-response restoration, preserving structure while values never leave; synthetic substitution — invented data with the real schema, because the model needs your shapes, not your customers. Together they make the default workflow compliant instead of making compliance an exception process.
7. Compare what the Azure platform layer does and does not provide for prompting reliability and safety.
Provides: data handling — prompts within your tenant boundary, not used to train foundation models, inheriting your compliance posture; content filtering / Azure AI Content Safety — classification and blocking of harmful content categories both directions; access control — Entra ID and private endpoints governing who can call deployments over which paths; auditability through Azure's operational surface. Does not provide: factual correctness — no setting makes a hallucinated discount rate false; output validation — your schemas, your code; prompt quality — grounding, honesty rules, constraints are your craft; task-level trust decisions — when a human must gate. The failure mode is assuming platform compliance covers application correctness; the two layers secure different things and both are required.
8. Give the 'when not to trust' taxonomy with the underlying principle, and state what correctly calibrated trust looks like.
Principle: trust falls as consequence rises and verifiability drops. Taxonomy: post-cutoff facts (unknowable, answered anyway); citations/quotes/exact numbers (fluent specificity is the top hallucination genre); legal/medical/financial advice (consequence + jurisdictional specificity); security-critical code/configs (subtle wrongness, severe blast radius); claims about your systems absent from the prompt (knowledge boundary guesswork); self-verified claims (shared blind spots); anything feeding irreversible actions (uncatchable after the fact). Calibrated trust: AI as first-rate input to verification processes — drafts humans review, code that faces tests, explanations checked against source — and never as terminal authority. Positioned so, nearly every use is safe; positioned as oracle, every use gambles.
9. Design the complete reliability hardening for a docs-Q&A feature (as in section 12), naming each layer and what failure it addresses.
(1) Grounding with retrieved doc sections + 'use only' — addresses invention of product behavior. (2) Honesty rule with exact-token UNKNOWN — addresses forced answers on uncovered questions; validation can branch on it. (3) Assumption elicitation — addresses silent resolution of ambiguous questions (which tier? which version?). (4) Self-verification clause — catches stretched claims and dropped question parts. (5) Redaction of customer PII in questions, restoration after — addresses privacy egress. (6) Exit validation: UNKNOWN branch routed to support, length/shape checks, logging of UNKNOWNs as documentation-gap telemetry. (7) Low temperature; regression set of covered/uncovered/ambiguous/PII questions run multiply, re-run on any prompt or model change. Each layer leaky, the stack strong; cost is mostly one hour of thinking, not per-call spend.
10. Why does forcing a model to answer (no honesty rule) directly manufacture hallucinations? Explain via the completion mechanism.
Generation continues text plausibly. A question sets up an answer-shaped continuation; if the model's context and knowledge don't contain the answer, the most plausible continuation is still an answer — so it produces one, synthesized from patterns resembling the question's domain. Refusal or 'I don't know' is a less likely continuation unless the prompt makes it explicitly acceptable and specified ('reply exactly UNKNOWN'). The honesty rule thus doesn't just permit honesty; it creates a high-probability, well-defined completion path for the no-answer case, which validation code can then detect and route. Absent that path, every gap in coverage converts to a confident invention — the feature's worst possible behavior, delivered in its most convincing tone.
11. A junior developer says 'the model verified its own answer, so we can skip review.' Correct them with the full argument.
Self-verification is one model checking work produced by the same weights, same context, same blind spots. It genuinely helps: reading-against-criteria is a different task from generating, so mechanical defects — dropped requirements, contradictions, arithmetic — get caught, and average quality rises for one cheap turn. But wrong beliefs pass their own checks by definition: if the model 'knows' a wrong API signature, verification confirms it enthusiastically. So the verified answer is an unverified answer with better grooming. Review economics remain unchanged: independent checks — human review, tests, authoritative sources — for anything consequential. Analogy that lands: a developer re-reading their own PR catches typos, not their own misunderstandings; that's why we have reviewers.
12. Explain conversation pollution and the restart discipline, including why arguing with a model is anti-productive.
Chat models are stateless; every turn replays the conversation history as context. When a session goes wrong — a misunderstanding, a wrong frame, hallucinated 'facts' introduced — those turns remain in history and condition every subsequent generation: the model keeps consistency with its own errors, and corrections fight against accumulated context weight. Arguing adds more polluted turns, often entrenching the frame. The discipline: extract the lesson (what context was missing? which constraint was unstated?), then start a clean session with an improved prompt embodying it. Thirty seconds of re-prompting beats ten minutes of correction. In application code the same principle: purpose-built calls with curated context rather than ever-growing chats; summarize-and-restart when sessions age.
13. Your team wants to paste production customer records into prompts 'because the bug only reproduces with real data.' Provide the governed path.
First interrogate the premise: bugs reproduce with data of the right shape and values, not the right identities — synthetic substitution (invented records matching the schema, including the pathological values that trigger the bug) resolves most cases outright. Where realistic distributions matter, redaction: placeholder substitution for names/emails/IDs with mapping kept locally, restoring after. If neither suffices (rare), the question becomes platform and policy: an Azure OpenAI deployment inside the tenant boundary with its no-training data handling, under an explicit policy decision by whoever owns data protection — not an engineer's judgment call in the moment. And regardless of path: secrets in the records (tokens, connection strings) never go; logs of what was sent are kept; the exception is documented. The default answer stays 'synthetic first' because it's also the faster path — no approvals needed.
14. Argue the economics of the defense-in-depth stack: why push reliability into early layers, and what does each layer cost?
Costs: prompt-level techniques (grounding, honesty rules, constraints, temperature) are free per request — engineering once, zero marginal cost. Self-verification costs one extra model call per request. Output validation costs code once plus negligible runtime. Human review costs scarce attention on every item, forever. Effectiveness is roughly inverse to cost at the margin: good prompts prevent the majority of failures; verification catches a meaningful slice of the rest; validation converts residual bad output into handled failures; humans catch what only judgment can. Therefore: maximize prevention in the free layers, reserve the expensive human layer for consequence-gated decisions, and never let human review become the compensating control for lazy prompts — that inverts the economics, burning the costliest resource on failures the cheapest layer should have prevented.
15. Scenario: an AI feature will draft responses to customer complaints, with an agent clicking send. A stakeholder asks 'how do we know it won't say something wrong or leak data?' Write the reliability case.
Structure the answer as layers. Wrongness: drafts are grounded in the customer's ticket plus our policy documents with 'use only' + UNKNOWN honesty rule, so product claims trace to sources; assumptions are surfaced for ambiguous complaints; self-verification flags unsupported claims; and the terminal control is architectural — a human agent reviews and edits every draft before send, so the failure mode is 'agent edits a bad draft', not 'customer receives one'. Data: PII in tickets is redacted before prompting and restored after; the workload runs on Azure OpenAI inside our tenant with contractual no-training data handling; secrets never enter prompts by policy and tooling. Evidence: a regression set of real (anonymized) complaint scenarios run before any prompt or model change; UNKNOWN and edit-rate metrics monitored — rising agent edits is our early-warning signal. Residual risk stated honestly: no layer is perfect; the human gate is sized exactly because of that.

17 Flashcards

Click a card to reveal the back.

Confidence ≠ correctness
Fluent assurance is a writing style applied equally to right and wrong answers. Review checks claims against sources — never tone.
Top beginner mistakes
Trusting draft one; vague prompts; confidence as correctness; asking beyond the knowledge boundary; one giant prompt; testing once; pasting secrets; arguing instead of re-prompting.
Grounding
Supply authoritative material + 'use ONLY the information provided'. The #1 hallucination reducer — recall becomes reading comprehension.
Honesty rule
'If not in the material, reply exactly UNKNOWN — do not guess.' Creates a legal completion path for uncertainty; validation can branch on it.
Temperature discipline
Low for facts, extraction, anything code-parsed. Higher only when variety is the point. Randomness is a feature for ideation, a defect for facts.
Self-verification
'Verify your answer against the context/requirements; list issues.' Catches mechanical slips (dropped requirements, contradictions, arithmetic). Cheap pre-filter.
Self-verification's hard limit
Same model, same blind spots — wrong beliefs verify as true. 'I have verified' is grooming, not evidence. Independent checks for anything consequential.
Explicit assumptions
'List every assumption about anything I didn't specify.' Silent gap-filling becomes reviewable statements — corrected for one sentence each.
Secrets rule
API keys, connection strings, passwords: NEVER in a prompt, any platform. A pasted secret is a compromised secret — rotate it.
Redaction + synthetic substitution
Placeholders (EMAIL_1) out, restore after — structure survives, values never leave. Or invent data with the real schema: the model needs shapes, not customers.
Azure OpenAI data handling
Prompts stay in your tenant boundary; not used to train foundation models; your compliance posture applies. Note: governs where data goes — not whether output is correct.
Never trust without checking
Post-cutoff facts, citations/quotes, exact numbers/versions, legal-medical-financial advice, security-critical code, claims about your undescribed systems.
Human-in-the-loop placement
Wherever output feeds irreversible actions or high consequences. Reviewed drafts fail safely; auto-fired actions amplify every error.
Conversation pollution
Wrong turns stay in history and condition later answers. Don't argue — extract the lesson, improve the prompt, restart clean.
Defense in depth
Prompt rules → self-verify → code validation → human gate. Every layer leaky; the stack makes failures rare, visible, recoverable.
Layer economics
Prompt fixes: free per call. Self-verify: one call. Validation: code once. Human review: attention forever. Push reliability into the cheap early layers.

18 Interview Questions & Answers

1. What's your mental model for when AI output can be trusted?
Trust scales inversely with consequence and directly with verifiability. Output feeding a verification process — a draft a human reviews, code that faces tests and review, an explanation I can check against source — gets used freely, because the process catches failures. Output that would act as terminal authority — exact numbers, citations, legal implications, anything triggering irreversible actions — gets independent verification or doesn't get used. And two hard boundaries where trust drops to zero without supplied context: anything after the knowledge cutoff, and anything about our systems the prompt didn't describe. The model answers both fluently; that fluency is the trap.
2. What are the most common mistakes you see people make with AI tools?
Three account for most damage. Trusting the first answer — shipping draft one because it sounded right; the fix is treating every output as a draft entering review. Equating confidence with correctness — hallucinations arrive in exactly the tone of facts, so 'it sounded sure' means nothing. And asking beyond what the model can know — current events, our internal systems — where it pattern-matches an answer from generic resemblance. Honorable mentions: vague prompts that outsource decisions invisibly, pasting secrets, and arguing with a polluted conversation instead of restarting with a better prompt.
3. How do you reduce hallucinations in practice?
Layered, starting free. Grounding first: supply the authoritative material and instruct 'use only the information provided' — recall becomes reading comprehension. Honesty rule second: 'if it's not in the material, reply exactly UNKNOWN' — without a legal path to uncertainty, the model fills gaps with inventions; with it, my validation code branches on UNKNOWN and routes to fallback. Then tight output constraints so answers live in checkable shapes, few-shot examples where format drifts, and low temperature for factual work. None reaches zero — which is why validation code and review sit behind the prompt layer. But those five prompt techniques prevent the majority of failures at zero marginal cost.
4. Is asking the model to verify its own answer worth anything?
Worth one extra call, yes — as long as you know what you bought. Verification is a different task than generation: re-reading a draft against explicit criteria catches dropped requirements, internal contradictions, arithmetic slips, constraint violations — mechanical defects, caught cheaply. What it cannot catch is wrong beliefs: the verifier is the same weights with the same blind spots, so a wrongly-known API signature verifies as correct with full confidence. My rule: self-verification raises average quality and goes in every consequential prompt — and 'the model verified it' carries zero evidentiary weight in review. Independent checks — my review, tests, sources — remain the actual verification.
5. Tell me about the assumptions technique and why you use it.
Every ambiguity in a prompt gets resolved by the model somewhere, and by default silently — the output looks identical whether its choices matched my intent or not. So on anything ambiguous I add one line: 'Before answering, list every assumption you're making about anything I didn't specify.' Suddenly the invisible becomes reviewable: 'assuming UTC, assuming decimal currency, assuming duplicates removed.' Each wrong assumption costs one sentence to correct at that stage; embedded in generated code, it costs debugging something that looks right. Bonus signal: assumptions that recur across sessions mark chronic holes in our specs — the technique doubles as requirements discovery.
6. What data are you comfortable putting in a prompt?
Classified, not vibes-based. Secrets — keys, connection strings, passwords — never, on any platform; a pasted secret is a rotated secret. PII — minimized or redacted: placeholder substitution preserves the structure the model needs while real values never leave, and for most debugging synthetic data with the right schema works perfectly, because the model needs shapes, not identities. Proprietary code and docs — policy plus platform: on Azure OpenAI inside our tenant with its no-training data handling, our policy permits what it forbids on consumer tools. Public and synthetic data — freely. The habit that makes it sustainable: synthetic-first as the default, so compliance isn't an exception process.
7. Does using Azure OpenAI mean you don't have to worry about AI risks?
It solves a specific class: data governance. Prompts stay inside our tenant boundary, aren't used to train foundation models, inherit our compliance posture, and access runs through Entra ID and private endpoints — that's why enterprise workloads route there rather than consumer tools. What it doesn't touch: correctness. No platform setting makes a hallucinated discount rate false, validates my output schemas, writes my honesty rules, or decides where humans must gate actions. Content filtering blocks categories of harm, not factual errors. The division of labor is clean — platform secures where data goes; my prompts and code secure whether outputs are right — and confusing the two layers is how teams ship compliant incorrectness.
8. When would you flatly refuse to use AI output without verification?
Citations and quotes — invented ones are indistinguishable from real ones until checked; exact numbers, prices, limits, versions — statistical recall of specifics is unreliable; anything after the knowledge cutoff — unknowable but answered anyway; legal, medical, financial conclusions — consequence plus jurisdiction-specificity; security-critical code and configuration — subtle wrongness with severe blast radius; and claims about our own systems that weren't in the prompt — that's pattern-matched guesswork wearing our vocabulary. Plus the meta-case: anything the model 'verified itself'. Note these share a shape — high consequence, or specificity the model fakes fluently. Drafts, brainstorms, and explanations I can check don't make the list; they enter verification processes by design.
9. How do you handle a conversation where the model has gone off the rails?
I stop investing in it. Chat history is replayed context — every wrong turn keeps conditioning subsequent answers, so the model maintains consistency with its own errors and corrections fight accumulated weight. Arguing adds more polluted turns. Instead: extract the lesson — what context was missing, which constraint went unstated, where did the frame go wrong — fold it into an improved prompt, and start a clean session. Thirty seconds of re-prompting reliably beats ten minutes of correction. Same principle in application code: purpose-built calls with curated context over ever-growing chats, and summarize-and-restart when sessions age past usefulness.
10. Describe defense in depth for an AI feature you'd ship.
Four layers, cheapest first. Prompt layer: grounding in retrieved authoritative content, 'use only', exact-token UNKNOWN honesty rule, output constrained to a checkable schema, assumptions surfaced, low temperature — free per call, prevents most failures. Verification layer: a self-check clause catching mechanical slips — one extra call. Validation layer: deterministic code parsing the response, branching on UNKNOWN to fallback, schema and allowed-value checks, failures routed to retry or human — code once. Human layer: review gates exactly where consequences are high or actions irreversible. Plus the harness around it all: a regression set run before any prompt or model change, and telemetry — UNKNOWN rates, validation failures, edit rates — as the early-warning system. Every layer leaks; the stack holds.
11. Your teammate pasted a connection string into a chat tool to debug faster. Walk me through your response.
Immediate: rotate the credential — the operational rule is that a pasted secret is a compromised secret, because it now lives in logs and histories we don't govern; speed of rotation matters more than blame. Short-term: check whether that class of secret appears anywhere else in prompt history, and whether the tool retains data. Systemic: make the right path easier than the wrong one — a redaction helper in the debugging toolkit, synthetic connection-string patterns for asking structural questions, and the one-line policy everyone can recite: secrets never, PII redacted, proprietary per platform policy. And blameless framing: the person was optimizing for the team's velocity; the failure was ours for not making the safe path the fast path. That's how you get the next incident reported instead of hidden.
12. How does temperature relate to reliability?
Temperature scales sampling randomness — how sharply generation favors the most likely next token. For factual answers, extraction, classification, anything parsed by code: low, because variety there is just inconsistency, and inconsistency is failed runs and flaky behavior. For brainstorming and phrasing alternatives: higher, because variety is the deliverable. Two clarifications I make to teams: temperature doesn't cause or cure hallucination — a grounded prompt at low temperature can still stretch, an ungrounded one at zero still invents; and low temperature isn't determinism — runs converge but aren't guaranteed identical, so validation code stays regardless. It's one dial in the stack, not a reliability strategy.
13. What telemetry would you attach to a production AI feature?
Signals that catch degradation before users do. UNKNOWN rate — rising means coverage gaps or retrieval problems; it's also free requirements telemetry. Validation-failure rate — malformed outputs per thousand; a jump usually means model drift or a prompt regression. Human edit rate where there's a review gate — agents editing more means quality sliding; it's the best proxy for correctness we can measure continuously. Token usage per request — cost regression detection. Latency percentiles. And on any prompt or model change: the regression set runs first, so changes are gated by evidence, not hope. The philosophy: models change under you — telemetry is how a probabilistic dependency stays operable.
14. Where do humans belong in AI workflows, and how do you decide?
At the points where consequence is high and reversibility is low — decided per action, not per feature. A draft reply: the agent's review is the gate, and the failure mode is 'human edits a bad draft', which is fine. A record deletion, a sent notification, a deployed config: approval before the action fires, because no downstream layer can recall it. Two disciplines keep the gates honest: don't dilute them — if humans approve two hundred items an hour, that's rubber-stamping wearing a control's costume, so scope gates to what genuinely needs judgment; and instrument them — edit rates and rejection rates at the gate are your live quality metrics. The goal state: automation earns wider scope gradually, by evidence from the gates, not by optimism.
15. Sum up your prompting reliability philosophy in a minute.
The model is a brilliant, tireless collaborator that is confidently wrong at unpredictable moments — and it never signals which moments. So I never rely on any single defense. I make errors less likely at the source: grounded prompts, honesty rules, constraints, low temperature for facts. I make errors visible in flight: assumptions surfaced, self-verification for mechanical slips. I make errors survivable at the exit: validation code with an UNKNOWN branch and designed failure paths. And I put human judgment exactly where consequences demand it — no wider, so the gates stay real. Data discipline runs underneath: secrets never, PII redacted, enterprise workloads on platforms with contractual data handling. Every layer is leaky; the stack is strong. That's the whole philosophy: defense in depth, with the cheap layers doing the heavy lifting.

19 Glossary

Hallucination
Fluent, confident output that is factually wrong or invented; delivered in the same tone as correct answers, hence the review discipline.
Beginner mistakes (prompting)
The recurring early habits behind most AI misuse: trusting draft one, vague prompts, confidence-as-correctness, boundary-crossing questions, single tests, pasted secrets, arguing with polluted conversations.
Confidence miscalibration
The gap between a model's assured tone and its actual reliability — tone is style, not signal.
Knowledge cutoff
The end date of training data; post-cutoff questions get pattern-matched inventions, not knowledge.
Knowledge boundary
The limit of what a model can know: training data plus supplied context; beyond it, answers are guesswork resembling knowledge.
Non-determinism
Same prompt, different outputs across runs; why single tests prove nothing and validation code is permanent.
Grounding
Supplying authoritative material and restricting the model to it — the strongest single hallucination reducer.
Honesty rule
An instruction making uncertainty a legal completion ('reply exactly UNKNOWN'), preventing forced-answer inventions and enabling validation branching.
Output validation
Deterministic post-checks — parse, schema, allowed values, UNKNOWN branch — converting bad output into handled failure.
Temperature
Sampling-randomness dial: low for facts/extraction/parsed output, higher only where variety is the deliverable.
Self-verification
A follow-up asking the model to check its answer against criteria; catches mechanical slips, shares the generator's blind spots.
Verification prompt
The concrete instrument of self-verification: 'verify each claim against the material; re-check calculations; confirm all requirements addressed.'
Explicit assumptions
Elicited statements of how the model resolved unspecified details — turning silent gap-filling into reviewable, cheaply correctable decisions.
Conversation pollution
Wrong turns persisting in replayed history and conditioning later answers; cured by restarting clean with an improved prompt.
Data privacy (prompting)
Controlling what enters prompts: secrets never, PII minimized/redacted, proprietary data per platform and policy.
PII
Personally identifiable information; redacted or replaced with synthetic equivalents before prompting.
Redaction
Placeholder substitution before sending (EMAIL_1), with local mapping and post-response restoration.
Synthetic substitution
Invented data with the real schema — sufficient for most debugging, because models need shapes, not identities.
Prompt injection
Instructions hidden in untrusted data that the model may follow; why data is delimited and prompts get least capability.
Human-in-the-loop
A person gating output before it takes effect — placed exactly where consequence is high and reversibility low.
Defense in depth
Stacked leaky layers — prompt rules, self-verification, validation, human gates — making failures rare, visible, recoverable.
Regression set (prompt)
Saved test inputs run before any prompt or model change; the evidence gate for a probabilistic dependency.
UNKNOWN branch
The validation path handling honest uncertainty — routing to fallback or human, and logging coverage gaps as telemetry.

πŸ—’ My Notes