back to indexHow-to Structure a Q&A ML App
Chapters
0:0 Intro
1:16 Architecture
2:19 Python Requests
3:33 Retriever Reader
3:58 Document Store
9:7 Outro
00:00:00.640 |
Okay so I had an idea. I thought maybe what we could do is actually put together a few videos 00:00:08.400 |
and what we'll do in the next few videos is build out a full Q&A project. And this is something 00:00:15.520 |
that I've actually been wanting to do for quite a while now and I think it will actually be really 00:00:21.360 |
cool. I was thinking through it this morning and I thought okay today we're going to start it. 00:00:26.320 |
So what you can see on the screen right now is the github repo for this project which is 00:00:32.880 |
completely empty almost. There's a readme, a gitignore and this one architecture drawing that I 00:00:39.360 |
set up literally you can see four minutes ago. So I'm going to show you that and I'm going to 00:00:46.480 |
explain what we're actually going to go through and I think we're going to cover a lot of different 00:00:53.040 |
things. So I think that is one of the reasons why I think this is such a cool project. 00:00:58.320 |
So at the moment this is like the basic architecture of what we would need to build 00:01:06.800 |
a Q&A model and the end goal is to have a front end which looks kind of like this. 00:01:20.320 |
So we'll have like a search bar here and we'll have some visual up here. It's going to be a 00:01:27.200 |
little bit better than the sigma and I'm going to show you what I already have and maybe we 00:01:31.600 |
can use that or maybe we'll do something different I don't know. And what we're going to be able to 00:01:35.120 |
do is ask a question here and we're going to be able to answer the question based on 00:01:45.760 |
stoic philosophy books. So I haven't really read any of these, I've read like little bits 00:01:51.600 |
but they're pretty interesting and I think quite unique. So as far as I know there's 00:01:59.040 |
definitely not anything like this out there at the moment where you ask a question and you get 00:02:05.280 |
the answer back from some ancient stoic philosophy book. And there's only really two books that I've 00:02:12.400 |
thought of so far which is Meditations by Marcus Aurelius and Letters from a Stoic by Seneca. 00:02:24.800 |
And the good thing with both of these is that we can find both of them online for free so we can 00:02:34.960 |
use Python requests to get these. So I'll just kind of put a little list here of what I think 00:02:41.360 |
we're going to need. So the first one is actually extracting and downloading this data so we'll be 00:02:49.280 |
using requests for that. And then once we have actually got that data we need to pre-process it 00:02:57.840 |
and when we're pre-processing it I think that will just be a case of using Regex 00:03:05.760 |
more than anything else but I'm not sure yet so let's see. So after we pre-process it and 00:03:13.120 |
that's when we get into this stuff over here. So this whole sort of stack that you can see 00:03:19.040 |
without the API. So this is a typical, it's called a reader or retriever 00:03:31.600 |
reader and what we do is we use this up here, this is our database, it's a document store, 00:03:39.360 |
Elasticsearch document store and what we're going to do is feed all of these. 00:03:46.080 |
Sorry it's getting a little bit messy with the color so let me change it. 00:03:58.400 |
So what we're going to do is take these and we're going to feed them 00:04:01.840 |
into our document store and once we have that what we want to do is build this retriever reader 00:04:10.880 |
stack and it will allow us to query the retriever down here and what the retriever will do 00:04:21.680 |
is send that query to Elasticsearch here which is what you can see happening there. 00:04:28.080 |
And returning from that we'll get so many different contexts. So all of the text from 00:04:36.640 |
meditations and letters from Stoic, we'll split them up by maybe paragraph and saw them in here 00:04:43.360 |
and what these contexts will be are the most relevant paragraphs. 00:04:51.360 |
And once we've done that, this retriever will pass on the context to our reader model down here 00:04:58.880 |
and what the reader model will do is say it's given a long sentence like this or paragraph, 00:05:07.360 |
it will say okay the actual answer that you want is actually only these three words here and it 00:05:13.840 |
will return those three words and what we want to do is return those three words in our answer 00:05:20.880 |
back to our API. But alongside the answer we're also going to include the full context here 00:05:28.720 |
as well. So we get a few things back and I think that that's like going to be the more 00:05:38.240 |
machine learning side of it but obviously we need to support all the machine learning side 00:05:42.560 |
and I mean the very first part of that that you can obviously see here is the 00:05:49.280 |
API. So let me so let me write down so we have the the ML part 00:05:54.080 |
and for that we're going to be using something called haystack. 00:06:07.440 |
I'm just going to use a different color here, move on to our API. 00:06:15.280 |
The API we'll just we'll use probably fast API to set that up. 00:06:20.000 |
Then once we set that up we go on to our front end part 00:06:26.400 |
and the front end I don't I'm not a front end developer I just mainly use Python but I do know 00:06:35.600 |
Angular a little bit. So what we're going to do is build all of this part using Angular. 00:06:45.200 |
So this will be our Angular front end and that's essentially everything we'll be covering but 00:06:58.320 |
there's you know there's quite a lot in here. In particular as well what I've missed 00:07:04.240 |
is alongside you know we have our reader model down here but what I want to try and do is rather 00:07:12.400 |
than just taking the reader model from Hugging Face Transformers as we normally would, I want to 00:07:21.440 |
actually try training it and for that we need to use something called MLM which is mass language 00:07:30.800 |
modeling. So we would need to train a BERT model using MLM or fine-tune the BERT model I should say 00:07:39.760 |
on the data from our books up here and then we'd also want to train it so that it performs Q&A 00:07:49.040 |
and for that we need to use the squad data set, probably squad anyway. 00:07:58.000 |
So you know there's quite a lot that I think we would have to do to build this 00:08:04.000 |
and I think it'd be pretty interesting. So that is what we're going to be covering in 00:08:12.160 |
sort of the next few videos and the one other final little thing. Okay so over here we have 00:08:21.840 |
the Marcus Aurelius Sit-Man and I thought maybe something like this would be cool. I don't know 00:08:28.080 |
this is something I drew ages ago and this is Marcus Aurelius and I think something like this, 00:08:36.480 |
maybe this or something like it would be pretty cool to just have in the middle of the web page 00:08:40.640 |
and underneath we have a search bar and keep it pretty simple. So I think that's everything really 00:08:48.800 |
for the plan and I think the first thing we're going to do in the next video is actually 00:08:55.440 |
sell requests and download that data and maybe pre-process it as well or they might be two videos. 00:09:03.040 |
So that's everything for this video. I hope that you're as excited about this as I am because I'm 00:09:11.040 |
really looking forward to actually building all of this. I think it'll be super cool and 00:09:15.280 |
I mean ideally at the end it's one it's going to look cool and two we're going to learn like a huge 00:09:23.520 |
amount of stuff if you even put all this together there's so many different things that you need to 00:09:27.440 |
know in order to make everything work. So it should be really cool and I'm looking forward 00:09:34.160 |
to getting started with it. So I will see you in the next video where we'll actually download the