π» 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
.envfile 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.
πΊοΈ 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:- Takes a userβs natural language request (e.g., βFind the top 3 employees with the highest salaryβ).
- Merges it into a prompt template containing your SQLite database schema definition.
- Requests the LLM to generate a structured JSON object containing the raw SQL query and a short explanation.
- Validates the JSON schema with Pydantic, executes the generated SQL query against a test database, and prints the resulting records.