Summarize the following. Use a bulleted list for all key point. Do not include introductory material. If code is explained, use speech to text and extract the code into a code block. If you can Identify what models, tokenizers, embeddings or other files mentioned, create a list in the footer.
Title: “🦜🔗 LangChain Components | Beginner’s Guide | 2023”
Transcript: “and welcome back to data science Basics this is the continuation video of land change series I have already covered the video about introduction to Langston some quick start videos as well as some use cases and now let’s go through the components part as you can see here I already covered the introduction and the components part I asked for my viewers if they want to have the video of different components separately or in one video and they want it to be on one video so this is going to be a long video where I will cover all the main components of Lang chat so after watching this video you will know the main components of Lang chain as I said the video will be quite long but I will place the time stamps for each component so feel free to jump into different components as you watch the video now without further Ado let’s get it going okay just the basic things before I get it going The Notebook will be provided to you and the link to the GitHub will be in the description box this is the table of contents for this video there will be a long things what I will be covering here but I will provide each and every piece or the documentation for each and every component as well as the sub components while I go through the notebook so feel free to click on the links and get the documentation for more information yeah now let’s start first thing first if you don’t know what is Langston this is a framework for developing applications powered by language models I recommend you to watch my previous video videos where I have explained in depth about what it length Chained and the quick starter guide yeah that is what in higher level what is line chain first thing first we need to set up the environment if I just click this here we need to First install the required libraries that is open Ai and Link Chain I have already done this run this command and you need to get the open AI API key the link is provided here if you just click this it will take you to the API key space first you need to create the account and then create the API key and just paste the API key in this place here then you are good to go now let’s go and see the first component as I said I will provide the link so just feel free to click the link and it will take you to the official documentation of link chain but what is schema in high level it’s just the basic data types and schemas so notes and bolts of working with large language models you will know what it is after I went through this specific part so there are different sub components of schema so there is the text when working with large language models the text goes in and the text come out right it’s the natural way to interact with the large language models what is here inside the text the text is this is line chain so that is how the text is right we can just run this that is it that’s nothing specific in this case and now there is chat messages what is chat message similar to text but with more of a message type there are system chat messages there are human chat messages there are AI chat messages and all these things we need to import those class from the Lang chain and the name is quite obvious here langsen dot chat models you need to import or chat open Ai and land chain dot schema we have human message system message and AI message the name is quite self-explanatory here so we just need to import that and there is just example here we need to initialize the chat open AI right here I’m just initializing this chat open Ai and the open AI API key is taken from what we just provided up here so that is how it works and or if you want to have more specific you can just comma and then if you type here open then it will suggest you to provide the open AI API key then you can provide it but we already have on the previous sale so we don’t actually need to provide that just not to have a confusion like where is the open AI API key provided right so the next thing is we need to provide the human message ins for the chat right so here is translate this sentence from English to French I love programming if I just run this and then it will translate to French yeah I don’t know this but if I say from English to Nepali because I know what is Nepali Language and here it says mobile programming one person and that is the correct translation yeah that is how it works and you can even pass the multiple messages as it is shown here and if I just run this command yeah it will show different things but you can just provide any languages or any other task for this particular chart and then you can even provide the batch messages as I said as it’s shown here there is two different things provided and then it will go through the batch messages if you just run this then it will provide the answer yeah that is how the chat meshes works right now there is another sub component of schema called the examples so it is actually self-explanatory here examples are input output pairs that represent inputs to a function and then executed the output so they can be used in both training and evaluation of the models so that is not that specific examples I need to provide here but if you want to go around here is the thing what is examples or you can refer to the official documentation now there is documents that is the another sub-component inside the schema what is documents that’s the piece of on structured data right holds the page content and metadata so I will show you what that means here but as we progress through the notebook you will get the idea okay what is piece what is space content and what is metadata because when we start working with the documents this comes as we go but just for you to understand here from langchain dot schema we need to import the document if I import this then I can just pass the document and here is the document class and I just say space content and I says okay the content of the data and the metadata as I said so you can just pass anything here so document ID document create time or if you have other different metadata that you want to provide for this specific document you can provide here and if you just run this it will just print that so that is how the schemas work because as I said this is the lots and volts of the large language model or line chain so that all of these things will come when we start working with different components of line chain let’s go through the next component and that is models as the name actually suggests itself different types of models that we use in the Lang chain right so first let’s go through the language model if you just click here what is language model it’s the model which takes text as an input and returns text as an output so here from langchain. lms I’m importing the open AI and here is just llm equals to open Ai and I’m passing the modal GPT 3.5 turbo and the temperature 0 and now I am just asking what no more comes after 2 into that large language model so if I run this it will say the answer the number that comes after 2 is 3 right by the way you are not just restricted with one model and here actually I am providing open Ai and GPT 3. 5 turbo but there are actually many models in the open ai’s in point so if you just click this link it takes you to the model in point compatibility so here I was actually using the GPT 3.5 turbo and for the not for the chart models right I’m using for the normal completion kind of things so it depends what kind of model you want to use in what kind of scenari use so that you get the best answer out of it now let’s go back to the notebook and here I am just saying now llm DaVinci an open AI model name takes DaVinci and I’m just initializing the model and now I’m asking the same question and what number comes after 2 and it says 3 but you get the idea that we can use different models from open AI but some of the model goes with the chat completion kind of things and some of them goes with the completions kind of things so in llm also there are actually open Ai and they chat open AI two different kind of models right so you need to be careful when choosing the model based on your use case so that you get the best result out of it and now let’s go with the chart models so that is another soft component inside the models a chat model takes a list of chat messages as an input and returns or chat message that’s simple difference here so from the Lang chain chart models we take the chat open Ai and again there is human message system message AI message and we can just initialize the chat open Ai and if I pass now instead of just text I just pass the content as a human message so here I says translate this smaller programming one person it works it is similar to what I showed you before but the different way of initializing the models right we could use multiple messages or batch messages as I showed you before I’m not going through all that again but you get the idea now there is text embedding models what is embedding or text embedding model takes the piece of text as an input and numerical representation of that text in the form of least or floats May patient doesn’t understand the E strings or the text right it needs to be converted to numbers or vectors right so that is when the embeddings come into action here I said text converted to Vector for May seems to understand right in simple terms from Lang chain dot in weddings we can have open AI embeddings as well as the hogging phase embeddings just to show you that it’s not necessary that we need to use the open AI embeddings I will show you one example from hogging fish why I am doing this is because open AI embeddings will cost you some money but hugging face is free and if I go and see here hogging face if I just run this command here embedding sogging face it does not work by default because we haven’t installed the packages just to show you that you need to install packages I have set up the notebook in this way the error message is quite self-explanatory again it says that we need to install the sentence Transformers yeah let’s install the sentence Transformer because hugging face embeddings use the sentence Transformer behind the scenes now I am installing the sentence Transformer and once that is installed and if we now again run the same command that I run before let’s wait when that is installed and by the way if you are thinking what is this capture this capture actually captures all the output when we install with Pip so that it is not displayed on the screen when it is doing the installation and now I can run the command and now it should work because we have the sentence Transformers let’s wait it is still loading and now we will have the hogging fish yeah as you see here it is actually downloading those hugging face embeddings right oh yeah it is downloaded and now we can just pass the text this is test document to check the embeddings if I pass the test and now embeddings dot embed query right and we need to pass the text that’s great and if I just run this command here yeah hugging face has 768 embeddings so invading’s length is that and the example if you want to know what is embeddings because as I said it is a float and here there are the different numbers representation meaning that this is a test document to check the embeddings is being translated from text to the vectors so that machines can understand that particular text that is what embeddings is this is the key part in working with the large language models and you need to know what is embeddings that is that’s why I’m explaining you step by step here and now let’s go and see the example of open AI meetings now and now I can just download the Open AI embeddings or initialize here because I already downloaded open AI on the First Command right now I just say text open Ai embeddings and I just pass the same text this text for the open AI embeddings dot embed query and then if I pass this text it will go through and if I run the same command here you can see there is 1536 embedding length and this is the example of the float or the vectors whatever you call it that holds that particular text as you can see the based on the different embeddings there are different embedding length and of course the embedding vectors will be also based on that particular embeddings yeah that is how it works it’s not that hard but you need to know how language chain components work so and this is all about the models part next let’s go through the prompts component in simple term what is prompt it is the input to the modem right whatever goes into the model that is called the prompt before we just pass in the form of text but now that text is provided to the prompt and the prompt is passed to the last language model that is just the different way of passing things into the model so let’s go through the prompt template so here there is nothing from langchain. lms I am importing the open Ai and the next one is I am initializing the model llm because to open Ai and there is the prompt what comes after two right and now I am passing that value to the last language model and it says 3 so that is why we did V4 but here in a more organized way as a prompt now let’s go and see the next sub component of prompts that is prompt template which is a better way of prompting that’s just the normal thing contains or text string similar to the F string of python if you are familiar with python I hope you are because you are watching this video which is all about Python and what it is and as for just the sake of Simplicity here is the example how F strings works you name the variable and you pass that variable in the F strings in the quarterly brackets now it prints hello sudarshan because it takes the name as a variable and we just pass here similar to that in prom template here from langchain. lms we import open Ai and the prompt template and we import that and this is how it works you just create a template and use just say something here I want ”
– This is a transcript of a video tutorial on the components of LangChain, a framework for developing applications powered by language models.
– The video covers the introduction to LangChain, installation of required libraries, and obtaining the OpenAI API key.
– The components covered include schema, which deals with data types and schemas for working with language models.
– The different sub-components of schema are text, chat messages, examples, and documents.
– The models component covers different types of models used in LangChain, such as language models, chat models, and text embedding models.
– Language models take text as input and return text as output.
– Chat models take a list of chat messages as input and return a chat message.
– Text embedding models convert text into numerical representations (embeddings).
– Prompting is explained as the input to the model, and prompt templates are introduced as a better way of structuring prompts.
– Code examples are provided throughout the transcript, demonstrating the usage of different components.
[List of Files/Models mentioned]:
– LangChain
– OpenAI API key
– OpenAI GPT-3.5 Turbo model
– Hugging Face embeddings
– Sentence Transformers