Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on. You've got this! 🚀
Context
Context is everything the AI model can see at once when generating a response. It includes your current prompt, your conversation history, and any documents you have shared. Understanding context explains why AI sometimes 'forgets' earlier parts of a conversation.
What is Context?
Context is the total input the AI model processes when generating a response.
In a conversation with ChatGPT:
- The current message you just typed is in the context
- All your previous messages in this conversation are in the context
- All the AI's previous responses are in the context
- Any files or documents you have shared are in the context
The context window is the maximum amount of text (measured in tokens) the model can process at once. If a conversation gets too long, older parts start falling outside the context window and the model can no longer see them.
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Why Context Matters
- The model can only use information that is inside the context window
- If the context is too short (vague prompts), the model makes assumptions about what you want
- If the context is too long (very long conversations), early messages may be forgotten
- Providing good context in your prompt is the most effective way to improve AI responses
- Documents and files you share with the AI become part of the context
Practice Task
Note
Open ChatGPT or any AI chat tool. Start a conversation and ask it a few questions about a specific topic. Then ask it to 'summarize everything we have discussed so far.' Notice how well it remembers the entire conversation. Then start a very long conversation and see if it starts forgetting the early parts. This gives you a hands-on feel for what a context window is.
Key Takeaways
- Context is everything the AI model can see at once when generating a response.
- The model can only use information that is inside the context window
- If the context is too short (vague prompts), the model makes assumptions about what you want
- If the context is too long (very long conversations), early messages may be forgotten