Generative AI · Foundations & Applications  ·  Session 2 · TCE Madurai 1 / 1
next  ·  back  ·  F fullscreen  ·  O overview
session_02/06 Generative AI · Foundations & Applications

Talking to AI,
and catching its lies

Prompts that actually work — and the engineer's answer to "how do you know it's right?": you measure. Today you build the measuring instrument.

Session 2 of 6 Your 10 questions become a weapon
01 90_second_recap — shout first

Still true after the break?

True or false
0 / 0
02 this_sessions_deal

Two artifacts in two hours

A prompt playbook

Role, task, context, format, examples, constraints — you'll take one terrible prompt and rebuild it five times, watching quality climb each step.

An eval harness

The 10 expert questions you wrote in Lab 1 become a test set. Your code will score the model against it — and score your prompts against each other. This one artifact is the difference between using AI and engineering it.

Every AI team on Earth ships on the same loop: prompt → measure → fix → repeat. Today you run your first lap.

03 live_demo · from wish to instruction

The prompt makeover: five upgrades

Same goal, better asks — watch the output climb
Prompt
Output (typical)
10% useful
04 the_pattern behind the makeover

Anatomy of a prompt: six switches

Toggle the parts

Task is mandatory. Everything else is a dial — turn on what the job needs. Over-stuffing costs tokens and dilutes attention (you know why now).

05 the_strongest_dial

Few-shot: show, don't tell

Classify a Tanglish movie review
Review: “Padam semma boring da, second half thookam vandhuchu” → ?

Examples pin down format, labels and edge cases better than any description. The model is an imitation engine — so hand it something worth imitating. 2–5 good examples out-argue a page of instructions.

06 make_it_show_its_work

Step-by-step beats straight-to-answer

₹500 item · 20% discount · then 18% GST on the discounted price. Final price?

Steps force the arithmetic into visible tokens you can check — errors surface instead of hiding. Modern models often reason internally — but when you must audit the logic (money, marks, medicine), asking for the working still wins.

07 your_code_is_the_customer

Demand a format, or parse chaos forever

Extract: “Hi, I'm Priya, third year BE CSE at TCE”

Apps don't read prose. The word ONLY is doing real work — without it you get JSON wrapped in “Sure! Here's your data:” and your parser dies at 2 a.m.

08 guess_the_fix, then click

The four classic prompt crimes

The kitchen sink

"Summarize this, also translate it, also make a quiz, also suggest improvements, also…"

