GenAI L21(part1) - Building a RAG System in Python using Langchain
Duration: 20 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- Section A | English: Vocabulary, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Preposition, Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Articles, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Verbal Analogy (Word Based Analogy)
- Section A | Quant Aptitude: Ratio and Proportion (Ratios), Mixture and Alligation, Permutation and Combination, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Arithmetic, Algebra, Powers and Exponents (Surds and Indices), Average, Age Problems, Percentage, Profit and Loss, Partnership, Time and Work, Simple Interest and Compound Interest, Mensuration and Geometry, Probability, Pipe and Cistern
- Section A | Reasoning: Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Calendar, Clock, Blood Relations, Directions (Direction Test), Seating Arrangements, Ranking, Order and Sequence, Puzzle Solving (Puzzles)
- Section B | C Programming: C Programming by Yash Sir, Coding Questions by Yash Sir
- Section B | Data Structures: Algorithm Analysis, Greedy Algorithms, Time Complexity Analysis, Sorting Algorithms, Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs
- Section B | OOP (C++): Object Oriented Programming (OOPS), Programming in C++
- Section B | OS: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Threads & Process Creation, Deadlock, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS
- Section B | Networking: Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics
- Section B | AI & Big Data Basics: AI & ML by Arun Sir, Big Data Systems
- Section C | Digital Electronics: Digital Systems & Boolean Basics, Logic Gates & Hardware, Boolean Expression, Boolean Minimization, Combinational Circuit, Sequential Circuits, Number System, Number Representation, Analog-Digital Conversion
- Section A, C | Comp. Fundamentals, COA: Basics of COA, Floating Point Rep, Cache Memory Organization, Input Output Organisation, Pipelining, Instr Formats & Modes, Control Unit Design, Register Transfer and Microoperations, Multiprocessors, Programming the Basic Computer
- MOCK TEST:
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This lecture introduces the practical implementation of a Retrieval-Augmented Generation (RAG) system using Python and Langchain. The session begins with a conceptual overview of the RAG architecture, distinguishing between document ingestion and retrieval phases. The instructor then transitions to a hands-on coding environment, navigating Jupyter Notebook to set up the necessary dependencies. Key steps include resolving installation errors for system utilities like poppler-utils and tesseract-ocr, followed by importing specific Langchain modules such as DirectoryLoader and CharacterTextSplitter. The tutorial progresses through configuring file paths for document storage and vector databases, initializing HuggingFace embeddings, and successfully loading PDF documents into the application. The segment concludes with verifying the ingestion of two specific documents and preparing to initialize a text splitter for chunking, establishing the foundational workflow for building a functional RAG pipeline.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with a static title slide reading 'RAG System in Python using Langchain' and '[KG]', establishing the lesson's focus. The instructor transitions to a Google Slides presentation displaying a 'RAG Architecture' diagram that visually separates the system into two distinct phases: Document Ingestion and Retrieval & Generation. This slide serves as a high-level conceptual map, illustrating how data flows from source documents through databases to models. The visual evidence includes the explicit text labels 'Document Ingestion' and 'Retrieval & Generation', providing a structural framework for the subsequent coding demonstration.
2:00 – 5:00 02:00-05:00
The instructor shifts to a Jupyter Notebook environment to demonstrate the initial setup for document ingestion. They list directory contents showing Python notebooks and configuration files, then attempt to install dependencies using the command 'pip install -r requirements.txt'. This step encounters a critical error where 'pip' is not recognized as an internal or external command. To resolve this, the instructor opens the 'requirements.txt' file to display the necessary packages, including 'langchain-community', 'chromadb', and 'unstructured[pdf]'. This segment highlights the practical challenges of environment configuration before code execution.
5:00 – 10:00 05:00-10:00
The instructor executes terminal commands to install system-level dependencies, specifically running 'apt-get install -y poppler-utils tesseract-ocr' to support PDF processing. After verifying that Python packages are already satisfied, they proceed to import essential libraries into the notebook. Visible code snippets include 'from langchain_community.document_loaders import DirectoryLoader, UnstructuredFileLoader' and 'from langchain.text_splitter import CharacterTextSplitter'. The instructor also initializes HuggingFace embeddings and a Chroma vector store, setting the stage for data processing. This window confirms the transition from environment setup to active library integration.
10:00 – 15:00 10:00-15:00
Configuration variables are defined within the notebook to manage file paths and database parameters. The code explicitly sets 'docs_dir_path = "/content/docs_dir"' and 'vector_db_path = "/content/vector_db"', alongside a 'collection_name = "document_collection"'. The instructor prepares to load an embedding model, with on-screen text indicating 'loading the model' and initializing 'embedding = HuggingFaceEmbeddings()'. This section focuses on parameterizing the RAG system, ensuring that paths and collection names are correctly specified before attempting to load actual data into the vector store.
15:00 – 19:57 15:00-19:57
The instructor demonstrates the document loading workflow using a 'DirectoryLoader' to ingest PDF files. The code 'loader = DirectoryLoader(' is executed, followed by 'documents = loader.load()', which returns a list object. Verification steps confirm the data type as '<class 'list'>' and the length as 2, indicating two documents were successfully ingested. The content of the first document is previewed using '#print(documents[0])', and the instructor begins initializing a text splitter to prepare for chunking. This final segment validates the ingestion process and transitions into the next phase of text processing.
The lecture provides a structured walkthrough of building the ingestion phase of a RAG system. It begins with architectural theory, moving to practical environment setup where common errors like missing pip commands are addressed. The instructor systematically installs system dependencies (poppler-utils, tesseract-ocr) and Python libraries (langchain-community, chromadb). Configuration is handled via explicit path variables for documents and vector databases. The workflow culminates in loading PDFs into a list structure, verifying the count of ingested documents, and preparing for text splitting. This progression establishes a reproducible pipeline from raw files to structured data ready for embedding and storage.

