LLMs and Prompts in Generative AI

Introduction to LLMs and prompt engineering fundamentals

Table of Contents

Large Language Models (LLMs) such as ChatGPT, Claude, and Gemini generate text by predicting the next token from patterns learned in massive amounts of training text, not by looking up facts. This lesson covers tokens, context windows, and the six-part prompt structure (role, task, context, rules, examples, format) for writing prompts that get useful, specific answers.

What you will be able to do

  • Write prompts using the six-part structure: role, task, context, rules, examples, format
  • Estimate roughly how many tokens a prompt uses (about 750 tokens per 1,000 words) and keep it within the context window
  • Explain why LLMs hallucinate and apply the safety tips (treat the model as an assistant, set boundaries, ask for sources) to reduce risk
  • Apply the three-step formula, name the role, state the task with a verb, set rules and format, to turn a vague prompt into a clear one
  • Run a prompt against the good-prompt checklist before sending it

Before you start

  • Access to an LLM chat tool such as ChatGPT, Claude, or Gemini
  • Basic familiarity with typing a message into an AI chat interface
  • No coding or technical background needed

Reference

Prompt part What it does Example from the lesson
Role Sets who the model should pretend to be "Act as a science teacher for grade five"
Task States what should be done, using a verb Summarize, rewrite, compare, or plan
Context Gives facts the model needs Notes, data, or short passages
Rules Sets boundaries on the answer "Keep it under 150 words," "use simple words"
Examples Shows the kind of output wanted (few-shot) One or two sample inputs with expected answers
Format Tells the model how to shape the answer Paragraphs, bullet list, JSON, or table
Token rule of thumb Estimates prompt/response size for cost and context limits About 1,000 words equals 750 tokens

Common errors and fixes

What goes wrong The fix
Prompt is vague and long Cut fluff, state the task with a verb, add one or two rules, then stop
No audience is set Say who the reader is: age, role, or skill level
No format is given Ask for a structure like bullets, table, JSON, or clear sections
Too many goals in one ask Split into small steps: plan, then draft, then polish
Model gives a wrong answer with confidence (hallucination) Ask for sources when they matter, and stop to rethink the task if the answer seems wrong or unsafe

Read the full walkthrough

The complete lesson, with screenshots and any downloads, is published on Substack as part of Prompt Engineering for AI Automation.

Read Lesson 1 on Substack →

More in this section

Continue the course

Browse all lessons in the Prompt Engineering for AI Automation course, or subscribe to the GenAI Unplugged newsletter to get new lessons in your inbox.

Dheeraj Sharma

Dheeraj Sharma

AI Systems Builder
Creator of the n8n Zero to Hero course (42 lessons, 31+ hours). I help solopreneurs build AI systems that grow revenue without growing workload.

Get the n8n Mastery Bundle

All workflows, cheat sheets, and premium resources from the entire course in one package.

Read the full lesson on Substack