Learn LangChain in 7 Easy Steps - Full Interactive Beginner Tutorial

Rabbitmetrics · Beginner ·🧠 Large Language Models ·2y ago

Key Takeaways

This video tutorial teaches the basics of LangChain, an open-source framework for developing LLM applications, by breaking it down into seven key components, including setting up a chain, using prompt templates, and creating agents.

Full Transcript

in this video you'll learn everything you need to know about Lang chain in seven easy steps I've broken down the framework into key components and here's an overview of the image I'm going to try to put in your mind in the next 40 minutes there is a lot to unpack but I'll walk you through the components one by one and I've included coding examples with every step I'll start off by asking why length chain and I'll give you a reason why you want to learn this and an overview of the framework then I'll show you how to build chains using prompts and ERS and we'll dive into the runable protocol and Lang chain expression language then we'll look at Splitters and retrievers and we'll build a rag chain finally I'll walk you through how to use tools and how to build an agent with access to Tools in this video I'll keep my focus on the core Lang chain framework and build the foundation for advanced use cases so I'll save Lang graph Lang Smith and Lang surf for separate videos if you're new to Lang chain this tutorial will serve as a quick start and if you're already already familiar with the framework you can use the tutorial to tie up some loose ends I'll share a link to this interactive map of Lang chain to the code and to a written tutorial below this video let's get started I'm going to start off by giving you an overview of the linkchain framework what is it why would you want to use it and then I'm going to show you how to get started developing in a collab notebook so what is Lang chain Lang chain is an open open source framework for developing llm applications an engine allows developers to combine llms with external sources of computation and data and the framework further simplifies the deployment of the llm applications by providing the needed tools such as tools for inspection monitoring and evaluation the deployment and monitoring tools are part of Lang Smith and Lang serf I'm not going to cover that here I'm going to cover the core Library so Lang chain combines llms with external sources of computation and data how does that work suppose that a user wants to ask a question related to some documents or some data that the user has access to now this question will be sent to the llm just like when you're interacting with chat DBT but you also need to fetch the context needed to answer the question from your own data or your own documents and to do that a vector representation of the initial question from the user is used to fetch all the relevant context needed to answer the question typically from a vector database this context is then fed to the llm alongside with the initial question and now the llm has everything it needs to answer the question in the right context and the magical thing about this is that we can do more than just answer the question we can actually take actions based on the input from the end user and we can do that because Lang chain allows us to build agents out of llms and agents are created by by combining llms with tools this will give the llms access to external sources of computation and data so what can we build with Lang chain when it comes to the types of applications you can build with llms this guise the limit from what I see most llm applications that have been built over the last year fall into one or three categories chatbots racun applications or agent systems so the chat BS are nothing new they're used for marketing customer support different types of education and creating assistance what is new is that these chat Bots can now be made more intelligent using llms then we have the rag Q&A applications and this is the magic that Lang chain and llama index made people aware of a year ago so these are the applications that are used for summarizing large documents doing data analysis and generating code by referencing repositories and then we have what we can call agent system both multi-agent systems and systems where we Loop humans into complex interactions with agents and this is what Lang graph is used for and Lang graph is a rather new component in the Lang chain ecosystem the number of potential applications of agent systems is virtually Limitless they're being implemented for Supply Chain management Revenue optimization operations management and so on all right so let's zoom out a bit and have a look at why you want to learn langing so so there are at least two good reasons for learning Lang chain so first of all Lang chain facilitates the transitioning to the next generation of programming languages and what do I mean by that so if we have a look at programming language hierarchies this is what it typically looks like so at the bottom of the pyramid you will have machine language on top of that you will have Assembly Language then you have the higher level languages those are the languages that you are used to program coming in so python Java SQL R C++ and so on and we've been moving up the pyramid ever since programming became a thing and right now we are at the final step the highest level of all languages which is natural language because with the llms we don't have to write code anymore we can have the llms write code for us by giving natural language as an input and the development of these pipelines that allows us to turn natural language into programs is exactly what Lang chain facilitates so we can create pipelines or chains as they are called that allows us to input natural language and get something of value in return like a report an analysis or computer program and with the current generation of best-in-class llms we can already write executable code code that works so this is not something that belongs to the Future it's already here now the second reason you you might want to use Lang chain is really not Lang chain itself but what's being built on top of Lang chain which is Lang graph now Lang chain was late to the multi-agent game you had autogen you had crew AI before that but what langra can do is really remarkable for instance Lang graph allows us to build complex interactions between agents and humans and this is needed especially in big organizations where you have to guard the access to certain files and so on but Lang graph also allows us to build multi-agent systems like autogen or crew II and the use cases for this are becoming more clear every day we need to be able to set up arbitrary communication patterns between agents we also need to do divide and conquer just like humans we can't have an llm do everything so we want to build specialized agents and we want them to be able to perform tasks in an asynchronous way all right let's get started developing the first thing you want to do is you want to fetch the API key from the llm service you want to use so in this tutorial I'm going to use openi and anthropic but Lang chain supports a wide array of llm providers so you can just choose your favorite one once you have grabbed your API key you want to put it in a EnV file all right so here on the collab notebook I have already installed the needed libraries here I'm going to install python. EnV to fetch API keys from the EnV file I'm going to install Lang chain of course Lang chain Community Omi and anthropic and I have uploaded the EnV file from my local machine to the cab notebook and now I'm ready to load the environment variables so I'm loading the API keys and once I've done that I can use chat anthropic and chat Omi to connect to anthropic and Omi and then I'm going to make a test call to GPT 4 and ask what is Lang chain and I simply make an LM call by using the invoke method and here we have an answer from gbt 4 this is very similar to what you would do if you were just calling gbt 4 directly through the open API and of course we can just switch out the llm now I'm calling clot 3 and here I also get a response so I can also easily prpt the llm with a system message and a user message at the same time and I'll just send the two messages in a list to the llm and this will allow you to do some basic prompt engineering but we can do a lot more advanced stuff than this once we start utilizing prom templates and building chains all right so let's dive into chains prompts and loaders and build our first chain I'm going to walk you through what a chain is and give you an analogy to think of then I'm going to work you through prom templates and how to use document loaders so a chain in Lang chain is a sequence of interconnected components that process a user's query utilizing one or more llms to generate and deliver some valuable output and I'm going to get into what those components are in a bit but let me just give you examples of the valuable output that we can generate with the chain so examples of valuable output could be an answer to a specific question it could be a summary of some document it could be a recommendation insights from data a piece of executable code or some Json for an API call and with the chains we can automate the generation of this value now what about the components the components of a chain are typically proms llms or what we call chat models output passes that passes the output of the llm tools that allow the llms to extract additional information from apis or run some code this is what turns llms into agents and general functions and in Lang chain these components are so-called runnables that can be chained together to produce a pipeline and this is one way to think of chains as pipelines in the world of llms so an analogy would be a data pipeline in a data pipeline we typically input some raw data and we get some nice clean data out in a table format and the data cleaning and transformation happening in the pipeline is valuable similarly in an llm chain we input a query and we get some valuable output in return and here the query is turned into value using llm calls functions and additional data and just like with data pipelines we can automate this process with cicd continuous integration and continuous delivery and this is what Lang chain as a framework can help you do so not only can you build the chains but you can also test the chains deploy them monitor the chains and evaluate the output and this can be done with Lang Smith and Lang surf so Lang chain has several built-in modules or classes that helps you create chains efficiently and one of those modules are prompt templates so a prompt for an llm is a set of instructions provided by a user to guide the model's response and promt templates in Lang chain are predefined prompt recipes these recipes are very helpful when you want to create chains fast another feature of Lang chain is that you have so-called document loaders a document is a piece of text and Associated metadata and the Lang chain document loaders provide a load method for loading data as documents from a source into a chain now let's head over to a collab notebook and set up a simple chain I'm going to import prompt template from Lang chain prompts and then I'm going to formulate the prompt to the llm as a string with a placeholder in this case with the variable topic and then I set up the prompt using the prompt template I just imported from Lang chain an input variable that I'm going to call topic and then the string the template itself and this is a simple example of a prompt that now allows me to comp OS a chain and I do that using the pipe operator so I can take the prompt and the language model LL mgbt 4 and assemble a chain using those two components and now I can invoke the chain with an input variable in this case topic so this was a very simple example of assembling a chain using the pipe operator let's try to make this a bit more advanced I'm going to create a chain that will transcribe one of my YouTube videos so I'm going to pip install the YouTube transcript API and then I can use one of the loaders that is spilled into L chain the YouTube loader so I'll import YouTube loader from Lang chain Community document loaders and then I can simply pass the URL to one of my videos or any video to the loader and have the loader extract the transcript from the video now if we have a look at what the loader extracts you can see that we get a list of documents if you want the transcript you can simply extract the page content from the documents or you can simply pass the documents to the chain directly so fetching the raw transcript would be as simple as just fetching the single document in this list and then extracting the page content all right so let's set up a chain that will summarize YouTube videos given a transcript so here I'm going to inject the video transcript into the prom template so this is going going to be my input variable and then I just set up the chain like I did before with the pipe operator and I'm going to invoke it with the video transcript and note that I can just pass the documents I don't have to extract the raw transcript and here we have a nice summary of my YouTube video so Lang chain also has a number of build-in chains that you can use for stuff like this for instance the create stuff documents chain and this chain will take a list of documents and pass them all in as context in the prom template pretty much what we did before just without using the buil-in chain this was just a very basic introduction to building chains now in order to build more advanced chains we need to understand Lang chains runnable protocol and Lang chain expression language in more detail let's now try to dive deeper into Lang chain expression language and the runnable protocol the Lang chain expression language simplifies building complex chains from basic components and we do that using the pipe operator that allows us to chain different components together feeding the output from one component to the next so a simple example of a chain composed in this way would be a prompt combined with a model and an output passer and these components are so-called runnables think of Lang chain expression language as a declarative way of composing these so-called runnables into chains and I'll get into what a runnable is in a second here we have a step-by-step example of what a chain looks like we have an input to the chain which is typically a dictionary that is sent to a prompt then a prompt value is sent to the or the chat model then the chat model will return a chat message that we want to pass and we typically want to use the passer to extract a string from the chat message and this will be the output of the chain this is one example of a basic chain and L chain allows us to chain multiple chains together like this so we might want to use the string output of the chain and send that to a new chain that will return a different output so what are runnables let's try to understand the runnable protocol this definition is directly from Lang chain a runnable is a unit of work that can be invoked batched streamed transformed and composed and the chains we built with Lang chain and the components of those chains are runnables and apart from Lang chain native components being runnables we can actually also pass in random functions into chain and those functions will then turn into runnables I'll show you that in an example when we get to the code and these chains can be invoked that means we execute the chain we can call batch on them if we have multiple inputs and we can stream the chains there are some core runnable objects in Lang chain that you want to understand in order to fully appreciate the Lang chain expression language these four objects are the most important ones runnable sequence runnable Lambda runnable pass through and runnable parallel so let's start from the top a runnable sequence in Lang chain is a class that chains together multiple runnable components and it ensures that each component processes its input and sequentially passes its output to the next component in general the change you're building in Lang chain will be of type runnable sequence now what about runnable Lambda runnable Lambda is a class that turns a python callable like a function into a runnable component and this allows us to integrate arbitary functions into chains as in the example I just showed you then we have runnable pass through and a runnable pass through in Lang chain is a class that either passes its input through unchanged or adds additional keys to the output in the first case it acts as a placeholder and in the second case it allows us to do flexible Integrations into sequences where we need to modify the input and finally we have runnable parallel and a runnable parallel in L chain is a class that runs multiple runnables concurrently and this allows you to do branching where you have two chains run the same input but return different outputs now let's see how this works by looking at some code examples all right so I'm going to use the same symbol example throughout this section I'm going to have an llm summarize AI Concepts here I have a prompt that tells the llm to summarize an AI concept and then I'm going to inject a context into the prompt the first thing I'm going to do is I'm going to create a simple chain using the pipe operator we already did it once now I'm going to add an additional element the output passer so the chain is composed of three elements the summarized prompt the llm and the output passer and when we invoke the chain we get the text output now remember that chains are of type runnable sequence and we can check the type of the chain that we just created to see if that is the case so I'm just going to print the type of the chain and here we can see that it is indeed of type runnable sequence now let's try to use a runnable Lambda here we have the same summarized chain as above but now with an additional element so I have a function that will calculate the length of the summary and then I'm wrapping this function in a runable Lambda this allows me to extend the chain we had before with an additional element so by adding this runnable Lambda to the chain from before I now have a chain that will return the length of the summary instead of the summary itself and here I can also check the type of the last element of the chain that I just added and it's of type runnable Lambda now we don't actually need to wrap the function in a runnable Lambda we can just add the function to the chain and then langin will make sure that the function is automatically converted to a runnable Lambda if I print the type of chain with function you can see that the last step of this chain is of runnable Lambda even though we didn't explicitly wrap the function in a runnable Lambda and let me just demonstrate that this chain actually works so I'm just going to invoke chain with function with the same context and here we get the summary length let's have a look at runnable pass through and first we'll go through the case where we use it as a placeholder I'm just going to instantiate a pass through and then I'm going to injected into the chain just before the length Lambda function and and as you can see we get the same output as before I can also check the types of the steps and you can see that the last step is still a runnable Lambda and the step before that is a runnable pass through passing data through without changing it like this is typically used with runnable parallel we can also use a runnable pass through for assigning value to the state of the chain to do that you will use the assign method of the runnable pass through and here I'm going to add the length of the summary to the state of the chain if I then add the assigned pass through as an additional component to the chain the output of the chain will now have an additional key with the length of the summary assigning an additional key value like this is particularly useful when you're working with SQL chains in some of my earlier videos on building custom SQL chains I'm actually using the assign method like this if I run this you can see that we now have the summary and the length and if I check the type of the last component of the chain I now get the type runnable assign the last example I'm going to give is the example of a runable parallel and in this case I will simply take the summary that the summarized chain is returning and then I'm going to Branch Out The Chain in two different arms one is going to take the summary and return the summary as it is this in the other one is going to return the length of the summary and this is going to give me something that is similar to what we got in the previous example so here my output contains the summary and the length of the summary and if I check the type of the last step of the chain I get a runnable parallel now let's talk about splits and retrievers I'm going to walk you through what a retriever is how we can split data into chunks and how we can load those chunks into a vctor store and in the cab notebook I'm going to give you a Hands-On example of working with a vector store I'm going to show you how you can use redis to build a vector store backed Retriever and do retrieval from Lang chain but let's start with answering the question what is a retriever a retriever in Lang chain is an interface case that returns documents given a query and this is not to be confused with a vector store so a vector store can be used as the backbone of a retriever but a retriever does not store the documents itself Vector store back retrievers are by far the most common retrievers when we build llm applications and when we build rag applications retrieval augmented generation applications we typically want to chunk up our data or split our data with a text splitter and store that in the vector store and langin has several built-in text Splitters that can be used for various different purposes it has a recursive text splitter that will try to keep the related chunks of text next to each other it has splitters for HTML markdown different types of code characters and tokens and I'll show you in a bit how to use the recursive text splitter when we get to the notebook so when the data has been chunked up into pieces we loaded into a vector store and then we can use that Vector store as the bases for a retriever that can be used in Chains or agents and if you go back and watch some of my earlier videos there are plenty of examples of using reddis and there's also a few examples of using pine cone but there are many different Vector databases to choose from and it's easy to switch up the vector database if you're using Lang chain because the interface is almost identical for for all the databases all right so let's head over to the collab notebook and see how we can work with Vector stores and how to use Splitters and retrievers so in this example I'm going to be using reddis as the vector store so I've pip installed redis and then I'm going to use the YouTube loader that we used before to extract the transcript from one of my videos here the loader will return a list of documents containing one document with the entire transcript of my video and now I can spit the text in the document using the recursive character text spitter and this text splitter is imported from langin text spitters I can then call the split documents method on the lists of documents containing a single document and then it will return a list of documents with chunks of text I could also have split the raw text by using the split text method of the text splitter once I have the chunks of text I want to load to a vector store I can connect to reddish or any other Vector database that Lang chain supports I'm going to need the host port and password in order to connect to redish and then the full reddish URL which is a combination of the three if you want to connect to redus through Lang chain and we want to do that here to use a hosted version of Reddit like I'm doing here just head over to reddit.com and sign up there a free tier and it's really easy to get started if you want to connect to reddis outside of L chain you can use reddish Pi so here I'm going to import reddis and then I'm connecting to reddis directly through redis py using the host port and password and once the connection has been established I can ping it to see that I actually have a connection and then I'm just going to flush the database to make sure it's empty next next up we're going to need some embeddings and I'm going to use hugging face embeddings since they are free so you'll need to pip install sentence Transformers I already did that here and then you can import hugging face embeddings from Lang chain embeddings and instantiate the embeddings it's going to take a few seconds to import this and when you're done you are ready to load the data to reddis I'm going to import Lang Chain's interface to redus because I want to load the vector data with Lang chain but I could also have done this manually using R pi and again I have an entire video covering that so just head over to the YouTube channel it should be easy to find so to load the vector data to radus we'll use the from documents method that's built into Lang chain Rus interface and as arguments we're going to pass in the list of documents with the chunks of text the embeddings the hugging phas embeddings and the reddish URL and then we're going to give it an index name let's call it YouTube and under the hood Lang chain is using the hogging face embeddings to create numeric vectors out of the text chunks and then load that to the vector database and once we have the data in the vector store we can set up the Retriever and again we use Lang chains radius object and we just call the method s Retriever with a search type and some keyword arguments and now we actually set up to do Vector similarity search over the documents in redish and just like we do with chains if we want to call the retriever we invoke it with a quiry and here we get all the chunks of data that are related in some way to data analysis and this list will contain exactly 10 documents as that's the parameter I set in the search keyword arguments so now we have a retriever and from here it's pretty easy to build a rack chain now let's move on to Rack retrieval augmented generation what is rack so rack is a technique for augmenting at l m knowledge with external data and a rag application is built in two steps the first one is indexing the external data that's what we did in the last section and in the second step we retrieve and generate the output with the llm so you already saw how the first step works we take some documents we chunk them up we turn them into numeric vectors and then we Lo them to a Victor database like reddish and the second step we retrieve and generate so the user query is used to fetch the context from the vector store and then that context is sent to the llm along side with the query itself and this gives the llm what it needs to generate a contextual output in a moment I'm going to show you how to build a rack chain and Lang chain using the retriever we just set up in the last section but before I do that I quickly want to make a comment on something I've noticed that a lot of AI practitioners have been thinking about do we really need to worry about this can we abstract away retrieval when we build chat Bots and rag applications if you're familiar with the OM assistance API you'll know that a lot of this is abstracted away when you build assistance that will do retrieval from a file and on the surface it looks like openi just removed a huge headache and made it a lot easier to build rag applications without having to worry about building retrievers but there is nothing simple about serving the right context to an llm based chatbot so if you're trying to build a chatbot that will convert customers for instance you're really facing a search problem and you generally have two metrics that you want to optimize precision and recall recall measures the completeness of the search results so how many of the relevant documents are we actually fetching and stuffing into the context window and precision measures the quality of the batch we are retrieving so the density of the relevant search results and in order to optimize the conversion rates in the chatbot you need both of these metrics and to do that you need control over the retrieval process which you don't have if you abstract away the retriever so just think about how many businesses are currently doing C conversion rate optimization on web pages and as more and more businesses are implementing chatbots and chat-based interfaces a lot of the C work is going to be focused on optimizing retrievers so I wouldn't bet on abstracting away retrievers at least not in the long run now let's build a rag chain using our reddish based retriever for this example I'm going to use a chat promp template and I'm injecting a context and the users's question into the template then I'm going to use a string output passer that allows me to extract the text output from the llm to set up the chain I'm going to use Lang chain expression language and in the first I'm extracting the question from the input data using the Lambda function and then passing the question to the retriever to get the context so the context here is a composition of two elements and then I also need to pass the question itself to the LM and I do that in the second line and then I use the pipe operator to assemble the entire chain consisting of the first dictionary The Prompt the llm and the string output passer and that's it now we have a rag chain we can then invoke the chain to get an answer to the question what can we do with llama 3 and this answer will then be based on the context which is given by the documents fetched by the retriever moving on to tools so what is a tool what is a toolkit and how do we use a tool tools and Lang chain are interfaces that agents chains or llms can use to interact with the world and I think a good way to think about tools is that just like humans need tools to perform tasks llms need tools as well for instance if you want to do some complex calculation that you can't do in your head you would need a tool for that a calculator or a computer program and similarly for the llm to be able to perform a task it will need access to computational resources or additional data in Lang chain you have several built-in tools you have the python Rebel tool you have a Wikipedia Tool YouTube Tool Saia tool and gradi Tool and so on and more and more tools are constantly being developed Lang chain also has built-in tool kits that are essentially collections of tools that are designed to be used to solve a specific task and examples of toolkits includes the air toolkit GitHub toolkit G lab toolkit and so on and just like tools the number of tool kits available for Lang chain is ever increasing so how do we use a tool and there are essentially two direct ways we can use a tool one is that we can directly run the tool with a query and just like loaders this will typically return some data or we can bind the tools to an llm and then we get an llm with access to tools that we can use in Chains and agents now let me show you how to do that by building on our YouTube example here in the notebook I'm going to pip install YouTube search and then I'm going to import YouTube search tool from Lang chain Community tools and the YouTube search tool allows me to search for YouTube videos so I'll in State the tool and then I can run the tool with the query rabid metric and as you can see this is going to return a list of videos which are videos from my YouTube channel now I can take this tool and I can bind it to the llm and then I get an llm with tools and now I can invoke the llm with tools with a query if I do that you can see that I get an AI message with some search arguments I can extract tool calls and that will give me a clear overview of the arguments and these are the arguments that you need to pass to the YouTube Tool now I can use a Lambda function to extract the arguments and then I can compose a chain consisting of my llm with tools the Lambda function and my YouTube Tool and this allows me to invoke the chain with random queres about YouTube videos so if I ask find some rabid Metric videos on Lang chain you can see that the chain is now returning me the list of YouTube videos so this is not much different than just running the search but there is now some llm based reasoning behind the crew and this is going to be more interesting once we start building agents finally let's talk about agents I'm going to to explain what an agent is and then we're going to build a YouTube summary agent what are agents so agents are programs capable of reasoning and Performing tasks by integrating llms with tools and they do so by leveraging the lm's capability to generate Json or other structured output this would be a very general definition of the concept in Lang chain agents have a very specific meaning in Lang chain an agent is a class that uses an llm to choose a sequence of actions to take the main conceptual difference between an agent and a chain is that in a chain the sequence of actions are hardcoded whereas in an agent we let the LM decide on what actions to take and what tools to use so think of the chain as a fixed sequence of steps whereas the agent might loop back and use the llm to decide on using a new tool and take a new action and this will go on until the llm decides that the task is completed in theory the agents are more flexible and robust than the chains however we also know that LMS can hallucinate so it depends on the use case now let's build an agent out of our YouTube use case after pip installed Lang chain hop I'm going to use that to extract a pre-made prompt and I'm going to import hop from Lang chain I'm going to import agent executor from Lang chain agents and create tool calling agent from Lang chain agents and the pre-made prom I'm going to use is available on the Hub and there you can see the template that's being used and then there's a variable Called Agent scratch pad and the agent scratch Pad is an important variable it is where the agent will save its intermediary steps but this prompt is ready to use along with our YouTube Tool and the llm and these are the only three things we need to create the agent so I'm going to pass the llm the tools the prompt to create tool calling agent and then I'll set up the agent executor and just like we did with the chains I can now invoke the agent executor and I'm going to ask the agent to find some Lang chain YouTube videos and here we see the list that it extracts with the tool and then it ranks the videos and finishes the chain and if we try to click on the first video we see that it gets Lang chain expained in 13 minutes by rabid metric what a brilliant agent now the cool thing about an agent is that we can just give it access to multiple tools and it will figure out on its own how to use the tools I'm now going to create a custom transcribe video tool using the tool decorator and the YouTube loader we used in section two and this tool will take a video URL and return the transcript of the video as a document then I'm going to create a list of tools with two tools the YouTube search tool which just used and the transcribe video tool and of course you need to have both YouTube search and the YouTube transcript API pip installed to do this and now we can invoke the agent executor and ask what topics the rabbit metric YouTube channel covers the YouTube agent will now use both tools add its disposal to give me a summary of the topics covered on the channel and here we have the final output with the summary of the topics covered all right that's it for now if you want to dive deeper into Lang chain I suggest you go check out some of the more advanced tutorials on the channel and if you enjoyed this tutorial and want to follow along for more content like this give it a like And subscribe thanks for watching

