Applied AI & Prompt Engineering · Module 1: Generative AI Fundamentals & AI Tools · Lesson 2 of 55

How ChatGPT, Gemini & Claude Work: Tokens, Context Windows & AI Models Explained

How ChatGPT, Gemini & Claude Work

Modern AI assistants such as ChatGPT, Gemini, and Claude are powered by advanced AI models that process user inputs and generate responses based on the model's learned patterns, instructions, available context, and the capabilities of the selected model.

Simple Idea:

You provide an input → the AI system processes the available context and instructions → the model generates an output.

ChatGPT, Gemini & Claude: The Basic Workflow

Although the underlying technologies and implementations differ, a simplified workflow for a modern AI assistant can be represented as:

User Input → Tokenization → Context + Instructions → AI Model → Generated Output

The actual architecture is considerably more sophisticated. The diagram above is a learning model intended to help beginners understand the major stages involved.

What Happens When You Send a Prompt?

Consider a user asking:

Explain Python loops to a Class IX student.

The AI system does not process the sentence exactly like a human reader. The input is converted into smaller units called tokens, combined with relevant context and instructions, and processed by the model.

The model then generates the response incrementally according to the capabilities and configuration of the system.

What Are Tokens?

A token is a unit of text that an AI model processes. Depending on the tokenizer and language, a token may represent a complete word, part of a word, punctuation, or another piece of text.

Therefore, a token is not necessarily equal to one word.

Remember:

Words, characters, and tokens are different concepts. The exact number of tokens produced by a sentence depends on the tokenizer and the language.

Why Do Tokens Matter?

Tokens are important because AI systems process text within token-based limits and operations.

Token usage can affect:

  • How much input can be processed
  • How much conversation history can fit into context
  • How much output can be generated
  • Processing cost in API-based applications
  • Performance and latency in some workflows

Words vs Tokens

Concept Meaning
Character A single written symbol such as a letter or punctuation mark.
Word A linguistic unit separated according to language conventions.
Token A unit used by the model's tokenizer to represent text.

For this reason, estimating token usage simply by counting words is only an approximation.

What Is a Context Window?

A context window is the amount of information an AI model can consider within a particular request or interaction, expressed in terms of tokens.

Depending on the AI system, the available context can include information such as:

  • The current user message
  • Earlier conversation content
  • System-level instructions
  • Developer instructions
  • Uploaded or retrieved content
  • Other information supplied to the model
Context Window = Available Token Space for Relevant Input and Output

Why Context Windows Matter

Suppose you are asking an AI assistant to analyze a long school policy document. The system needs sufficient context capacity to process the relevant material and produce the requested response.

A larger context window can be useful for tasks involving:

  • Long documents
  • Large codebases
  • Extended conversations
  • Research material
  • Multiple source documents
  • Large structured datasets
Important:

A large context window does not automatically mean that the model will understand every piece of information perfectly. Context capacity and effective use of context are separate issues.

Context Window vs Memory

These terms should not be treated as identical.

Context Window Memory
Information available to the model within the current processing context. Information that an AI product may retain or retrieve across interactions.
Measured in terms of the model's context capacity. Depends on the product's memory implementation and user settings.
Directly relates to what can be considered for a particular model invocation. May involve information stored outside the immediate model context and retrieved when needed.

Instructions and AI Behaviour

AI systems can receive different kinds of instructions that influence how they respond.

For example, a request may specify:

  • The role or task
  • The target audience
  • The required format
  • Restrictions
  • Output requirements
  • Additional context
Explain database normalization.

Audience:
Class XII Computer Science students.

Requirements:
- Use simple language.
- Include a practical example.
- Explain 1NF, 2NF and 3NF.
- End with five revision questions.

The instructions help define what kind of response the user expects.

System Messages and User Messages

AI applications can provide different types of instructions or messages to the model. One important distinction is between system-level instructions and user messages.

Message Type Purpose
System Message Defines high-level behaviour or rules for the model within a particular application.
User Message Contains the request or information supplied by the user.

Some modern AI platforms also support other instruction layers, such as developer instructions. The exact message hierarchy and implementation depend on the platform and API.

Example: Different Instruction Levels

Consider a simplified educational AI application:

Level Example
System Follow the application's safety and behavioural rules.
Developer Provide answers appropriate for school students.
User Explain recursion with a simple example.

This is a simplified conceptual example. Actual message roles, priority rules, and system architecture vary between platforms.

Why Instructions Matter

Without clear instructions, an AI system may not know the expected audience, format, level of detail, or objective of a task.

Compare:

Explain databases.

with:

Explain relational databases to
Class XI students.

Include:
1. Definition
2. Tables
3. Rows and columns
4. Primary keys
5. A simple school database example

Use beginner-friendly language.

Model Limitations

AI models have limitations. A sophisticated model can still produce incorrect, incomplete, biased, or unsuitable output.

