Prompt Engineering – 100+ Lab Exercises (Basic, Intermediate, Advanced)
🔰 Basic Level (30+ Exercises)
Goal: Understand foundational concepts, experiment with basic prompt formats, and explore prompt behaviors.
Foundations of Prompt Engineering
Introduction to Large Language Models (LLMs).
What is Prompt Engineering? Key terminology.
Understand zero-shot, one-shot, and few-shot prompting.
Introduction to prompt templates and input-output structure.
Explore model temperature and top-p settings.
Basic Prompt Experiments
Write simple factual prompts (e.g., “What is a computer?”).
Generate lists (e.g., “List 5 countries in Asia”).
Reformat text (e.g., “Convert this to title case”).
Translate between languages using prompts.
Ask the model to summarize a paragraph.
Output Formatting
Ask LLM to return answers in Markdown format.
Prompt the model to output JSON data.
Request numbered lists or bullet points.
Extract structured data from unstructured input.
Wrap responses in HTML for integration with UI.
Basic Roles & Context Setting
Set persona: “You are a teacher explaining…”.
Impose tone: formal vs. casual vs. humorous.
Specify output audience (e.g., for 6th graders).
Ask for step-by-step reasoning.
Request analogy-based answers.
🚀 Intermediate Level (40+ Exercises)
Goal: Craft intelligent, reusable prompt systems and understand fine control over output using context, constraints, and chaining.
Prompt Patterns & Strategies
Chain-of-Thought prompting.
ReAct (Reasoning + Acting) prompting.
Tree-of-Thought prompting.
Role-play based prompt flows.
Reflection-based self-improvement prompts.
Prompt Engineering for Tools & APIs
Design prompts for code generation (e.g., Python, JS).
Create structured SQL queries from natural language.
Generate REST API documentation from prompt.
Debug code using error-prompt explanation.
Prompt for test case generation.
Contextual Prompting
Supply background context in prompts.
Use delimiter markers (
""",<<< >>>) for large inputs.Reference prior responses in chained prompts.
Control memory with system-level instructions.
Inject temporal or location-based constraints.
Industry-Specific Prompting
Finance: Extract financial data from news articles.
Healthcare: Summarize patient notes.
Law: Rephrase legal documents.
Education: Generate custom quizzes.
HR: Draft emails and performance reviews.
🧠 Advanced Level (40+ Exercises)
Goal: Create production-grade prompt systems, integrate with APIs and agents, and apply prompt engineering for autonomous systems.
Advanced Prompt Design & Optimization
Token management and compression strategies.
Use of embeddings in retrieval-augmented generation (RAG).
Convert long documents into vectorized chunks for input.
Dynamic prompt injection with APIs (LangChain, LlamaIndex).
Prompt optimization using
eval()-based testing.
Agents & Autonomous Prompt Systems
Prompt chaining using LangChain agents.
Build multi-step tool-using agents (e.g., web + code).
Construct tools with function calling.
Use prompt routers for context switching.
Multi-agent communication (e.g., teacher ↔ student).
Prompt Evaluation & Debugging
Evaluate prompt accuracy, safety, and hallucination.
Identify prompt-induced biases and reduce them.
Use OpenAI’s evals framework or custom test sets.
Implement A/B testing for prompts.
Log and version-control prompts with metadata.
Ethical & Secure Prompting
Prevent jailbreaks in prompts.
Sanitize user input in public prompt forms.
Control offensive output with constraints.
Add moderation layers using prompt validation.
Use guardrails to block harmful queries.
Capstone Projects
Design a chatbot that provides legal advice using prompt chaining.
Build a content generation pipeline (SEO blogs, emails).
Create a self-improving agent with feedback loops.
Implement an AI tutor with memory-based prompts.
Develop a code review assistant with prompt-based correction.
✅ Tools & Libraries
LangChain, LlamaIndex, PromptLayer
OpenAI Playground, Claude Console, Gemini Studio
Gradio, Streamlit, Chainlit
Replit, Jupyter Notebooks
LangSmith (for logging, tracing)
📚 Resources
OpenAI Cookbook, Anthropic Prompt Guides
Papers like “Prompt Programming for Large Language Models”
OpenPrompt, DeepEval, PromptSource
Blogs: Latent Space, Weights & Biases, OpenAI Engineering