Original Description

In this tutorial, I will teach you LangChain as efficiently as possible by breaking down the framework into seven key components you need to understand to start developing more advanced LLM applications. Link to written tutorial with code and interactive map: https://www.rabbitmetrics.com/langchain-in-7-easy-steps/ ▬▬▬▬▬▬ V I D E O C H A P T E R S & T I M E S T A M P S ▬▬▬▬▬▬ 1:14 LangChain Overview & QuickStart 8:43 Chains, Prompts & Loaders 15:00 LangChain Expression Language & Runnables 23:22 Splitters & Retrievers 29:45 Building a RAG Chain 33:53 Tools & Toolkits 37:20 Building Agents with Tool Access
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

This tutorial teaches the basics of LangChain, including setting up a chain, using prompt templates, and creating agents, and provides hands-on experience with building LLM applications.

Key Takeaways
  1. Install LangChain and required libraries
  2. Set up a chain using the pipe operator
  3. Use prompt templates to craft effective prompts
  4. Create agents using the tool decorator
  5. Invoke the agent executor and ask the agent to perform a task
💡 LangChain provides a simple and intuitive API for chaining together different components, making it easy to build complex LLM applications.

Related Reads

Chapters (7)

1:14 LangChain Overview & QuickStart
8:43 Chains, Prompts & Loaders
15:00 LangChain Expression Language & Runnables
23:22 Splitters & Retrievers
29:45 Building a RAG Chain
33:53 Tools & Toolkits
37:20 Building Agents with Tool Access
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →