back to indexChatting with ArXiv Research Papers — AI Assistant #3
Chapters
0:0 LangChain AI Assistant
0:40 New Arxiver bot in Python
6:0 Arxiver LangChain agent code
12:22 Adding new papers to the DB
00:00:00.000 |
Okay, so today we have an update on the AI Assistant project that we've been working on for a little while. 00:00:07.680 |
It's kind of been on the back burner for a while with everything else that's been going on, 00:00:13.200 |
but today I think it's probably the first exciting part of the tool that you can actually use. 00:00:20.640 |
And, well, let me just show you what it looks like. 00:00:23.840 |
So come over to Colab here, I just do the PIP install, the most recent version, so 0.5. 00:00:32.240 |
And then we set our environment variables, so that's just API keys that we need from OpenAI and Pinecone. 00:00:37.680 |
And then I come down to here and I initialize, so this is a new thing, this archiver bot, all right? 00:00:44.800 |
So initialize that, and this archiver is everything we need to begin interacting with the code library 00:00:52.080 |
that we've already built in the previous two videos. 00:00:56.000 |
So the downloading of papers and the search through those papers, 00:01:02.800 |
that can now, or that will be fully controlled through the chatbot. 00:01:07.120 |
At the moment, it's just a search that is implemented 00:01:10.240 |
and kind of in the progress of building the upload part of that as well. 00:01:15.760 |
So we can run this and this is a question that is kind of covered in one of the papers 00:01:21.920 |
that I have added, and it's, what is the general scientific consensus 00:01:29.280 |
So it's from this paper here on, it's not even a paper, 00:01:33.040 |
I think it's a chapter of a book on the evolution of intelligence. 00:01:36.080 |
Now, I noticed adding like a non, like AI, computer science article into the dataset, 00:01:44.400 |
that there are a few things with the library that doesn't quite work yet, 00:01:47.200 |
like references here are mostly not archive papers. 00:01:51.280 |
And I don't, there might not even be any archive papers in there. 00:01:54.160 |
So I need to figure out a better way of dealing with that 00:01:57.680 |
when we're doing like the propagation approach to finding all of the relevant papers. 00:02:03.440 |
And I'm not sure how well it's being processed, 00:02:06.960 |
like the chunks, maybe the size of chunks needs to be increased or decreased. 00:02:15.760 |
There's a scientific consensus that early hominids developed tool usage with Homo habilis, 00:02:24.800 |
Homo erectus showing evidence of enhanced intelligence with task-specific stone hand axes. 00:02:30.960 |
Okay. So, I mean, this is a pretty good answer, I think. 00:02:36.800 |
So I could ask chatGPT this, and it may or it may not give me a good answer. 00:02:41.840 |
I think on this sort of topic, it probably would give a decent answer, 00:02:44.960 |
but I don't know where that information is coming from. 00:02:47.280 |
And I don't want to just blindly rely on that. 00:02:49.600 |
Okay. Especially when you're doing actual research 00:02:52.000 |
and you need to source what you're talking about, right? 00:02:57.600 |
So I can click on here and it's going to take us to that paper that we saw before. 00:03:02.080 |
Okay. And we see it's the evolution of intelligence, which is from a book, I think. 00:03:09.200 |
Then, okay. Could you tell me about development tool usage in this context? 00:03:14.800 |
They have like the, we have some basic simple stone tools, 00:03:27.120 |
Maybe that's something we can try and improve. 00:03:29.760 |
But I think right now it's kind of a consequence of what is happening. 00:03:34.960 |
We're like, we're making multiple calls, open AI. 00:03:41.040 |
Even though we're using, in this case, we're using GPT-3.5 Turbo, 00:03:46.080 |
I mean, if you did this with GPT-4, it would take a very long time. 00:04:24.240 |
but because we have the chat history in there, 00:04:27.440 |
it knows to actually search for the Homo erectus hand axes, 00:04:31.200 |
because it can see the previous interactions that we had. 00:04:39.120 |
Okay. And let's see if there's something else that we can have. 00:04:44.320 |
So there's also evidence of great similarities 00:04:50.000 |
So what are the similarities between humans and great apes? 00:04:58.800 |
Okay. You can see again, it's creating the search term here. 00:05:06.000 |
And our answer is similarities between humans and great apes 00:05:11.520 |
which evolved as an adaption to forested environments 00:05:20.560 |
between humans and great apes and intelligent, 00:05:22.560 |
in intelligence and traditionally believed has been found 00:05:33.280 |
may have been potentiated as early as 12 to 14 million years ago. 00:05:43.440 |
So I think the point here is that we probably had like 00:05:52.240 |
the intelligence of humans was already well on its way 00:06:04.960 |
Let me talk a little bit more about where this is going. 00:06:10.640 |
So come over to, this is a new code that we have. 00:06:14.720 |
So this is like the chat interface thing that we're doing. 00:06:18.160 |
We're using line chain to create all of this. 00:06:23.040 |
So we have a couple of prompts that we're creating here. 00:06:42.480 |
This is when we start uploading documents via this function. 00:06:47.120 |
So that's something I'll talk about a little bit later. 00:06:51.440 |
So when we call this function, it just executes, right? 00:06:57.440 |
So let's have a look at how we actually create those. 00:07:01.120 |
So first we initialize a large language model. 00:07:11.200 |
And then we go on and we initialize our memory. 00:07:15.600 |
So this is one of the more complicated parts. 00:07:17.760 |
So the memory, we have this pine cone object, 00:07:25.120 |
Okay. So we have this pine cone class that we created. 00:07:41.040 |
and then we also have another version of it here. 00:07:45.360 |
This is like the first version that I wrote pretty quickly. 00:07:51.360 |
So this is a retrieval Q&A with sources chain from line chain. 00:07:55.200 |
So basically we're going to retrieve relevant documents, 00:07:58.160 |
and we're also going to include the sources in there. 00:08:02.000 |
I tried in these prompts to make sure that it's going to include 00:08:11.940 |
And then we come down here and we initialize a search tool, right? 00:08:18.880 |
There will be multiple tools that the agent can use. 00:08:24.640 |
which is where we're chatting with the agent, 00:08:26.960 |
and we want it to refer to these archive papers. 00:08:33.040 |
So it uses the search function, which is here. 00:08:38.820 |
This is basically just a custom version of the retrieval tool 00:08:48.240 |
The only difference is that we add in the sources 00:08:50.800 |
to the answer response or the answer value here, 00:08:54.240 |
because before it didn't seem to be using this, 00:08:58.160 |
because you basically get a answer value and a sources value. 00:09:02.480 |
It didn't seem to be considering the sources value in the final answer. 00:09:06.640 |
So I just forced them into the actual answer value here. 00:09:11.520 |
I'll probably make some other changes to that in the future, 00:09:19.120 |
So that's the search function that our tool uses. 00:09:24.160 |
We have a description, which is the search description here. 00:09:35.360 |
This should be the first option when looking for information. 00:09:40.320 |
you must always include all sources of information, right? 00:09:43.520 |
So again, sources of information, super important. 00:09:46.560 |
And then we append that tool to our tools list, right? 00:09:49.520 |
So then that's kind of ready to be used by our agent, okay? 00:10:06.640 |
I haven't really messed around so much with this at the moment, 00:10:09.120 |
but we use conversational buffer window memory. 00:10:11.440 |
So we keep basically a track of the last five interactions. 00:10:20.400 |
So we're using the chat conversational react description agent. 00:10:23.840 |
What that means is that it's for a trap model, 00:10:27.040 |
which is the GT 2.5 turbo model that we've initialized. 00:10:31.760 |
It's conversational, meaning there is this conversational memory 00:10:37.280 |
So it's not just looking at a single interaction. 00:10:44.640 |
The react is like a framework where you are basically saying, 00:10:49.920 |
I want you to reason about what action to take and then take the action, okay? 00:10:56.320 |
So the RE is reason and the act is action, okay? 00:11:06.000 |
base your decision on whether to use this agent on the agent description, 00:11:24.480 |
So we have this custom system message up here, okay? 00:11:28.880 |
Which is your expert summarizer and deliver technical information. 00:11:32.320 |
You make complex information incredibly simple to understand, 00:11:41.680 |
But one thing I did add that again is pretty important 00:11:44.720 |
is just really telling the agent again and again 00:11:48.880 |
to include a source of information at the end of responses, okay? 00:11:53.680 |
So I just like hammer that in as often as I can 00:11:57.520 |
just to make sure that it's actually doing that, okay? 00:12:08.400 |
And then the final bit that is in this initialization component 00:12:15.680 |
That is for later that I'm not using that right now, 00:12:22.400 |
And I kind of show you what that is going to look like. 00:12:26.880 |
we have basically the same code we saw before. 00:12:31.280 |
So I can like test the most recent version of the bot. 00:12:39.440 |
It's going to do the exact same thing, right? 00:12:43.840 |
It's not accessing the database at this point. 00:12:56.880 |
is I want to be able to use this chat interface 00:13:03.120 |
At the moment, we have to use a different script 00:13:08.880 |
but we write code in order to add those papers 00:13:16.320 |
I want to let users interact with the chatbot 00:13:18.800 |
and say, I would like to talk about this particular paper 00:13:24.240 |
and for that paper to not be within the database already. 00:13:39.280 |
and then we can start talking about it, right? 00:13:41.600 |
I'm not sure because that takes a little bit of time. 00:13:49.840 |
you need to give me a bit of time to think about it. 00:14:06.160 |
So we have this add article to database function, right? 00:14:11.920 |
That is just getting the archive ID, basically. 00:14:38.560 |
and then we shrink the paper in smaller parts. 00:14:49.280 |
or we're going to return something like this. 00:14:53.760 |
It's now accessible via the search archive database tool. 00:15:01.360 |
but also actually more for the chatbot to see. 00:15:08.000 |
we can now access it through this other tool, right? 00:15:11.280 |
So if it's going through those multiple steps, 00:15:21.600 |
So I added the attention is all you need paper. 00:15:29.760 |
and it retrieved the relevant information from that paper. 00:15:33.920 |
but I don't want to write code like this to do it. 00:15:39.280 |
but can you add the like 1706.03762 paper to your memory? 00:15:58.480 |
I would like to say, can you add the attention 00:16:07.200 |
So this is where we might search for multiple papers, 00:16:09.840 |
some papers about NLP attention to your memory, right? 00:16:15.280 |
I want to be able to ask these things to the bot, 00:16:24.480 |
But for now, like you can actually kind of use this 00:16:31.280 |
So you can use some code that will look like this. 00:17:06.320 |
So with that, you can actually use this library. 00:17:19.920 |
Because we want to basically make every interaction 00:17:24.160 |
with this library accessible via the chat bot. 00:17:36.080 |
Hopefully there'll be a bit more progress on this very soon. 00:17:38.880 |
And I'll be able to show you like an actual chat bot 00:17:41.680 |
that you can genuinely use just like out of the box 00:17:45.680 |
as a essentially like research assistant for archive papers 00:17:51.280 |
and maybe in the future, other things as well.