
This lecture provides a basic understanding of what RAG (Retrieval Augmented Generation), how it's created and how it benefits the user. As you move through this course, you'll appreciate having a local Large Language Model that retrieves and servers up your local data in a query response.
This short video is a callout to let you know that you will need at least 16GB of memory to host the two models that are used in Docker Model Runner.
Demo to help with setting up a Python virtual environment using Python version 3.13.
Demo to help with installing Docker and running local models that will be used to create RAG.
RAG provides a way to incorporate user data into an AI query by processing the data and storing it in a numeric vector "database". In the demo project, our raw data is a set of four PDF files. We must convert the PDF's to a text format. This video shows you how to convert PDF's to Markdown text. This is the first step in a pipeline that will ultimately store the data in a FAISS index.
After converting user data to a text format in Section 2, we are now ready to "ingest" the data into a FAISS index. We're using the ai/embeddinggemma model to map out the data in a multidimensional space. This layout arranges data so that searching for content that matches AI Query input can execute quickly. The FAISS Index is made up of two files: index.faiss and index.pkl. Together these files are responsible for storing and retrieving data with semantic similarity.
This video demonstrates how to execute the ingestion script as well as a test script to verify that the dimensions of the vectors are calculated to 768 as expected. The ingestion script reads in the user data markdown documents and with the use of chunking and embedding creates the vector store that stores data in two files that make up the FAISS index. This video will help to understand how data is stored in numeric vectors (index.faiss) and then human readable content can be extracted using meta data stored in a "pickle" file (index.pkl).
The code in app.py is broken down into nine sections as shown below. The application implements that query pipeline from User question to user data extraction and ranking for similarity to the question. A PROMPT is created that will hold system instructions (guardrails), context and the user question. Context will be provided by data from the FAISS index.
Global Configuration
Section 1: Environment and Docker Model Runner Endpoint
Section 2: Load Embedding Model
Section 3: FAISS Vector Store (only use indexes you create yourself)
Section 4: Large Language Model
Section 5: Create Retriever
Section 6: Cross Encoder ReRanker
Section 7: RAG Prompt
Section 8: RAG Chain
Section 9: User Interface
This video will walk you through running the app.py script. The script provides provides instruction to the user who wants a question answered. The user question is added to the application PROMPT, along with static system instructions, and context. Context is provided by extracting text data from the FAISS index and comparing it to data in the users questions. The similarity comparisons are scored and the top 4 data chunks are merged and provide the context. The video explains using the huggingface.ai website to set up an access token that is tied to the CrossEncoder library which scores the comparisons between user data in the FAISS index and the text in the user question.
The DEBUG demo outputs data related to document data in the vector store and total chunks in the index and chunks per source. Once the user asks a questions the ReRanker is called to generated top 4 similarity matches to the user questions. This outputs data showing ReRanker similarity scores for documents matched to the user question.
If you are reading the code, and don't fully understand what the code is doing, I recommend using AI to help you to understand it. This is a short video that can help you to prompt your favorite AI to explain what the instructions in the code are doing.
We conclude this course with a discussion of memory as it pertains to 'how much data can we add to the FAISS index' and how much RAM is needed to run this application locally with Docker Model Runner. We also address the question: 'Should I run locally or should I set up my RAG application in the cloud?'. We look at a list of use cases for running RAG in the cloud. The "Next Step" is to keep learning and there are suggestions for creating Agentic RAG.
This course teaches the how and why of Retrieval Augmented Generation (RAG) - a technique that connects private local data to a large language model. Students will build and run a fully local RAG system using Docker Model Runner, LangChain and FAISS, gaining hands-on experience with both he data ingestion pipeline and the query pipeline including retrieval and reranking.
This course is designed for developers, data practitioners, and curious professions who are comfortable writing Python and want to move beyond chat bot prompt based interactions. This course will be beneficial if you're interested in understanding how AI systems work, specifically how you can host local user data and make it available as context to a local LLM. You'll write your own user interface that provides the prompt for local queries than can use your personal data. The skills you gain are applicable to building private, cost-effective AI tools that run entirely on your own machine, making this course especially valuable to those working with sensitive data or in environments where cloud AI services are not practical or permitted.
Students will also learn how to work with the Docker application's Docker Model Runner (DMR). DMR will allow you to run local LLMs and models that can build numeric vectors which allow you to integrate "chunked" user data with the LLM.