One prompt, one job. Chain simple calls instead — each does one thing well, and you can test each. (This is Session 5's workflow idea, arriving early.)

The fix ↓

Vague adjectives

"Make it good. Make it professional. Make it pop."

Define it or show it. "Professional" = whose? Give a rubric ("no slang, ≤3 sentences, active voice") or 2 examples of what good looks like.

The fix ↓

Assuming it remembers

"Like I told you yesterday…" / "use my usual style"

It remembers nothing (Session 1!). Everything needed must be in THIS context window. Re-send the facts, every time.

The fix ↓

No format spec

Then spending an hour parsing "Certainly! Here are some thoughts…"

Specify structure up front: JSON schema, bullet limit, word cap, "reply ONLY with…". Your parser will thank you.

The fix ↓
09 the_uncomfortable_part

Your polished prompt
still lies beautifully.

A US lawyer submitted a brief citing six court cases — ChatGPT invented all six. He was sanctioned in federal court. Air Canada's chatbot promised a refund policy that didn't exist — a tribunal made the airline honour it.

Mata v. Avianca (S.D.N.Y., 2023) — six fabricated cases, $5,000 sanction  ·  Moffatt v. Air Canada (2024 BCCRT 149) — chatbot invented a refund policy, airline held liable

These weren't bad prompts. They were unmeasured ones.

10 live_game · vote before the reveal

One of these is a confident lie

All three sound equally sure. Which is fabricated?
0 / 0

The scary part isn't that it lies — it's that the lie is indistinguishable in tone from the truths. No amount of squinting at style detects it. Only checking does.

HT hot_take · argue with me

Hallucination is not a bug.
It is the model doing exactly what it was trained to do.

It was trained to produce plausible text, not true text. Plausibility was the objective; truth was never in the loss function. Accept that, and "how do I stop it lying?" becomes an engineering question — with engineering answers.

Disagree? Good. Bring it to the break — strongest counter-argument gets named on the closing slide.

11 the_engineering_answer

"How do you know it's right?" You measure.

Test set

Questions with known correct answers — written by someone who actually knows. (You, in Lab 1 Part E.)

Scorer

Code that compares the model's answer to the expected one and returns ✓ or ✗. No human squinting.

Score

One number. Now "is prompt B better?" has an answer instead of an argument.

"In God we trust; all others must bring data." — the engineer's oldest prayer, today pointed at AI. Or in this course's dialect: a prompt without an eval is a superstition.

12 live_demo · your first eval

Watch an eval run

10 questions · cricket expert's test set

Read the failures, not the score

7/10 isn't the insight. Which three failed, and why — that's the insight. Wrong facts? Format drift? Too-strict matching? Each failure type has a different fix.

The score is a dice roll

Run it twice — the score moves. Session 1's dice, back again. The discipline: temperature 0, three runs, report the average and the spread — even T=0 isn't perfectly deterministic in practice; batching and floating point wobble it.

13 the_scorer decides the truth

Same answer, three verdicts

Q: "Who composed the music for Roja?" · Expected: "A. R. Rahman" · Model said: "It was composed by AR Rahman in 1992."
Pick a scorer…

The metric is a design decision. Too strict → punishes correct answers. Too loose → rewards garbage. Your scorer is part of your system — and sometimes the scorer is the liar.

14 live_demo · settle it with numbers

Prompt A vs Prompt B: the arena

Same 5 questions · same model · only the prompt differs
A: "Answer this: {q}"
B: role + "answer from known facts only,
say I-don't-know otherwise" + format
15 say_it_with_me

"It worked when I tried it"
is not evidence.

You tried 3 questions. Users will bring 3,000 — misspelled, in Tanglish, about edge cases you never imagined. The demo shows the best case; the eval shows the expected case.

Every AI product that embarrassed its company in the news had a great demo first.

16 how_professionals_actually_work

Eval-driven development: the loop

This is the job
Write prompt
v1 is always mediocre
Run eval
T=0 · ×3 · average
Read failures
the actual curriculum
Fix one thing
one change at a time
Re-run
did the number move?
↻  repeat until the score stops improving — then grow the test set

Change one thing at a time or you'll never know what worked. Failures aren't embarrassments. They're the syllabus.

17 lock_it_in — say it before you click

Six ideas you own now

Prompt anatomy

···

Role · Task · Context · Format · Examples · Constraints. Task mandatory, rest are dials.

Reveal

Few-shot

···

2–5 examples pin format and edge cases. The model imitates — feed it patterns.

Reveal

Step-by-step

···

Visible reasoning you can audit. Errors surface in the working.

Reveal

Hallucination

···

Confident, fluent, wrong — indistinguishable by tone. Only checking detects it.

Reveal

Test set

···

Questions + expected answers + scorer = one honest number.

Reveal

The loop

···

Prompt → eval → read failures → fix one thing → re-run. T=0, ×3, average.

Reveal
18 50_minutes · same rhythm as Lab 1

Lab 2: the lie detector

Makeover a terrible prompt
5 documented iterations. Write down WHAT you changed and WHY it got better. ✓ checkpoint 1
Load your 10 questions
The file from Lab 1 Part E. Format them into the test-set template.
Build + run the checker
Normalized-contains scorer. Get your score. Read every failure. ✓ checkpoint 2
Prompt A vs B on YOUR set
Design a better prompt template, run both, compare numbers. ✓ checkpoint 3: show me A vs B + one insight
# the heart of today's lab def run_eval(template, tests): hits = 0 for t in tests: ans = ask(template.format(q=t["q"])) if norm(t["expected"]) in norm(ans): hits += 1 return hits / len(tests)

Stretch

LLM-as-judge scorer · run ×3 and report the spread · does temperature change your score?

50:00 press L to start / pause · R resets — amber at 10:00 left, red at 2:00
19 short_break · Session 3 soon

You can now prove
whether AI is right.

Next session: AI grows eyes and ears — images, documents, voice. Have a photo or two on your phone — you'll interrogate them.

@intrepidkarthiKeep your eval harness — it grades your capstone