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 the background information you give AI so it can produce a relevant response. Without context, AI has to guess what you need. With good context, the response is much more useful.
What Context Is
Context is any background information that helps the AI understand your situation.
Context answers questions like:
- Who is asking? (a student, a developer, a business owner)
- What is the purpose? (for a report, for a client presentation, for learning)
- What is the background? (I am new to Python, this is a financial document)
- What are the constraints? (keep it simple, avoid technical terms, under 100 words)
Context helps AI tailor the response to your specific situation.
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Prompt Without Context vs With Context
Without context:
Prompt: 'Explain APIs.'
Result: A general explanation of APIs that may or may not be useful for your situation.
With context:
Prompt: 'Explain APIs to a junior developer who knows JavaScript but has never worked with REST APIs. Use a simple analogy and one code example in JavaScript.'
Result: A targeted explanation with the right level of detail, the right language, and an appropriate code example.
The context changed the audience, the background, and the output format. All three make the response more useful.
Types of Context to Include
- Who you are: 'I am a student learning Python for the first time'
- What you have already tried: 'I tried using a for loop but it returns an error'
- The purpose: 'This is for a presentation to non-technical clients'
- The constraints: 'Keep it under 100 words and avoid technical jargon'
- The audience: 'Write for someone with no programming experience'
- The document or code: include the actual content you want AI to work with
Key Takeaways
- Context is background information that helps AI produce a relevant response
- Without context, AI makes assumptions that may not match your needs
- Good context includes your background, the purpose, the audience, and constraints
- Including the actual document or code you want AI to work with is always helpful
- Context does not make your prompt longer unnecessarily; it makes it more targeted
Key Takeaways
- Context is the background information you give AI so it can produce a relevant response.
- Who you are: 'I am a student learning Python for the first time'
- What you have already tried: 'I tried using a for loop but it returns an error'
- The purpose: 'This is for a presentation to non-technical clients'