0% found this document useful (0 votes)
32 views4 pages

Build RAG Chatbots with Python

The document outlines a two-day workshop focused on building Retrieval-Augmented Generation (RAG) systems and agentic AI with Python. Day 1 covers the architecture of LLMs, embeddings, and hands-on activities to create a RAG chatbot, while Day 2 focuses on developing autonomous LLM agents, integrating tools, and deploying applications. Participants will learn to use various technologies like LangChain, FAISS, and Streamlit to create functional AI systems.

Uploaded by

omkarmeher8689
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views4 pages

Build RAG Chatbots with Python

The document outlines a two-day workshop focused on building Retrieval-Augmented Generation (RAG) systems and agentic AI with Python. Day 1 covers the architecture of LLMs, embeddings, and hands-on activities to create a RAG chatbot, while Day 2 focuses on developing autonomous LLM agents, integrating tools, and deploying applications. Participants will learn to use various technologies like LangChain, FAISS, and Streamlit to create functional AI systems.

Uploaded by

omkarmeher8689
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LLM with Python

DAY 1 – Building a Retrieval-Augmented Generation


(RAG) System
Goal: Understand context retrieval, embeddings, and create a working RAG chatbot using
open-source LLMs.

Time Topic Learning Outcomes Hands-On Activities

9:00 – LLM Ecosystem - Understand the Quick demo: Using


9:30 AM Overview architecture of modern LLM ollama to run a local
apps model
- Difference between model,
retriever, and orchestrator
- Where APIs (OpenAI,
Ollama, etc.) fit in

9:30 – Understanding - Convert text into Hands-on: Build a


10:30 AM Embeddings and embeddings simple document search
Vector Databases - Store and retrieve data engine
from FAISS / Chroma /
Milvus

10:30 – ☕ Break
10:45 AM

10:45 – Designing the RAG - Learn how RAG improves Draw architecture and
12:15 PM Architecture factual accuracy run retrieval pipelines
- Understand chunking,
retrieval, context window,
and re-ranking

12:15 – 🍴 Lunch Break


1:00 PM

1:00 – Building a RAG - Use LangChain / Project: “Chat with


3:00 PM Chatbot in Python LlamaIndex with local Company Policy” bot
LLMs (e.g., Mistral, Gemma) using your own
- Query over PDF or text documents
corpus
- Manage memory and
streaming responses

3:00 – ☕ Break
3:15 PM

3:15 – Enhancing the RAG - Add context ranking, Deploy chatbot UI +


5:00 PM Pipeline caching, and evaluation measure retrieval quality
- Integrate Streamlit/Gradio
for UI

Day 1 Outcomes

●​ Understand how to build a production-style RAG pipeline​

●​ Learn to use LangChain, FAISS, ChromaDB, sentence-transformers​

●​ Deliverable: Working “Chat with Documents” app using local or API LLM​

DAY 2 – Building Agentic and MCP-driven AI Systems


Goal: Create autonomous LLM agents, connect them with tools and APIs, and explore
Model Context Protocol (MCP) for composability.

Time Topic Learning Outcomes Hands-On Activities

9:00 – From Chatbots to - Understand agents, tools, Demo: Agent reasoning


9:45 AM Agentic AI reasoning loops chain visualization
- Learn how OpenAI
function calling and ReAct
patterns work

9:45 – Building a Tool-Using - Connect your LLM with Code Lab: “Smart
11:15 AM LLM Agent external tools (search, Research Assistant” agent
calculator, APIs) (uses DuckDuckGo +
- Use LangChain or Wikipedia)
LlamaIndex agents

11:15 – ☕ Break
11:30 AM

11:30 – Introduction to MCP - Understand what MCP is Explore MCP architecture


12:45 PM (Model Context (as used by Anthropic, with examples
Protocol) LangChain, etc.)
- Learn how to make LLMs
interact modularly across
tools
- Explore structured context
exchange

12:45 – 🍴 Lunch Break


1:30 PM

1:30 – Hands-on: Building - Build a pipeline Project: “Research Copilot”


3:15 PM MCP-Style Modular connecting LLM + Retrieval — RAG + Tool + Planner
LLM System + API + Memory
- Each component
communicates via a context
protocol

3:15 – ☕ Break
3:30 PM

