Module 1: Core Theory

Prompt Engineering Fundamentals

Understanding the Science of Talking to AI

What is Prompt Engineering?

Prompt Engineering is the art and science of structuring text to effectively communicate with and guide Large Language Models (LLMs) to generate the desired output.

It's not just 'asking questions'. It is a form of programming in natural language. Just as a Python developer writes code to execute logic, a Prompt Engineer writes context and constraints to navigate the probabilistic latent space of an AI model.

The Chef Analogy

Think of an LLM as a Michelin-star chef (the diverse training data). The Prompt is the order ticket. If you write 'Make me dinner', you might get anything from a salad to a steak. If you write 'Prepare a medium-rare Wagyu ribeye with truffle mash, presented on a warm plate', you get excellence. Specificity is the currency of quality.

The 4 Core Pillars

Every successful prompt is built on these four pillars. Missing one often leads to generic or incorrect outputs.

01

Instructions

The specific task you want the model to perform. (e.g., 'Summarize', 'Translate', 'Code', 'Analyze').

02

Context

Background information that limits the scope. Who is the persona? What is the situation? (e.g., 'Act as a Senior Legal Consultant...').

03

Input Data

The actual content to process. (e.g., The text of the email to reply to, or the CSV data to analyze). Always separate this clearly.

04

Output Indicator

The format of the desired result. (e.g., 'Format as a markdown table with columns: ID, Name, Score').

The CO-STAR Framework

A proven industry standard for structuring complex prompts.

C
Context
O
Objective
S
Style
T
Tone
A
Audience
R
Response
C

Context

Provide background information on the task.

O

Objective

Define clearly what you want the AI to do.

S

Style

Specify the writing style (e.g., Business, Academic, Witty, Journalistic).

T

Tone

Set the attitude (e.g., Formal, Casual, Empathetic, Authoritative).

A

Audience

Who is this for? (e.g., 5-year-olds, Experts, CEO).

R

Response

The output format key (JSON, HTML, List, Email).

Example Output
Context: I am a software engineer looking for a job.
Objective: Write a cover letter.
Style: Professional and data-driven.
Tone: Confident but humble.
Audience: Hiring Manager at Google.
Response: A 3-paragraph text block.

Know Your Model

Different models have different 'personalities' and strengths.

Google Gemini

Strengths

Huge context, strong multimodal (image, audio, video), deep Google ecosystem ties.

Best For

Long-document analysis, research with Workspace, multimodal reasoning.

Pro Tip

Put durable rules in system instructions; keep task-specific details in the user turn.

ChatGPT / GPT models

Strengths

Strong reasoning, tool use, coding assistance, and broad ecosystem plugins.

Best For

Analysis, coding workflows, creative drafting, agent-style tool loops.

Pro Tip

Use custom instructions or projects for lasting context; keep each task prompt scoped.

Claude

Strengths

Excellent writing, careful coding, long context, and strong instruction following.

Best For

Document drafting, codebase edits, nuanced analysis, XML-structured prompts.

Pro Tip

Claude responds well to clear XML-ish structure: wrap inputs in tagged blocks.

Under the Hood: Mechanics

Tokens

LLMs don't read words; they read chunks of characters called 'tokens'.

1000 tokens ≈ 750 words. 'Hamburger' is one token. 'Skibidi' might be 3 tokens. This is why LLMs struggle with tasks like 'count the letters in strawberry'—they don't see the letters.

Temperature (0.0 - 1.0)

Controls the randomness of the output.

Low (0.2): Deterministic, focused, analytical. Good for coding and math. High (0.8): Creative, diverse, unpredictable. Good for poetry and brainstorming.

Top-K & Top-P

Advanced sampling parameters.

Limits the pool of next-token choices. Lowering these makes the model 'stick to the script' more rigidly.

Further Learning