Back to Index

OpenAI GPT 3.5 AI assistant with Langchain + Pinecone #1


Chapters

0:0 Building an AI assistant with GPT 3.5
1:43 AI assistant overview (langchain etc)
3:44 Asking some questions on arXiv
11:3 Rest of the idea (understand YT, articles)
13:30 What will the AI assistant look like?
16:10 Next video: scraping arxiv

Transcript

Okay so I'm going to share something that I've been working on for the last few days and it's going to take, I think, quite a few more days for this to progress into something that is in a more showable state but I wanted to kind of share that progress and I think it makes sense for us to walk through the steps of building it as they are built.

So the idea is something that I've actually, I think, wanted to build since I kind of came into the space of NLP and machine learning and in fact I think it's one of the main reasons I even got interested in NLP in the first place which is actually trying to build some kind of AI assistant and I don't mean the AI assistant like Siri or Alexa because honestly I don't think they're that useful like okay it's cool because you can speak and the lights will turn on or a certain song will play, that's great, but it's not actually helping me do things in my daily life that I, you know, personally would think of as productive.

So what I've always wanted to build is an AI assistant that can actually do that but unfortunately it's always been kind of out of reach to do anything like this, that is until very recently with the release of these crazy AI models we've seen CheckGPT, obviously GPT-3 for quite a while, we have long-term memory, we have essentially all of these different components are kind of coming into place where we're now at the stage that we can build an AI assistant that is actually useful and it shouldn't be too difficult to actually do it either.

So the idea I have so far is what you can see here, so I want to obviously build this personal chatbot, I think it's better to call it an AI assistant than chatbot because that's kind of like one component of it and the first thing that I'm going to work on is can it help me with like researching papers from archive.

So this will be an incredibly helpful thing because I spend a lot of my time just kind of like reading things and trying to research things and you know what I always find is that I end up going down like a rabbit hole of papers, like there's this paper and to understand what it's talking about I need to go and read another paper and then to understand that I need to go and read another paper and that's fine but I think it would be so useful to actually just be able to ask a question in like a chat or in like a search bar or something and get a answer that kind of takes all of these relevant parts of the research and summarizes it to me and also tells me where that's from so I can read into it more.

So that would be incredibly useful and that's my main focus right now actually building this part of it and to some degree it's kind of there so let me just show you what we have so far with that. Okay so we're going to start with a couple of questions I've already asked and this is just in a notebook at the moment so there's a ton of code that I've just run in order to get to this point and then we'll just see a couple of questions just so you can get a feel for what the idea behind this might look like when it is more kind of fleshed out.

So right now what we're working with is a very small portion of data set and of course this is not really in a chatbot like format it only has the archive data in there it can't really do that much right now. This is really like the first component of the idea of an AI assistant.

So yeah let's take a look. Okay so now I'm asking something that is kind of in there what is the latest research on reasoning and acting in language models? So if I come down we get this paper here towards reasoning in large language models a survey it does straight away like a very it seems like a very useful paper but this is quite a lot of text maybe I don't want to read all this it's not in the best format either.

So what we can do is put them all together and feed them through an OpenAI completion endpoint so doing text of entry 003 so we come down here and then this is asking the question now and this does take a little bit of time because I have a lot of information going into the large language model and small amount coming out but it's you know all of that together is considered by the large language model and based on how much we have it's going to take longer or less time.

So the latest research on reasoning and acting in language models includes techniques for improving and eliciting reasoning in these models. So this is I think probably referring to things like chain of thought which is true methods and benchmarks for evaluating reasoning abilities findings implications previous research in the fields and suggestions future.

So it's an okay review but it's not very specific. So I kind of figured it probably doesn't have that much specific information on this topic in there at the moment because there isn't much I think I got like a month's worth of papers in there which is not necessarily that much.

So run this and what we're going to do is ask this so what is the term that describes how large language models seem to exhibit reasoning abilities when they get to a certain size. All right this is something you know the answer to and it will hopefully give it us.

