This repository contains Python notebooks and supplementary materials for the PSI AI Academy's course on AI/LLM Engineering. Designed as a hands-on companion to the lectures, it provides practical guidance and code samples for each module.
Course content is organized by day/module:
day_1/: Introduction to Large Language Models (LLMs) and prompt engineering.day_3/: Retrieval-Augmented Generation (RAG), covering basic and production systems.day_4/: Evaluation of RAG systems and synthetic data generation.day_5/: Advanced retrieval techniques and synthetic data generation for RAG evaluation.day_6/: Agentic architectures using LangGraph and OpenAI Agents SDK.day_9/: Advanced Applications and Integrations (see below).day_9-A2A/: Agent-to-Agent (A2A) Communication & Collaboration.
To work with the course materials:
- Navigate to the day's folder.
cd day_1 - Install dependencies. This project uses
uvfor package management:uv sync
- Explore the notebooks. Launch Jupyter Notebook or your preferred IDE to open the
.ipynbfiles.
- Core Concepts: Learn to interact with OpenAI GPT models via API.
- Prompt Engineering: Build effective prompts, including zero-shot, few-shot, and chain-of-thought (CoT) strategies.
- Chat Architecture: Understand system, user, and assistant roles in chat-based LLMs.
- Application Building: Create simple LLM-based tools and applications.
- Model Reasoning: Explore techniques for controlling and interpreting model responses.
- Basic RAG: Introduction to retrieval-augmented generation principles.
- Productionized RAG: Build and deploy robust RAG pipelines using LangChain and LangSmith for monitoring and evaluation.
- RAG Evaluation: Assess RAG pipeline performance and reliability.
- Synthetic Data Generation: Use LangChain to generate test datasets for RAG evaluation.
- RAGAS Framework: Apply the RAGAS framework for systematic RAG system evaluation.
Two notebooks guide you through advanced retrieval techniques and synthetic data generation for RAG pipeline evaluation:
-
Advanced Retrievers
- Demonstrates advanced retrieval methods in LangChain using a loan complaints dataset:
- Naive Retrieval, BM25, Multi-Query, Parent-Document, Contextual Compression (Cohere Rerank), Ensemble Retrieval, Semantic Chunking.
- Includes an activity to evaluate retrieval strategies with the Ragas framework, comparing performance, cost, and latency.
- Demonstrates advanced retrieval methods in LangChain using a loan complaints dataset:
-
Synthetic Data Generation (SDG)
- Focuses on generating "golden datasets" for RAG evaluation using PDF documents on AI regulation bills:
- Data loading (PyMuPDFLoader), knowledge graph creation (Ragas), test set synthesis (single-hop and multi-hop questions), LangSmith integration.
- Shows how to set up and evaluate RAG pipelines with the generated datasets and compare retriever performance.
- Focuses on generating "golden datasets" for RAG evaluation using PDF documents on AI regulation bills:
Learn how to build stateful, multi-agent applications using LangGraph and the OpenAI Agents SDK:
-
LangGraph
- Introduction to LangGraph for multi-agent LLM applications.
- Covers graph-based architecture: State, Nodes, Edges.
- Includes a chatbot example that remembers conversation history.
-
OpenAI Agents
- Demonstrates the OpenAI Assistants API for agentic workflows.
- Step-by-step creation of an Assistant, Thread, Message, and running the Assistant.
- Example: A "Math Tutor" assistant that solves math problems.
- Integration Focus: Explore integration of LLM-powered applications with external APIs, databases, and workflows.
- Custom Tools & Plugins: Build and deploy custom tools and plugins for enhancing LLM capabilities.
- Case Studies: Real-world examples of integrating LLMs into business and research pipelines.
- Security & Compliance: Considerations for deploying LLMs in production environments.
- A2A Architectures: Design and implement agent-to-agent communication using LLMs.
- Protocols: Explore message passing, negotiation, and multi-agent collaboration strategies.
- Practical Example: Build a multi-agent workflow where agents share knowledge and coordinate tasks.
- Evaluation: Assess performance and robustness of agentic collaborations.
- Install dependencies using
uv sync. - API keys required for OpenAI, Cohere, and LangChain/LangSmith (see notebook instructions).
- Notebooks are self-contained and can be run in sequence or individually.