
Demonstrate how to implement robust retrieval augmented generation systems with asynchronous pipelines, tracing, caching, and batch processing, and evaluate baselines using recall at K, metadata filtering, and reranking.
Create an OpenAI API key, set up $5 billing on the OpenAI platform, and enable GPT four access and embeddings for vector search; securely manage keys.
Explore how tokens function as subword units, not full words, and how token IDs, input tokens, and output tokens drive LLM processing and OpenAI pricing.
Switch from synchronous to asynchronous code to run multiple OpenAI LLM calls concurrently, using async IO and gather to fire coroutines and await them, speeding up many calls.
Implement asynchronous disk caching for LLM calls by creating stable cache keys from function arguments, handling hits and misses, and storing JSON-serialized results to speed up repeated prompts.
Improve autocompletion for the cached chat completion by wrapping the underlying function with functools.update_wrapper, exposing its arguments (max tokens, temperature, etc.) and preserving the original signature for better IDE hints.
Learn to design robust AI workflows by using structured outputs that transform LLM text into programmable objects, enabling parsing, validation, and seamless passing between functions.
Learn to write and iteratively refine a prompt to generate a synthetic dataset for evaluation. Use a Jinja template to render prompts with placeholders and manage multi-line formatting.
Improve prompt design for retrieval augmented generation by classifying emails as useful or useless to recall and generating questions only from useful content, with batch iteration for faster experimentation.
Finish improving the prompt for evaluation question generation in retrieval augmented generation by refining it with ChatGPT, addressing attachment handling, and adding a second step to specify details for recall.
Execute robust OpenAI embedding calls using a text embedding model, implement caching to avoid repeated work, and prepare for cosine similarity calculations.
Compute embeddings for each question by iterating over the email dataset, building a twin data structure for back-and-forth navigation, and batch-generating embeddings with a cached embedding function.
Build a retrieval evaluation workflow using embeddings and cosine similarity to filter bad questions. Compare embeddings of bad questions with generated questions to flag deletions and review candidates.
Build a prompt schema to classify whether two questions are duplicates, using a duplicate verdict enum, a system and user prompt, and chain-of-thought reasoning to produce a final JSON verdict.
Execute the duplicate identification prompt to compare question pairs, filter duplicates, and generate deduplicated questions from the dataset, starting with a subset before full deployment.
This lecture demonstrates improving question quality in retrieval augmented generation by using LLM with structured outputs, evaluating standalone questions, and rewriting prompts based on email content and a JSON schema.
Download section 0205 resources (notebook, written questions json, poll csv) and attach to the first lesson; run all cells to verify questions and set stable keys via a simple namespace.
Install lensdb, the open-source vector database, and enable full-text search with bm25 via tenkV. Create a disk index for emails using Tantivy and update requirements and gitignore the lensdb directory.
Connect to a LanceDB database, create a table with email data, and build a full-text search index on the content column using mode overwrite, then verify with a quick search.
Measure retrieval performance by adding a reranking step to full text search, comparing reranked results to raw results, and evaluating Colbert and cross encoder models for top results.
Please download the notebook attached as a resource to this lesson.
Master Advanced Retrieval Augmented Generation (RAG) with Generative AI & LLM
Unlock the Power of Advanced RAG Techniques for Robust, Efficient, and Scalable AI Systems
Course Overview:
Dive deep into the cutting-edge world of Retrieval Augmented Generation (RAG) with this comprehensive course, meticulously designed to equip you with the skills to enhance your Large Language Model (LLM) implementations. Whether you're looking to optimize your LLM calls, generate synthetic datasets, or overcome common challenges like rate limits and redundant data, this course has you covered.
What You'll Learn:
Implement structured outputs to enhance the robustness of your LLM calls.
Master asynchronous Python to make your LLM calls faster and more cost-effective.
Generate synthetic data to establish a strong baseline for your RAG system, even without active users.
Filter out redundant generated data to improve system efficiency.
Overcome OpenAI rate limits by leveraging caching, tracing, and retry mechanisms.
Combine caching, tracing, and retrying techniques for optimal performance.
Secure your API keys and streamline your development process using best practices.
Apply advanced agentic patterns to build resilient and adaptive AI systems.
Course Content:
Introduction to RAG and Structured Outputs: Gain a solid foundation in RAG concepts and learn the importance of structured outputs for agentic patterns.
Setup and Configuration: Step-by-step guidance on setting up your development environment with Docker, Python, and essential tools.
Asynchronous Execution & Caching: Learn to execute multiple LLM calls concurrently and implement caching strategies to save time and resources.
Synthetic Data Generation: Create high-quality synthetic datasets to simulate real-world scenarios and refine your RAG system.
Advanced Troubleshooting: Master debugging techniques for async code and handle complex challenges like OpenAI rate limits.
Requirements:
A modern laptop with Python installed or access to Google Drive.
Experience as a software engineer (2+ years preferred).
Intermediate Python programming skills or ability to learn quickly.
Basic understanding of data science (precision, recall, pandas).
Access to a pro version of ChatGPT or equivalent LLM tools.
Who Should Enroll:
Software engineers with experience in basic RAG implementations who want to advance their skills.
Data scientists and AI professionals looking to optimize their LLM-based systems.
Developers interested in mastering the latest RAG techniques for robust, scalable AI solutions.
Join this course today and transform your AI systems with the latest Advanced RAG techniques!