Okay so emergent behavior that is correct so essentially this is the idea that large language models you keep increasing the size of them and once you get to a certain size it's like they can all of a sudden just do this new thing right. So kind of like what we're doing here once the GPT models got to a certain size all of a sudden they could answer questions very easily and they could do like named entity extraction just by you know telling them to within the prompt and all these like crazy things that just kind of seem to emerge out of nowhere all of a sudden even though they were not necessarily fine-tuned to do that in the first place.

So that's pretty cool and then okay let's try this. Tell me about the idea behind immersion abilities in large language models. Let's run this. Okay cool so took quite a while and that's definitely something you need to work on but okay tell me about the idea behind these immersion abilities and it says okay emergent abilities of language models is a concept that larger models are more proficient at meta learning than smaller models and can acquire abilities that are not present in their smaller models which is true.

This includes tasks such as few-shot prompting which is the idea that you can give a few examples within your prompt and the model will learn how to do something based purely on that. A transliteration from the international phonetic alphabet. Now I don't know whether that's true or not this is the point where you'd like okay let's take a look at these papers and see what they say.

Recovering a word from its scrambled letters and Persian question answering. Now recovering word from scrambled letters I'm pretty sure I've seen that Persian question answering now I have no idea but it would not surprise me it seems pretty realistic. Furthermore large language models can be trained with more data which can potentially lead to miscorrelation between different modalities so I'm not entirely sure what that means but you know again we have these papers in there so we can read into it which is pretty cool.

To mitigate the risks associated with immersion abilities researchers urge to develop up-to-date benchmarks to measure unforeseen behaviors in their large language models. So this is something that people keep talking about it's like okay we have all these benchmarks have been created pretty quickly but then the models are kind of saturating these benchmarks almost as soon as they are made like they just become irrelevant because the models are just so far beyond these benchmarks so quickly.

So that's definitely like an important thing right now. And then final question or final serious question is what are chain of thoughts in large language models so this is kind of like a prompting technique hopefully it will explain it a little better than I can. So chain of thoughts are a technique used to enable complex reasoning and generate explanation with large language models by forcing them to explicitly verbalize their reasoning steps as natural language.

So this is kind of like you ask it a question and what it's going to do is first it's going to kind of say okay this is your question this is the first step I'm going to take in order to find the answer to your question and based on that first step it's going to move on to the next step right and then the next step and then it will come to your answer.

So this is kind of a very human way of going about things when we are trying to answer a question we will usually go through it step by step in our heads and this is essentially what we're getting the models to do here as well and it works very well for just improving the performance or the question answering abilities of these models.

