You are expert at writing long form seminars on PhD level. Here is a early draft of…
- User
You are expert at writing long form seminars on PhD level. Here is a early draft of seminar on LangChain. Please improve it, structure it and keep writing in same style as original input. Please proved your answer in latex format. Launching is launching is a platform that allows users to create better applications that under the hood use alarms it's a framework that obstructs the communication with the LM into higher level abstraction to allow easier easier domain driven development and easier changes of underlying LMS and underlying mechanisms used it allows users to create create what are called chains which basically mean calling the LM in a sequential or manner also allows prompt management or how they call it prompt templates uh we which can generate uh which can generate prompts based on the user input or outputs of a previous steps of a program also it allows abstractions to memory management or for the labs meaning how to save a history of a chat conversation for example also it allows abstractions to the vector stores uh to uh to to make for example rack systems and at the end it allows agenting frameworks to work together saying all of that all of this uh launching uh provides a comprehensive suite of tools to easily develop Elm based applications uh first thing about the literal cover cover our jails and form templates both of these are just a very basic abstraction layer that allows switching of labs basically chains can be invoked by the user message and under the hood they will call LM which is specified in LLVM config prompts that are going to be passed to the LLM can be parameterized based on the user input over previous steps in the program and which can be manipulated or used for the appropriate purpose important here is to note that prompts are and general text is the way to communicate with LLVM expects text input and outputs text at the end and it has some sort of reasoning engine behind it but under the hood it all only generates or predicts the next token of its output and it's working only with a text not with some sort of a function or something like that all the mechanisms like tool calling for example you just allow him saying he I have access to this tool please use it without this inputs and give me the result of the output of the course so that we can on them run them manually umm the next when creating a chat with the LM as you're probably used to video ChatGPT you expect them to have a knowledge of a previous conversation so when you asked about for example uh whether uh in the uh New York today and then uh say uh how about tomorrow you should you expect that L knows that you talked about New York and that you want to have it uh weather prediction for tomorrow uh but LM's are stateless stateless and they only get input as a as a pure text and they don't save any state in in themselves which means that we need to provide a better prompt or better input to the element in this case we want to provide a history history consists of a series of user message and what are called AI messages basically output on the LMS and there is also a third type of message which is which is a system message which tells LLM in general how it should behave when talking about the chat history we have a task to somehow save all the inputs from the user and now previous inputs of the user and previous outputs of BLM and pass it to LLM itself this means that we need to have a programmatic way to to say this to store these results to be one of the important things here to keep in mind is that MLM's have a limited number of tokens that they can get as input they are now pretty large approximately around 300 uh pages of a book for example uh but still we need to the ways to control what is passed to the LM itself so there are a couple of mechanisms to how to how to deal with memory management inside the BLM input or LLM prompts first and foremost is the most basic uh type of the input which is just passing full history of our conversation to the LM itself it's called Uh uh puffing or no staffing buffer buffer OK which means which means that we just buffer or the messages from user and from LM inside some sort of array or vector and we pass everything to the uh to DL problem with the buffered memory is that it can at large and we are passing all the inputs which mean that we at some point may get for example overflow of tokens that can be passed through the hello I'm itself second type of memory which can be used is buffered windows or buffer window which is basically saving glass car key interactions between user and elham this limits the number of the what is that will be passed to the LM but this also has a hard cut out of the number of conversations me which means for example if K is low or if the conversation is along that L you will not have a full context of what is happening so for example if you ask about whether in different States and then we ask hey where was it sunny for example and key was very small like a tool it could not figure this out because this first message would be taken out of the context also talking about the limited limiting the number of tokens that are passed there is also talking buffer which basically instead of interactions limit number of tokens that are passed to the LM so for example we can say hey just passed last two 2000 tokens to align itself uh which or limits the token usage uh and this can have a very nice predictable cost measures because we are always sending at most for example 2000 tokens again same problems as a with a buffer you know we have a hard cut out at some point uh there is also summary memory uh so this summary memory is basically that for each prompt we do summary which in turn does mean that we need to call once more once more the BLM to summarize the conversation and we only passed this summary of our conversation to the LM plus the new input far off our user uh this umm ohh usually is a little bit excessive uh which involves a lot of calling of LM basically we have almost double amount of calls to the L in this case because we call it once with the user input and to get output and then with this output call it again to give us a summary of what has been said so far so we have a double double cost to the LM but uh what we are limiting here is uh probably the number of tokens that are sent because we will have only a short summary that we sent each time and this is where the saving could come up then 4th 5th summary there is a summary buffer uh summary buffer is a combination of a buffer and a summary basically we buffer last key conversation so this means that we have our newest conversations always uh ready and in full but uh all the conversation history is then summarized by the land itself so we again don't pass with the buffer everything or that with what we have with the buffer window or talking offer that we have a hard cut out and we don't have any information older than the car key interactions so we have a older context but it's now summarized and with labs it's pretty uh good that summarization so we will not lose uh any or not that much information in from previous conversations now we are getting into some more exotic base next type of memory is called entity no this is basically used when we need to keep track of for example different persons inside novel or something like that which can for example for each entity remember ohh what it said about for example uh Romeo or Juliet and has a tracking report of everything describing Romeo and Juliet basically it keeps a summary about entities inside the conversation uh next one is the knowledge graph uh we will go deeper into knowledge graphs uh later on uh in in the in the in the conversations because uh because uh uh knowledge graphs can be very very useful and we will have a deeper understanding of deeper understanding of that next one is vector stores vector stores we will go deep into this uh also in the uh into the vector stores are used in multiple parts of the LM framework and now we are talking about vector storage usability for memory management but there is also a vector stores used for the rack system which we'll cover later on so we will first talk about I'd like to have those themselves then vector stores that are used for memory management and later on for rack So what is a vector store vector store is basically a specialized database uh instead of having uh pairs of the for example ID's and some sort of data it stores data sort of in a vector format and then has associate associate data to this vector representations inside the element context this means that for example we can have a uh we have what are called embedding embeddings embeddings is basically uh output of the encoder part of the LLM model this means that LLM takes in an input then then it maps it into its uh end dimensional space for example it can be 512 dimensions which uh LM takes uh all its knowledge and maps it to this 512 dimensional space it's very hard for us humans to measure anything for more than 3 dimensions but if we go back to three dimensions it means for example that the 100 we have we can have for example uh course 11 can be colors 1 can be for example a different seating arrangement and then we can have a a vector of blue chair which would somehow combine blue and a chair on for example X&Y access and now pointing to an OK now we're talking 2 dimensional space but this is the point we have a very large dimensional space and all the inputs are now mapped into this N dimensional space by this is important because language map similar things to this similarity into into these spaces and this is how we get this compression of the whole Internet or something like that that that can now work from and basically maps all the inputs to these 512 dimensional space and this is called embeddings meaning that for any length of the input we will get as output 512 dimensional vector of numbers which represent um how LM sees this so for example if we talk about whether a nice weather or some sort of a different variation they will map to pretty much similar in these areas space or 512 dimensions but if you talk about for example soccer it will map it to different area of the this 512 dimensional space and but for example if it now talk about some sort of jersey or or uh ball it will map it to somewhere near this in in this large space OK So what we have so far is that we have now talk about beddings and we have said vector store basically maps some sort of number or vector to some sort of context how we combine these two is that we give LM input it gets and we get this embedding from the LLM and then we store this mapping of this input and embedding vector together inside the vector uh database is this cool because then what we can do is when we get a new input as I said it will embed similar inputs to the umm but yeah somewhere inside the neighborhood or the number of the embedding inside this large uh large space uh it will map it to similar in neighborhood meaning that if we now ask a question about the football I get it will point to somewhere in this neighborhood about football and then was you can say OK now back to store give me all the context that you have on football basically we give you this embedding and say hey we do a similarity search what you have in your database regarding this part of the embeddings embedding space and then the vectorial pool for example K last uh OK closest let's say neighbors to this newer bending that we are searching for and give it as a output what we can do this with in the context of a memory management is that if you have very large memory management very large large context what we can do is that we can uh all the prompts uh put inside the vector database with the appropriate medics and for example when we ask a new question we can do a bedding so this new question pool the key closest neighbor or this question that we ask so for example regarding football and we can pull all the context regarding the football uh uh from this previous conversations so OK closest and then give this as a history of a conversation well the question itself to the LM so it can have a context what has been said what are problems we'd like to store its latency and a customer cost problem because we need to call embeddings for everything which means one more to call to LM basically and also you need to host it somewhere takes up space and um infrastructure costs latency problem because we need to do a similarity search similarity search in this context is always a cosine is almost usually cosine of symmetry hmm and with this cosine symmetry takes time to compare and it's I think it's a linear because it needs to search everywhere to and get this key courses 1 so it takes some time especially database is very large so this is where we get our like this problem because we have this extra step of calling the database and getting the K closest embeddings to the new question pulling them out and then pulling them instead of having these context already ready ready for us.
- Assistant