Build More Powerful LLM Applications for Business’s with LangChain (Beginners Guide)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on guys this is Dean here uh this is a tutorial on Lane chain um and how you can essentially use this framework to build very powerful applications on top of the language learning models that we love and use today this helps solve a lot of the limitations that are associated with the language models such as gpt3 and gpt4 but my kind of whole goal with this is to um you know to have you guys not only understand the concepts of how you can use a tool like this to create applications but also provide you guys some very specific use cases to get your juices flowing Lane chain is essentially a tool a framework that that's built you know that's powered by language models that not only connects your language models to other sources of data becoming more data aware but also can um interact with its environment a lot more be agentic is the term that they use and I think the combination of these two is very very very powerful there's a whole lot of use cases that are that come with this and um the whole kind of idea with Lane chain is they're trying to essentially abstract all of this make it very easier for developers like me who um you know don't have you know too much of an understanding of very low level Concepts to just come in and create again powerful applications that are leveraged by these language models and another thing to mention is that I'm actually actively working with a company local here to implement something like this into their current existing operation and I think that's important to mention because it's one thing to you know preach from a textbook but it's another to actively work on a project you know be involved deep in the trenches understanding their current systems their you know their softwares they use and essentially connect the dots together and that's why I mean that's kind of my whole goal with this video is you know this technology is obviously available to all of us but it's real it's more so of what you can make of it right what you know current industry are you in and how can you essentially leverage um your knowledge of this to connect the dots and create something that can be very valuable to a company ultimately helping increase their revenue which is the bottom line so yeah guys let's get into this um before we actually get into really what Lane change is I would like to go over kind of some of the very current limitations of llms so again such as gpt3 and gpt4 and I've highlighted them here and they do kind of all relate to one another but they are not very scalable it's difficult to tie actions to them pricing becomes a factor you can't really build complex workflows and it's hard to kind of interact with its its environments and again these are going to make a lot more sense kind of as we get into it but I would like to show you here um you know obviously say we wanted to use the um you know the annual reports that Apple provides its investors right so this is an 80 page document and traditionally with um it's the current language models out they're only trained first of all up until about I think middle of 2021 but second of all um you know as far as from a um you can't even you know you wouldn't even be able to use this data as um you know there's 80 PDF pages and that goes above um the token limit so I mean we can just go ahead and test that right now so if we were to essentially um you know copy let's say probably um I'd say 20 Pages just 20 Pages out of the 80 that they provide us and we come into the tokenizer we can actually you know paste it in and you can already see let me just refresh this you can already see that we are above the 8 000 token limits so we essentially wouldn't be able to even you know use any of this data unless obviously we kind of split it up but that kind of goes against the whole idea of this because you know obviously then you would have to use only just certain paragraphs but how do you know if you're not leaving other context out there's a lot of manual intervention associated with this so it just doesn't make sense and that's kind of um again one of the things that Lang chain um helps us resolve with with the use of embeddings and semantic search and open AI does this as well again but this idea of link chain is just the abstraction it makes it a whole lot easier for developers to build these very powerful applications example let's say we wanted to develop a um you know a lead generation application for a dealership right this could be a very big dealership a local one down the street whatever let's say we want to essentially develop a customer facing chat bot this is kind of how I see a customer would able to come in and ask hey I'm looking for a car that's so and so um is this something that you guys have in your inventory and it would essentially give that response and also maybe even schedule an appointment right so again I'm going to try and make this as simple as possible but obviously traditionally if we wanted to do this with the current models a it wouldn't even have access to this company sensitive information such as their inventory and B this would be a lot of data especially if we had the inventory of a bigger dealership such and give it more you know details about the description and whatnot so yeah guys essentially this is the workflow that would be provided with um this is how I would do it with Lane chain so essentially I kind of provided the use case of it so let's say in order to do that we would first need to provide it a you know inventory a you know Excel or a CSV spreadsheet of the um you know of the products that they house that the dealership houses so again this would be way too big of a PDF to just load into GPT so what we would need to do is first we would convert this into a readable text using some of the document loaders and then from this text we would essentially chunk it into different paragraphs if you will or just different sections so for example let's say um this inventory CSV it has everything all the models all of the descriptions the price of all the different um cars and we would essentially kind of split those um that inventory into different chunks and you know for example one of the chunks could be mid-sized sedans one of them could be trucks one of them could be sports cars to be honest it doesn't really matter all that matters really the concepts I'm trying to get around is we're just essentially splitting this very big CSV file into separate chunks um and then from there we essentially convert them into embeddings and then we store them in a vector store so you can just think of this as a database right so um I'm going to explain the concept of embeddings of of how vectors work really quick here but just know that we're essentially taking each one of these chunks converting them into a vector like this one shown here and then storing them in a database and now you're probably wondering you know what the hell is this um you know this vector or what is Vector and a vector this essentially allows our computer to understand um to help to understand what are these chunks exactly right what because to the computer it's just a ton of words it doesn't have any understanding of what these um you know what the vehicle models are what the descriptions are what the um you know what the prices are but essentially it converts them into a a one-dimensional array called a vector and from this Vector it's going to be able to compare it to what the user asks and provide the relevant data that's that that's needed so again this will make a lot more sense here I have a kind of simple concept of a two-dimensional relationship between these between a sedan a truck and an airplane I saw a lot of useful kind of what is it illustrations like this online I thought I would make something similar so you can see that um with the kind of three items that we have mapped here sitting in a truck and an airplane you can see that a sedan and a truck um are more similar to one another than an airplane that's down here you know they're all three vehicles um that can be manpowered and used petroleum but a normal keyword search wouldn't be able to distinguish the difference between a sedan and a truck because um you know it would say a normal keyword search like a basic keyword search it would just look for the characters that are in this word and compare them and you can obviously see between a sedan and a truck there's no keywords that or phrases that are similar between the two so technically a computer wouldn't even know the difference that's why we convert it to a vector and then we essentially use something called a cosine similarity and essentially you can see here the it's like the angle you can see it's shorter between the um sedan and the truck that means they're a lot more similar now this is just a two-dimensional relationship right we have an X and Y axis now with open AIS and beddings there's actually 1500 and 36 different dimensions which is just um you know mind-boggling to me so again if you don't fully understand this yet um it will make a lot more sense but essentially just understand that this semantic search that we did is a lot more um relevant a lot more foolproof than say something like a basic keyword search because then a computer wouldn't really know what the difference is between these three but obviously since we've converted it to a vector it can this these numbers it essentially knows the difference between the two so again this will make a lot more sense as we go through this so essentially once these vectors are stored in this you know database um all of these the vectors of each of these chunks so each one of these chunks is going to have you know different vectors associated with it and again these chunks are from the big inventory CSV that we gave it so now let's say a user asks a question which cars do you have in stock for a sedan that's great for the family great MPG rating and it's a newer model so it essentially it would take this user input here and it would create an embedding just like we did with the chunks right just like we did with the company data and it would create an embedding for this um you know search this user input now it would use that similarity search between these two um you know embeddings these two vectors and it would find now the computer would essentially know okay out of that big spreadsheet that we gave it um and what the user acts only use the relevant chunks that are associated with what the user asks and this is how the computer understands it so it just essentially Compares these two embeddings using similarity search which is just the cosine similarity again you don't really need to understand that but I thought it'd be important an important concept to learn so from that input it would only grab the two relevant chunks that are essentially associated with the user input is now it would create a new prompt so it would say which cars do you have in stock for a sedan that's great for family great MPG rating and then it would grab the two chunks that it pulled out that are most similar to what the user input is so for instance it would grab these records from the CSV Honda Accord Toyota Camry and the Sonata and along with this um whatever records are associated with that vehicle such as the description price Etc but now you I hope that this kind of concept is making a little bit more sense out of that big CSV that we handed it it's only grabbing the just relevant chunks um you know using this similarity search with the embeddings so now this is essentially that the prompt that we're going to plug in now to the large language model so again this is technically you could just uh go into chat GPT and do this but again this whole kind of this this is a lot more systemized um and and again now you can see how much more cost effective it is than say plugging in something like this or even if it's below the 8000 token limit it would still be a lot more expensive if you're doing this at scale so then again with this new prompt provided it gives us an answer so I'd say hey you know customer name so hey Jack we currently have these vehicles in stock at our location that might interest you it would give you the relevant cars and then maybe you would ask something like would you like to schedule an appointment to come check it out right so this is kind know the use of Agents again Lang chain we're just touching the surface of this there's a whole lot you can do which I'm still learning as well and it's completely mind-boggling to me but um this is essentially how we would develop a solution like this at scale that's also cost effective so again um kind of going past the current limitations of large large language models so I hope this kind of whole process makes sense um and again this is just kind of one of the tools that are associated or one of the components that are associated with Lang chains so you can see there's a whole lot more and again guys I really recommend you guys check out their documentation just read through it um even if you're not a developer I think it's still important just to learn this technology and again just kind of get your juices flowing of what's possible and what's not right and a whole lot is so we can see the different components and again I'm not going to get into each of them but um it's important to understand all of them and essentially from these different components you can essentially create a more uh complex chain I mentioned so a more complex workflow for example that we'll get into and then there's also agents which um that this is going to be the next example I provide but essentially they can um make decisions of what actions to take on behalf of the user or the language model so um it's pretty nuts how it does this it kind of has its own like logic and reasoning associated with it but again to better kind of understand this I want to provide another use case and we'll just stick with the dealership example here but essentially uh you know as you guys saw here an agent um essentially allows us to communicate with our external environment take actions and involve some decision making and um so an agent would essentially have a tool kit and um with a dealership example you can see for instance these may be some of the tools that are the agent has access to so say these service records of a dealership or the in-house CRM that the dealership uses or the company email integration right whatever companies or whatever email software they use to send out automated emails to customers potential customers or for a service appointment which we'll actually look into here so again this is this would be a kind of more complex chain but this is something that's definitely possible with langchain and this is kind of how a customer service or a customer agent interaction would go so and again I hope this makes a lot more sense as I go through this so for example the customer would say hey I bought a Jeep with you guys and I think my brakes are very squeaky the service representative this is the bot would say hey there um do you have an you know email address phone or vehicle then that was associated with your you know your vehicle um and then essentially it's just trying to collect data and we would say yes you know my email is you know provided here we would essentially extract that data and then the bot would have access to the um to not only the service records but also um let me add that here but also their in-house CRM so we can see here we're saying Hey Dean pleasure to hear from you again please give me a second while I quickly look into this so now the service representative you know the large language model is has access via the tools via the agent to access the company's service records as well as their in-house CRM so you can now see in our next response we're saying Hey Dean when you purchase your car it looks like the brake pads were almost out because it probably got this data from the um you know the service records right it looks like you need to replace you need replacement pads since you purchased your car less than 60 days ago we'll go ahead and give you a free replacement breaks one or available when are you available to come in and schedule an appointment and I know this sounds completely wildly like how the hell would it be able to you know come up with this reasoning and this logic to do all this but I assure you it is possible um but yeah essentially it would have access to this external information and it could take actions on behalf of um the model so it would know for example that you bought your car less than 60 days ago because it had access to the company's in-house CRM and then um because you bought it less than 60 days ago it's going to offer you a free replacement breaks because that's for example the company policy right this is something this is data that you would train it we're not train it this is data that you would load in to the language model and and then it also asks you to schedule an appointment so again we can see here in the next response the customer would say oh oh man thanks for letting me know I'm free this Thursday if that's available so from that response I gave it it would look again in these in the CRM or um in the service records and see okay this Thursday we have um you know spots available for 10 30. um so you can see our bot here it schedules it for 10 30 a.m this upcoming Thursday and it even sends for example an email confirmation out to the customer to confirm the appointment so again that's just another tool that it has access to the email integration and it would essentially send out a tool a service appointment confirmation giving a little bit more details about what they're coming in when and a confirmation for the customer to confirm so again guys all of this is possible now you can I hope by now you kind of understand a little bit more of what's possible and how powerful a abstraction framework like Lang chain is and again this is just kind of on the top of my head I was developing but something like this is possible and not only does this um and then guys there's so many benefits associated with this for a company because for example you know let's say there's two dealerships right one down the street and another one a few miles out and I would you know me being obviously kind of in you guys too watching those tech savvy people you would more you know you would most likely go with the dealership that has an integration like this um integrated into their current system because it's just so easy right because not only do you not even need to talk with a um you know service representative but you could essentially do this at whatever time you need to even when the agents aren't working and not only that it's just so much more of a streamlined process just from the email for example the language model would be able to not only grab this information but also have its own logic and reasoning um and you know like I said kind of with all the association with all these tools um the fact that it can do something like this is is nuts to me and not only will this save the company a lot of money but also it can streamline the process it can for example generate leads for the service records or for the um you know service department of a dealership during off business hours and you know customers would probably feel a lot more comfortable knowing that hey you know this dealership can for example look up all that specific information just from something like an email or maybe you know if you didn't shop there for example you'd have to provide it it's VIN number so it can you know look up this information and like a nationwide database if you will so yeah guys this is um again this is just one of the use cases that I thought of um but you know again all of this is possible with Lane chain and um I really recommend you guys check out their um their documentation just learn a little bit more about how everything is how all the kind of components come into play how to make more complex chains um different prompt selectors uh it gets pretty um you know I wouldn't say complex but um you know it it really frees up the abstraction really just allows you to build really whatever for your company whether this is something internal to your team or um you know or something that's more customer facing so so yeah guys um I hope you learned something from this let me know if you guys want more like high level videos like this with Concepts other use cases or you want more kind of technical videos of me actually coding something um you know coding a you know an application with Lang chain and um you know GPT four or three uh for example you know we could maybe do like a video series on this or whatnot um but my time is going to be pretty strapped up um as again like I said I'm actually implementing this into a business local to me into their current systems and operations and although I can't share too much information about that um you know I would like to kind of um you know maybe document uh my journey um you know and what I've learned um you know implementing this so so yeah guys um and along with this we are actually creating a kind of a no code and I say we my friend and I were actually Implement we're actually creating a no code software that can Implement um with a tool such as bubble.io and webflow so you can for example you know import company specific data whether it's Sops um you know just information related to products whatever it may be you can essentially Implement that and integrate that into a no code tool so you know almost extracting it even more but yeah guys if you guys are interested in this just let me know kind of what style of videos you want or maybe you know you kind of like this more high level overview of this that's perfect fun I really enjoy doing this um also uh we did I did just create a new Discord if you guys are interested in chatting with other you know developers that are building applications that leverage AI uh be sure to join the Discord down below I'll also be a lot more active in there to help answer any questions you guys you guys may have but yeah I hope you guys enjoyed this and I will see you in the next one
Info
Channel: Cerum AI
Views: 3,931
Rating: undefined out of 5
Keywords:
Id: sp3-WLKEcBg
Channel Id: undefined
Length: 25min 52sec (1552 seconds)
Published: Sun Apr 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.