Limitation Explanation
Factual errors The model may generate information that is incorrect.
Hallucination The model may generate plausible-sounding but unsupported information.
Incomplete context Important information may be absent from the available context.
Ambiguous requests Vague instructions can produce unexpected results.
Bias Outputs can reflect biases present in data, modelling, or system design.
Outdated information The model may not contain the latest information, depending on the system and available tools.

Knowledge Cutoff

A model's knowledge cutoff refers to the point in time up to which its training knowledge or built-in knowledge may extend.

A model may therefore be unable to reliably answer questions about events or developments that occurred after the relevant knowledge period unless the AI product provides access to additional tools such as web search, retrieval, or other current-information sources.

Important:

Do not assume that an AI model automatically knows today's information. For current prices, policies, examination notifications, software versions, government announcements, news, or other rapidly changing information, use an appropriate current source or retrieval capability.

Knowledge Cutoff vs Current Information

Situation Recommended Approach
Historical concept Model knowledge may be sufficient.
Current software version Check current documentation.
Latest government notification Check the official government source.
Current examination circular Check the official examination authority.
Current market information Use an appropriate current data source.

What Are Reasoning Models?

Reasoning models are AI models or model variants designed to perform more deliberate multi-step reasoning for tasks that benefit from deeper analysis.

These models can be particularly useful for problems involving:

  • Complex mathematics
  • Programming problems
  • Logical reasoning
  • Multi-step analysis
  • Planning
  • Complex technical tasks
Complex Problem → Deeper Reasoning Process → Final Answer

Fast Models vs Reasoning Models

Fast-Oriented Model Reasoning-Oriented Model
Optimized for speed and responsiveness. Optimized for tasks requiring more deliberate reasoning.
Useful for routine tasks. Useful for complex multi-step problems.
Often suitable for simple content generation. Often useful for difficult analysis and problem solving.
May be preferable when latency matters. May involve additional computation or latency.
Important:

"Reasoning model" does not mean the system is guaranteed to be correct. More deliberate reasoning can improve performance on some tasks, but outputs still require appropriate evaluation.

Why Model Selection Matters

Different AI tasks can have different requirements.

Task Potential Priority
Simple rewriting Speed and cost
Short summary Speed and sufficient quality
Complex programming Reasoning and technical capability
Large document analysis Context capacity and quality
Current information Access to reliable current data
High-volume automation Cost, latency, reliability, and scalability

Why ChatGPT, Gemini and Claude May Give Different Answers

Different AI assistants can produce different responses to the same prompt because they may use different models, training approaches, system instructions, tools, context, safety mechanisms, and product configurations.

Even when two systems appear to perform the same task, their underlying models and surrounding software can differ significantly.

Key Point:

Different output does not automatically mean that one system is wrong. The responses should be evaluated against the task, evidence, requirements, and appropriate authoritative sources.

Example: Same Question, Different AI Systems

Imagine giving the following prompt to three AI assistants:

Explain recursion to a Class X student.

Use:
- Simple language
- One real-world analogy
- One Python example
- Three practice questions

ChatGPT, Gemini, and Claude may all produce useful answers, but the wording, examples, organization, reasoning approach, and level of detail may differ.

This is normal for AI systems and is one reason users should learn how to evaluate AI output rather than relying solely on the name of the tool.

Understanding the Complete Interaction

User → Prompt → Tokens → Instructions + Context → AI Model → Generated Tokens → Final Response

This simplified workflow combines the major concepts introduced in this lesson.

Practical Example: An Educational AI Task

Case Study: Generating a Computer Science Explanation

A teacher asks an AI assistant:

Explain SQL JOINs to Class XII students.

Use a school database example.
Include INNER JOIN, LEFT JOIN and
one practice question.

The AI system processes the instruction along with the relevant context available to it and generates a response.

The teacher should then check whether the explanation is technically correct, aligned with the syllabus, and appropriate for the students.

Common Misconceptions

Misconception Reality
One token always equals one word. A token may represent a word, part of a word, punctuation, or another text unit.
A large context window means perfect understanding. Context capacity does not guarantee perfect use or understanding of every piece of information.
AI always knows the latest information. Current knowledge depends on the model and available retrieval or browsing capabilities.
Reasoning models are always correct. They can still produce incorrect results.
All AI assistants use the same model. Different products can use different models, configurations, and supporting systems.

Practical Activity 1 — Understand Tokens

Consider the following sentence:

Python is easy to learn.

Discuss why the number of tokens should not automatically be assumed to equal the number of words.

Practical Activity 2 — Context Window

Imagine you are asking an AI assistant to analyze a large school policy document.

Identify what information could form part of the context:

  • The user's question
  • The policy document
  • Relevant conversation history
  • Instructions about the desired output

Practical Activity 3 — Improve an Instruction

Weak instruction:

Explain AI.

Improve it by specifying:

  • Audience
  • Topic scope
  • Length
  • Examples
  • Output format

Practical Activity 4 — Identify Model Limitations

For each scenario, identify what should be verified before relying on the AI response.

  1. Latest CBSE examination notification
  2. Current Python library version
  3. Historical definition of a database
  4. Current market price
  5. Generated code for a production application

Interview Questions

Q1. What is a token?

A token is a unit of text processed by an AI model's tokenizer. It may represent a complete word, part of a word, punctuation, or another piece of text.

Q2. What is a context window?

A context window is the amount of information, measured in tokens, that a model can consider within a particular interaction or model invocation.

Q3. Why is the context window important?

It determines how much relevant information can be supplied or considered for a task and is particularly important for long documents, conversations, and complex workflows.

Q4. What is the difference between a system message and a user message?

A system message provides high-level instructions or behaviour for the AI application, while a user message contains the user's request or supplied information.

Q5. What is a knowledge cutoff?

A knowledge cutoff refers to the point in time associated with the model's built-in training knowledge or available knowledge during development.

Q6. What are reasoning models?

Reasoning models are model variants designed to perform more deliberate multi-step reasoning for tasks that benefit from deeper analysis.

Q7. Does a reasoning model guarantee a correct answer?

No. Reasoning models can still produce incorrect or unsupported results and should be evaluated appropriately.

Q8. Why can ChatGPT, Gemini and Claude produce different answers?

They can use different models, instructions, tools, context, safety mechanisms, and product configurations.

Examination MCQs

Q1. What is a token?

  1. Always exactly one word
  2. A unit processed by an AI model
  3. A database record
  4. A programming variable

Answer: B

Q2. What does a context window represent?

  1. The physical size of a computer screen
  2. The amount of information the model can consider in context
  3. The number of users of an AI application
  4. The size of the keyboard

Answer: B

Q3. Which statement about tokens is correct?

  1. Every token is exactly one word.
  2. Tokens can represent parts of words.
  3. Tokens are only used for images.
  4. Tokens are database tables.

Answer: B

Q4. What is a user message?

  1. An instruction or information supplied by the user
  2. The computer's operating system
  3. The AI model's training dataset
  4. A database password

Answer: A

Q5. What is a knowledge cutoff?

  1. The model's screen resolution
  2. A point associated with the model's built-in knowledge
  3. The number of users allowed in an account
  4. The size of a prompt button

Answer: B

Q6. Which task may benefit from a reasoning-oriented model?

  1. Complex multi-step mathematical reasoning
  2. Changing monitor brightness
  3. Printing a document
  4. Opening a folder

Answer: A

Q7. Does a large context window guarantee perfect understanding?

  1. Yes, always
  2. No
  3. Only for images
  4. Only for code

Answer: B

Q8. Why might two AI assistants provide different answers?

  1. They may use different models and configurations.
  2. AI systems always produce identical responses.
  3. Only the keyboard determines the answer.
  4. The screen resolution determines the answer.

Answer: A

Q9. Which information should be checked using an appropriate current source?

  1. A rapidly changing government notification
  2. A basic historical definition
  3. A simple programming concept
  4. A mathematical definition

Answer: A

Q10. Which statement about reasoning models is correct?

  1. They can never make mistakes.
  2. They are designed for tasks benefiting from deeper reasoning.
  3. They do not process tokens.
  4. They do not require instructions.

Answer: B

Key Terms

Term Meaning
Token A unit of text processed by an AI model.
Context Window The token-based capacity for information available to the model during an interaction or invocation.
System Message A high-level instruction used to influence model behaviour within an application.
User Message The request or information supplied by the user.
Knowledge Cutoff A point associated with the model's built-in knowledge.
Reasoning Model A model variant designed for tasks requiring more deliberate multi-step reasoning.
Model Limitation A constraint or weakness that can affect the reliability or usefulness of model output.

Self-Assessment Checklist

  • ☐ Explain what tokens are.
  • ☐ Explain why tokens matter.
  • ☐ Define a context window.
  • ☐ Explain why context capacity matters.
  • ☐ Distinguish context from memory.
  • ☐ Explain the purpose of instructions.
  • ☐ Distinguish system and user messages.
  • ☐ Identify common AI model limitations.
  • ☐ Explain the concept of knowledge cutoff.
  • ☐ Explain reasoning-oriented models.
  • ☐ Explain why different AI assistants may produce different outputs.
  • ☐ Identify situations requiring current information verification.

Key Takeaway

ChatGPT, Gemini, Claude, and other modern AI assistants process inputs using AI models that work with tokens, context, and instructions. Their capabilities are constrained by factors such as context capacity, model limitations, available knowledge, and the tools connected to the AI system.

Prompt → Tokens → Context + Instructions → Model Processing → Generated Response

Understanding these fundamentals helps users choose appropriate AI models, write better instructions, recognize limitations, and evaluate AI-generated results responsibly.