Skip to main content
Welcome to the Prompt Engineering module. This module explores how to design, optimize, and programmatically manage prompts to get consistent, high-quality, and structured outputs from LLMs.

πŸ’» Module Practice Notebooks

Master all the concepts from this module with hands-on practice:
  • Practice in VS Code: Open the notebook in your local editor. Requires a local .env file containing your API keys.
  • Practice in Google Colab: Open the notebook directly in Colab. Setup cells are included to install packages and request API keys.
πŸ’» VS Code | πŸš€ Colab | πŸ“₯ Download Notebook

πŸ—ΊοΈ Module Overview

Learn how to control LLM outputs deterministically:

πŸ“š Module Curriculum & Roadmap

Explore the sections in this module using the cards below:

1. Introduction to LangChain

Why LangChain is needed, the difference between traditional and GenAI applications, setting up projects with uv, managing .env keys, and initializing Groq/Gemini chat model providers.

2. Prompt Templates & Messages

Defining string-based PromptTemplate and message-based ChatPromptTemplate schemas, understanding message objects (SystemMessage, HumanMessage, AIMessage), variable passing, and response extraction techniques.

3. LCEL & Runnables

Building pipelines using LangChain Expression Language (LCEL) and the pipe (|) operator, managing invoke() vs. stream() flows, and using runnables like RunnablePassthrough, RunnableSequence, and RunnableParallel.

4. Output Parsers

Converting raw text generated by LLMs into structured Python structures: strings (StrOutputParser), lists (CommaSeparatedListOutputParser), dictionaries (JsonOutputParser), or validated data objects (PydanticOutputParser).

5. Model Hyperparameters

Controlling token selection, randomness, and length using parameters like Temperature, Max Tokens, Top-K, and Top-P.

6. Few-Shot & Sequential

Advanced prompting patterns, explaining why few-shot example formatting is required, setting up FewShotPromptTemplate, and composing sequential chains where outputs feed directly into subsequent prompts.

πŸ› οΈ Practical Capstone Project

Natural Language to SQL Generator

Build a python tool that:
  1. Takes a user’s natural language request (e.g., β€œFind the top 3 employees with the highest salary”).
  2. Merges it into a prompt template containing your SQLite database schema definition.
  3. Requests the LLM to generate a structured JSON object containing the raw SQL query and a short explanation.
  4. Validates the JSON schema with Pydantic, executes the generated SQL query against a test database, and prints the resulting records.