Prompting Fundamentals
PROMPT = the interface between human intent and AI output -- better prompt, better result
LLMS PREDICT PLAUSIBLE CONTINUATIONS -- YOUR PROMPT SHAPES THE DISTRIBUTION
The model does not understand your intent -- it predicts what text would logically follow
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Prompting Fundamentals
What is a prompt, and why does wording matter?
Tap to flip
🃏 Answer
PROMPT = the interface between human intent and AI output -- better prompt, better result
Core insightLLMs predict plausible continuations -- not your intent
Vague promptGets vague completion -- the model cannot read your mind
Specific promptShaped probability distribution -- toward the output you need
Why it mattersSmall wording changes produce dramatically different outputs
Tap to flip back
Core Techniques
ZERO then FEW then CHAIN then TREE -- four prompting strategies in order of sophistication
ZERO-SHOT AND FEW-SHOT AND CHAIN-OF-THOUGHT AND TREE-OF-THOUGHT
Let's think step by step -- seven words that dramatically improve reasoning accuracy
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Core Techniques
Prompting strategies — from zero-shot to tree-of-thought?
Tap to flip
🃏 Answer
ZERO then FEW then CHAIN then TREE -- four prompting strategies in order of sophistication
Zero-shotJust ask -- works well for simple, clear tasks
Few-shot2-5 examples improve consistency and format adherence
Chain-of-ThoughtLet's think step by step -- major improvement on reasoning tasks
Tree-of-ThoughtMultiple reasoning paths, pick best -- like beam search for reasoning
Tap to flip back
Role Prompting
ACT AS an expert -- role prompting primes the model's style, tone, depth, and vocabulary
YOU ARE A (specific expert). (Context). (Task). (Format). -- THE FOUR-PART TEMPLATE
More specific role = more calibrated response distribution
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Role Prompting
Role prompting — what does it do?
Tap to flip
🃏 Answer
ACT AS an expert -- role prompting primes the model's style, tone, depth, and vocabulary
Specificity mattersHarvard-trained cardiologist beats medical expert every time
System promptSet persistent role for entire conversation
User promptJust give the task -- role already established in system
Four partsRole + Context + Task + Format = expert-quality output
Tap to flip back
Structured Output
ASK for JSON and you SHALL RECEIVE JSON -- format instructions produce formatted outputs
OPENAI STRUCTURED OUTPUTS GUARANTEES VALID JSON -- API-LEVEL SCHEMA ENFORCEMENT
Always validate output even with reliable models -- occasional invalid JSON still happens
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Structured Output
Structured output — how do you get reliable JSON?
Tap to flip
🃏 Answer
ASK for JSON and you SHALL RECEIVE JSON -- format instructions produce formatted outputs
JSON outputSpecify exact schema -- model returns valid JSON reliably
OpenAI Structured OutputsAPI-level schema enforcement -- guaranteed valid JSON
Anthropic XML tagsUse tags like answer and thinking for structured responses
Always validateEven reliable models occasionally produce invalid JSON
Tap to flip back
RAG Pipeline
RETRIEVE then GENERATE -- ground the LLM in real facts before it writes
QUERY AND RETRIEVE AND AUGMENT AND GENERATE -- FOUR STAGES OF RAG
RAG reduces hallucination but does not eliminate it -- model can still misread retrieved context
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 RAG Pipeline
RAG — the four stages?
Tap to flip
🃏 Answer
RETRIEVE then GENERATE -- ground the LLM in real facts before it writes
QueryUser question that triggers document retrieval
RetrieveSemantic search over vector database -- top-K relevant chunks
AugmentInject retrieved chunks into the LLM prompt
GenerateLLM answers using retrieved context as grounding
Tap to flip back
AI Agents
AGENT = LLM + TOOLS + MEMORY + LOOP -- the four components of an autonomous AI agent
REASON THEN ACT THEN OBSERVE THEN REASON AGAIN -- REACT PATTERN
Agents can make mistakes and get stuck in loops -- human oversight and sandboxing are critical
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 AI Agents
AI agents — the four components and ReAct?
Tap to flip
🃏 Answer
AGENT = LLM + TOOLS + MEMORY + LOOP -- the four components of an autonomous AI agent
LLM coreReasoning engine -- decides what to do next
ToolsWeb search, code execution, APIs, database queries
MemoryShort-term (context) + long-term (vector store)
ReAct patternThink then act then observe then think again
Tap to flip back
LLM API Parameters
MODEL and MESSAGES and MAX TOKENS and TEMPERATURE -- four key parameters every API call uses
SYSTEM PROMPT SETS ROLE AND USER PROMPT GIVES TASK AND ASSISTANT HOLDS HISTORY
Cost = input tokens + output tokens -- optimize by using smallest model that solves the task
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 LLM API Parameters
The four key API call parameters?
Tap to flip
🃏 Answer
MODEL and MESSAGES and MAX TOKENS and TEMPERATURE -- four key parameters every API call uses
ModelWhich LLM -- bigger = smarter and more expensive
Messagessystem + user + assistant role array
Temperature0=deterministic, 0.7=balanced, 1+=creative
StreamingReceive tokens as generated -- better UX for long responses
Tap to flip back
Context Windows
CONTEXT WINDOW = the model's working memory -- everything outside it is forgotten
CLAUDE 200K TOKENS AND GEMINI 1M TOKENS AND GPT-4O 128K TOKENS
Lost in the middle: LLMs pay less attention to content buried in the middle of long contexts
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Context Windows
Context window — what is it, and what gets lost?
Tap to flip
🃏 Answer
CONTEXT WINDOW = the model's working memory -- everything outside it is forgotten
No persistenceLLMs forget everything between conversations without explicit memory
Lost in middlePut critical information at start or end of long context
Context costsLonger context = higher API cost per call
Memory strategiesRAG, summarization, sliding window, external vector store
Tap to flip back
Prompt Security
JAILBREAK = prompting to bypass safety guidelines -- red teams test this before deployment
PROMPT INJECTION AND JAILBREAKING AND PROMPT LEAKING -- THREE SECURITY THREATS
Defense in depth -- no single mitigation is sufficient, layer multiple defenses
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Prompt Security
Prompt security — injection vs jailbreaking?
Tap to flip
🃏 Answer
JAILBREAK = prompting to bypass safety guidelines -- red teams test this before deployment
Prompt injectionMalicious input overrides system instructions -- real attack vector
JailbreakingCreative prompting to bypass safety filters
Prompt leakingUser extracts confidential system prompt contents
Red teamingIntentionally break system before deployment -- mandatory
Tap to flip back
Prompt Evaluation
EVALS first, vibes second -- measure prompt performance systematically before deploying
50 TO 500 REPRESENTATIVE EXAMPLES BEFORE CHANGING ANY PRODUCTION PROMPT
Never deploy a prompt change without running evals first -- works on 5 examples means nothing
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Prompt Evaluation
Prompt evals — how do you test before deploying?
Tap to flip
🃏 Answer
EVALS first, vibes second -- measure prompt performance systematically before deploying
Exact matchOutput equals expected string -- deterministic tasks only
LLM-as-judgeStronger LLM rates outputs on rubric -- scalable
Test set size50-500 representative examples -- before any prompt change
Regression testingVerify golden examples still pass after any change
Tap to flip back
LangChain Framework
CHAIN = LLM + PROMPT + OUTPUT PARSER -- LangChain connects these pieces into pipelines
LCEL PIPE SYNTAX: PROMPT PIPE LLM PIPE PARSER -- CHAIN COMPONENTS TOGETHER
LangSmith provides observability and debugging -- trace every step of your LangChain application
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 LangChain Framework
LangChain — what is a chain?
Tap to flip
🃏 Answer
CHAIN = LLM + PROMPT + OUTPUT PARSER -- LangChain connects these pieces into pipelines
PromptTemplateReusable prompt with variable slots
Chain (LCEL)prompt | llm | output_parser -- pipe syntax
AgentLLM + tools + memory + loop -- autonomous task completion
LangSmithTrace, debug, and monitor LangChain applications
Tap to flip back
🎯 Exam Favorite
CHAIN OF THOUGHT = Show your WORK — the model reasons better when forced to think step by step
THINK ALOUD · REASON THROUGH · THEN ANSWER
Chain-of-thought prompting — the most powerful prompt technique
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🎯 Exam Favorite
Chain of thought — why does it help?
Tap to flip
🃏 Answer
CHAIN OF THOUGHT = Show your WORK — the model reasons better when forced to think step by step
THINK ALOUD · REASON THROUGH · THEN ANSWER
Tap to flip back
🧠 Vivid Story
FEW-SHOT = Showing the model 3 EXAMPLES before asking your question — it gets the pattern
ZERO-SHOT · ONE-SHOT · FEW-SHOT — MORE EXAMPLES = BETTER GUIDANCE
Zero-shot vs Few-shot prompting
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🧠 Vivid Story
Zero-shot vs few-shot prompting?
Tap to flip
🃏 Answer
FEW-SHOT = Showing the model 3 EXAMPLES before asking your question — it gets the pattern
ZERO-SHOT · ONE-SHOT · FEW-SHOT — MORE EXAMPLES = BETTER GUIDANCE
Tap to flip back
🔑 Key Distinction
SYSTEM PROMPT = The BRIEFING before the mission — sets the AI's role, rules, and personality
ROLE · CONSTRAINTS · TONE · FORMAT
System prompts — controlling AI behavior at the foundation
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🔑 Key Distinction
System prompt — the mission briefing
Tap to flip
🃏 Answer
SYSTEM PROMPT = The BRIEFING before the mission — sets the AI's role, rules, and personality
ROLE · CONSTRAINTS · TONE · FORMAT
Tap to flip back
💡 Concept Anchor
AI AGENT = Give it a GOAL and it PLANS, ACTS, OBSERVES, and LOOPS until done
PLAN · ACT · OBSERVE · REPEAT
AI agents — LLMs that take actions in the world
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 💡 Concept Anchor
AI agents — the loop?
Tap to flip
🃏 Answer
AI AGENT = Give it a GOAL and it PLANS, ACTS, OBSERVES, and LOOPS until done
PLAN · ACT · OBSERVE · REPEAT
Tap to flip back
📅 Quick Reference
TEMPERATURE = CREATIVITY DIAL — low temp = focused and predictable, high temp = wild and creative
0 = DETERMINISTIC · 1 = BALANCED · 2 = CHAOTIC
Temperature and top-p — controlling LLM randomness
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 📅 Quick Reference
Temperature — the creativity dial
Tap to flip
🃏 Answer
TEMPERATURE = CREATIVITY DIAL — low temp = focused and predictable, high temp = wild and creative
0 = DETERMINISTIC · 1 = BALANCED · 2 = CHAOTIC
Tap to flip back
⭐ Most Important
ROLE · CONTEXT · TASK · FORMAT · CONSTRAINTS — the five elements of a perfect prompt
RCTFC — THE COMPLETE PROMPT BLUEPRINT
The anatomy of a high-quality prompt
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 ⭐ Most Important
The five elements of a strong prompt?
Tap to flip
🃏 Answer
ROLE · CONTEXT · TASK · FORMAT · CONSTRAINTS — the five elements of a perfect prompt
RoleSets expertise level, tone, and vocabulary — "You are a..."
ContextBackground the model needs to give a relevant answer
TaskExactly what you want done — be specific and unambiguous
FormatHow you want the output structured — list, JSON, table, essay
ConstraintsWhat to avoid, limits, tone — "in under 200 words, no jargon"
🐍 Code# Perfect prompt template
prompt = """You are an expert {role}. {context}
Task: {task}
Format: {format_instructions}
Constraints: {constraints}
Input: {user_input}"""
# Test variations — small prompt changes = large output differences
Tap to flip back
🎯 Exam Favorite
TREE OF THOUGHT = Explore MULTIPLE reasoning paths, pick the BEST one
COT → TOT — MORE POWERFUL REASONING
Tree of Thoughts — beyond chain of thought
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🎯 Exam Favorite
Tree of thought — how does it differ from chain of thought?
Tap to flip
🃏 Answer
TREE OF THOUGHT = Explore MULTIPLE reasoning paths, pick the BEST one
Zero-shotDirect answer, no reasoning — fast, often sufficient
Chain of ThoughtOne step-by-step reasoning path — much better for math and logic
Self-consistencyMultiple CoT paths, majority vote — simple and effective improvement
Tree of ThoughtBranch and evaluate multiple paths — best for complex multi-step problems
🐍 Code# Self-consistency (generate N samples, take majority vote)
responses = [llm(prompt + "
Let's think step by step.") for _ in range(5)]
from collections import Counter
final_answer = Counter([extract_answer(r) for r in responses]).most_common(1)[0][0]
Tap to flip back
🔑 Key Distinction
PROMPT INJECTION = Malicious instructions HIDDEN in data that hijack the AI agent
THE BIGGEST SECURITY THREAT IN LLM APPLICATIONS
Prompt injection — the SQL injection of the AI era
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🔑 Key Distinction
Prompt injection — direct vs indirect?
Tap to flip
🃏 Answer
PROMPT INJECTION = Malicious instructions HIDDEN in data that hijack the AI agent
Direct injectionUser input tries to override system prompt instructions
Indirect injectionRetrieved content (web pages, documents) contains hidden instructions
DefenseSanitize inputs, least-privilege agents, validate outputs before acting
🐍 Code# Basic injection detection (not foolproof)
dangerous_patterns = ["ignore previous", "disregard instructions",
"you are now", "system prompt", "jailbreak"]
def check_injection(user_input):
return any(p in user_input.lower() for p in dangerous_patterns)
Tap to flip back
💡 Concept Anchor
STRUCTURED OUTPUT = Tell the model exactly what JSON shape you want — it delivers it
JSON MODE · FUNCTION CALLING · PYDANTIC — production reliability
Getting reliable structured output from LLMs
🎥 Watch Instead
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 💡 Concept Anchor
Structured output — JSON mode vs function calling?
Tap to flip
🃏 Answer
STRUCTURED OUTPUT = Tell the model exactly what JSON shape you want — it delivers it
JSON modeInstruct model to output JSON — works but may need parsing fixes
Function callingDefine schema, model fills fields — most reliable, OpenAI/Anthropic support
Pydantic/instructorPython class → LLM output → validated object — cleanest for Python apps
🐍 Codeimport anthropic, json
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-6", max_tokens=500,
messages=[{"role":"user","content":"Extract: name, age, job from: John is 30, works as engineer. Output JSON only."}]
)
data = json.loads(response.content[0].text)
Tap to flip back