3:30 – Deploying & Scaling - Use Streamlit/FastAPI for Deploy one of your agents
5:00 PM LLM Apps UI locally (Streamlit UI + API
- Use OpenVINO or endpoint)
Ollama for local inference
- Design modular
architecture for real-world
LLM apps

Day 2 Outcomes

●​ Understand Agentic AI architecture (ReAct, Toolformer, function-calling)​

●​ Build a multi-tool LLM agent with reasoning loops​

●​ Learn Model Context Protocol (MCP) for interoperable LLM pipelines​

●​ Deploy working LLM apps via Streamlit or FastAPI​

Common questions

Powered by AI

Agentic AI systems extend beyond traditional chatbots by incorporating reasoning loops, tool integration, and autonomous decision-making capabilities. They leverage advanced patterns like ReAct and function-calling to perform complex tasks independently, such as searching for information, making calculations, or interacting with APIs. This enables them to handle tasks requiring logical reasoning and multi-step operations, unlike traditional chatbots which typically offer scripted interactions with limited adaptability .

Deploying LLM applications locally with systems like OpenVINO or Ollama offers advantages such as improved data privacy, reduced latency, and enhanced control over the operating environment. However, it also presents challenges including the need for adequate local computational resources, potential integration complexities, and maintenance overhead. These systems provide inference capabilities that optimize model execution on devices, but necessitate careful management to balance performance and resource use .

Designing a RAG architecture involves understanding chunking, retrieval mechanisms, context windows, and re-ranking processes. Chunking breaks the input data into manageable pieces, retrieval searches the vector database for relevant information, a context window determines how much retrieved data is fed into the LLM, and re-ranking ensures the most relevant information is prioritized. These components work together to enhance the system's capability to access and use pertinent information efficiently, optimizing the generation of accurate responses .

Streamlit and FastAPI are used for creating intuitive and responsive user interfaces and API endpoints for LLM applications. Streamlit focuses on rapid UI development with minimal code, suitable for deploying interactive data apps, while FastAPI excels in building scalable API services with high performance. Their integration facilitates smooth deployment of LLM applications by providing robust frontend and backend capabilities, allowing applications to cater to user needs effectively and scale to handle varying loads .

To build a document search engine, embeddings are used to convert text data into high-dimensional vectors that capture semantic meaning. These vectors are stored in a vector database like FAISS or Chroma, which allows efficient similarity searches. When a query is processed, its text is also converted into an embedding and matched against stored vectors to retrieve relevant documents, facilitating fast and accurate information retrieval .

Context ranking prioritizes more relevant data for input into the LLM by measuring the relevance of retrieved documents against the query, thereby enhancing response accuracy. Caching helps in improving response times and reducing repeated database queries by storing frequent retrieval results, which is crucial for efficiency and speed in production environments. Together, they optimize the RAG pipeline by balancing accuracy with efficiency .

RAG architecture enhances factual accuracy by integrating a retrieval step before generating responses, which allows the system to access and use external, up-to-date information stored in vector databases. This approach helps in retrieving relevant information as context that can correct or refine the LLM-generated outputs, reducing hallucinations and ensuring responses are based on factual data .

LangChain and LlamaIndex are instrumental in structuring and executing workflows for RAG chatbots. LangChain orchestrates complex pipelines and integrations, allowing different modules like LLMs, retrieval databases, and APIs to work cohesively. LlamaIndex facilitates efficient indexing and retrieval operations, handling document stores to supply the LLM with relevant context. Their combined usage aligns with local deployment needs by simplifying interactions between LLMs and data retrieval mechanisms .

Creating a tool-using LLM agent involves connecting the LLM with external utilities such as search engines, calculators, or APIs. This process typically includes defining interaction modalities, establishing communication protocols, and ensuring synchronization between different systems. LangChain provides framework and workflow support for integrating tools, while LlamaIndex assists in managing the indexing and retrieval of data essential for tool functionality. These tools help organize interactions and streamline processes, making tool integration less complex and more efficient .

MCP allows different LLM components to interact modularly by standardizing how contextual information is exchanged between them. It facilitates structured communication, making the integration of diverse tools, APIs, and LLMs more efficient and flexible. By ensuring consistent context exchange, MCP improves pipeline scalability and adaptability, enabling developers to quickly reconfigure components without affecting the overall system architecture .

You might also like