So it's really cool and this method has improved performance on a variety of tasks and sparked the active development of further refinements which is true there are kind of further advances on that one of those is the React thing that I mentioned earlier so yeah this is kind of getting there like the data set I have behind this is very small it's not even that relevant to what I'm wanting to do and I'll kind of discuss that a little more in a moment and yeah it's already doing relatively well which I think is pretty cool and then I wanted to test so can you tell me why zebras are stripy I kind of tried to force it to not answer questions that are not answerable by whatever you have within the data being given so I asked if the question cannot be answered using the information in the context answer I don't know so usually or at least some of the time when you do this it will say I don't know if it doesn't see the answer in the context but I've only had that work so far with smaller context where we're feeding quite a lot into here so I think I need to kind of figure out this prompt a bit better because when I last tried this it didn't work so come down yeah so like it does actually give you the answer and I also checked in these papers to make sure that they don't actually tell you why zebras are stripy inside them and they didn't it is kind of just making this up not making this up it knows this within the model weights but it doesn't know it from the source knowledge which is the context that we try to provide here so this is just something that I will be testing and hopefully at some point I can get it so it will say I don't know even for a really obvious question because I don't want it to be outputting false information now that is you know the idea of what we have so far so the archive part of it what we'll do is very quickly go through the rest of it and then I'll probably leave it there and we'll go through some of the data pre-processing stuff that I did in the next video right so I wanted to be able to make good writing suggestions so a lot of my work is writing articles so that would be insanely useful if I can get good writing suggestions on these niche topics because I've tried with like gpt and gpt3 and when it comes to kind of like technical topics it doesn't really do very well it can help a little bit with like ideation on kind of getting out of I want to say writer's block but beyond that it's not actually that useful so it would be really good to get good suggestions on these more technical topics I would really like this if we do go for like a chatbot type thing to be able to talk well like chat gpt can so I can like go through a multi-step process of answering questions I don't know how realistic that's going to be because the research behind chat gpt hasn't been released so you know there's no way of knowing how they how they did that unless so they will probably release a chat gpt endpoint at some point so you know maybe that will feature in this at a later date there are other data sources I'd like to include like youtube videos articles so a ton of the you know when I'm going through things and or building something I will end up kind of forgetting things over time that I did you know like years ago and what I will do very often is either you know find someone else who's explaining it or if I know that I've explained it in the past I'll go back to my old videos go back to my old articles and actually use them to kind of relearn because it's almost like I'm speaking to myself like it's just an older version of myself so the language I'm using is super easy for me to understand so I would like to be able to index all that stuff as well like just past things I've done and as well as kind of including that would be my notes like in this here I'm using obsidian which is like a note-taking app which I've just only just started using in the past week before then my notes are just kind of everywhere but if I continue using this and I have a lot of notes in here it'd be really good to index all of that code documentation so you know like lang chain it's a new library chatgpt doesn't know anything about it so you can't ask it questions about it it would be really good to like be able to put that in our long-term memory component and then actually we can answer questions about it like super quickly which will be amazing now what will it look like yeah this lang chain pinecone for storing all the archive papers and everything else so one thing I did want to mention this is right now what you just saw all the papers I got for that they've just kind of been brought in bulk from scraping the archive website and using the archive API and there was no intelligent logic behind that what I have started working on and it's kind of you know it's getting there is basically you give one paper and then it's going to work through that paper it's going to extract the references and then it's going to find the other papers that were mentioned in that paper and it's kind of like a graph or a tree that kind of expands out or branches out from that that would be really cool because I think then you can be a lot more specific on what you're indexing and not just kind of index the last 20 years of archive which would be insane so that would be really cool maybe you can do a bit of both though I will say like maybe some more recent papers you just kind of get them in and index them in bulk right the okay React framework is kind of what I mentioned before there's some notes here I didn't actually mean to press that so let's go back to here so this is basically okay your chatbot your AI system will be able to search the internet it will be able to use Python to answer questions and all of these kind of like cool crazy things that'll be really fun to try and then there's also the chain of thought thing so I haven't actually tested that yet I would like to so that is in there as well and then where are we at the moment we are still doing step one so it's where we are for now that's all I'm focusing on I think that would still take a little bit of time to build and it's definitely going to take a couple of videos to actually walk you through everything so you know we're going to be on this for a little while and then we'll move on to trying to make it into more of a chatbot we're going to have like the endpoint and a nice like web app like maybe I can use angular or something it's like the only framework I've ever used before I don't know if that's even relevant anymore but my idea actually here was to ask chatGPT to help me build that so that will be interesting to to try out let's see and then finally I want it to be in a super easy to use format so you can literally just like git clone it and use it for your own things so yeah that's where we are at the moment you know for this video I'm going to leave it there because there's a ton of code it's super messy but I will take you through it in the next video where we're going to focus on actually getting all these archive papers and we'll kind of explore both options there so we have like that graph method or we have just kind of like the dumb method of bulky downloading everything for now that's all for this video I hope it's been interesting I'm super excited to see where this project goes and it's already looks kind of promising so that'll be cool to see so thank you very much for watching and I will see you again in the next one bye bye.

you. you. you