Latest / Agentic Conversations (formally mlops.community) / RAG Has Been Oversimplified // Yujian Tang // #206
Transcript
- 0:00My name is Yujin. I'm a developer outlet Zillis
- 0:05and yes, so I take my coffee, two shots of espresso over ice
- 0:09with sparkling water and a pump of caramel, and then some milk
- 0:14to mix. Welcome back to the Community
- 0:19Podcast. I'm your host Dimitrios, and
- 0:22today we're talking with Eugen. What a conversation.
- 0:25We went real deep when it comes to rags.
- 0:28I know it's everyone's favourite topic.
- 0:30Or at least it was in 2023. Let's see how 2024 shapes out.
- 0:34Maybe you are bored of them or tired of them and now, but I
- 0:38promise you we got into some caveats when it comes to rags.
- 0:43There's a million and one courses or pieces of content
- 0:49that have come out around rags and so how can we differentiate
- 0:53ourselves? Well, we talked about some
- 0:55optimization methods that you might want to consider when you
- 0:58are using Rags. We went from what the hell is a
- 1:02rag to how do I optimise it? And what do I need to be
- 1:06thinking about at the deepest level?
- 1:08How am I building my app so that I can take full advantage of the
- 1:14pros and cons of each design pattern and these dense vectors
- 1:18and sparse vectors and all that fun stuff that all database
- 1:25vector database people like talking about?
- 1:26I guess so. If you are doing anything with
- 1:32rags, I would love to hear from you.
- 1:33To be honest, I would love to hear what you're working on.
- 1:36And if you decided against Rags, I would also love to hear from
- 1:41you because the beauty of this is that rags, as we talked about
- 1:45with Eugene, they're not for everything.
- 1:49Although you may go on Twitter and hear that you can just throw
- 1:54some AI at it and have it be a rag or use a rag with it, you
- 1:58don't need to. And the last part, I think
- 2:02Eugene has some cool insight around multi modal rags and what
- 2:06we can do when that starts taking off and when support
- 2:11happens. For that more O If you are on
- 2:17the market for anything vector database, check out Zillas Cloud
- 2:22and check out Zillas Pipelines, their new feature that they just
- 2:28have 4:00 early access for the community and listeners of this
- 2:32podcast. You can find it by clicking in
- 2:35the show notes. And huge thanks to those for
- 2:37sponsoring this episode. Of course, if you liked it,
- 2:43share it with just one friend. That's all I ask.
- 2:46All right. I'll see you dude.
- 2:55Well, I'm stoked to have you on here.
- 2:57I want to do like a huge deep dive into Rags and basically
- 3:02where we're at right now. It's 2024.
- 3:04Rags have become the hero of the LM space.
- 3:08I think it's more or less. The QA bots are like the Hello
- 3:12Worlds that you create with LM's and I know you've been spending
- 3:16a lot of time working on Rags and and their implementations
- 3:21and all that and stuff. So we should probably start with
- 3:25we had you on last time and we'll link to the last podcast
- 3:29that you came on in case anyone wants to basically hear.
- 3:32I'm not going to say it's part one, because we're going in a
- 3:34totally different direction where it's not like you need to
- 3:36listen to that one first before you get to this one.
- 3:38But we did have a pretty insightful conversation around
- 3:43vector databases and the idea of how much AI has been accessible
- 3:51by the masses now because of things like vector databases and
- 3:55Ellms. And so whereas before it took
- 3:59quite a lot of effort and a lot of engineering time to get some
- 4:04kind of ML model into production and that was really the thesis
- 4:09for the ML OPS community from like 2020 to 2022.
- 4:15Now it feels like were in a place where we can get something
- 4:21at least something quick and dirty U and running real quick
- 4:25and validate assumptions, validate different ideas that we
- 4:29might have O Before we go any further, the vector database LLM
- 4:37embedding design pattern is probably the one that everyone
- 4:41thinks about when it comes to Rags.
- 4:44Am I correct? And correct me if I if I've
- 4:47gotten anything mistaken there. Yeah that sounds about right for
- 4:52most of like what you what people like ask about when it
- 4:56comes to like the rack sack is like you know what our
- 4:59embeddings. How do we get embeddings into
- 5:01vector databases? Like what do I are embedding
- 5:03models in Elms, the same thing and they are not the same thing.
- 5:08And this is like something that quite often gets asked and
- 5:13people like, you know, once they look at these different
- 5:16applications like using like, if you're gonna use, like chain, if
- 5:20you're gonna use on the index and you're gonna do rag, you're
- 5:23going to have an embeddings model and you're gonna have a
- 5:26LLM. And people will ask like, oh,
- 5:28like do they have to be the same?
- 5:30And the answer is no, they don't have to be the same.
- 5:31It's like, Oh well, how do I pick one?
- 5:33And then, you know, it gets a lot more complicated than just
- 5:37like the very basic like here is use the default.
- 5:39Here's Open AI. Boom.
- 5:42So yeah, and embedding models it.
- 5:45It's probably worth just a quick summary too, for the two people
- 5:49that are listening that have been under a rock and do not
- 5:51know how embeddings work and vector stores work with
- 5:55embeddings and what you need to do there.
- 5:59Uh, yes. OK.
- 6:01So yeah, I should probably should have more clarified what
- 6:06these pieces of the puzzle were. So embeddings models are the
- 6:10models that you use to turn your data that you're going to be
- 6:14working with. This is your proprietary
- 6:15internal data or whatever. And you turn that into vector
- 6:18embeddings so that you can well, so that you can work with it.
- 6:23Basically because embeddings are numerical representations of
- 6:26this input data that is like a text or image or something.
- 6:32It's like a machine learned using a machine learning model
- 6:36representation of this kind of data and embeddings embedding
- 6:41models are trained well. Now we've moved into we've moved
- 6:46far long enough into the ragged staff that people who are
- 6:49working on the more like cutting edge stuff.
- 6:52I think this was probably this probably came to light a few
- 6:55months ago. Like the whole like you need to
- 6:57be training your embeddings model on specific types of data
- 7:00that you want to work with. Like you can start off by going
- 7:03to hugging face and getting like a very basic embeddings model
- 7:08and it will work decently fine. But when it comes to like
- 7:10enterprise production and it when it comes to working with
- 7:12very specific data, you're gonna need to make sure that you're
- 7:15training your beddings model on the right data.
- 7:18And then what these embeddings models do, or what we do with
- 7:21the embeddings models. What you need to do with
- 7:22embedding models in order to get the embeddings from them is you
- 7:25actually after you train the model, you need to ensure that
- 7:29you're only taking the output from like the second to last
- 7:31layer. So traditional models,
- 7:32traditional natural image processing models will, they
- 7:37will or even even image rattles. They'll do some sort of like
- 7:42image models do some sort of segmentation.
- 7:43Natural image processing models might do some sort of
- 7:47classification or some sort of prediction, something like that.
- 7:51But with the vector embeddings, that's what we're looking for
- 7:53actually. We just want to know what the
- 7:57semantics the model has pulled out of the input is.
- 8:01And so that's why instead of taking the output of the model,
- 8:04where we actually do is we take the output from the 2nd to last
- 8:06layer and then just to touch on the LMS's and the factor
- 8:12database in case there are other people who have not heard about
- 8:15these yet. LM's are the large language
- 8:18models, right GPT, everybody kind of has heard of that one.
- 8:21There are many others, right? Like mixture came out.
- 8:24Perplexity is I think perplexity is coming out with another one.
- 8:27I don't know. There's like a huge number of
- 8:29Owens now, Falcon Llama, basically everything you can
- 8:33think of is an LM. I also like actually I have like
- 8:37a personal grief on this is at this point like I don't even
- 8:39know like what makes something a large language model anymore.
- 8:42How large does it have to be, you know, 7 to 1320, a trillion
- 8:47parameters. I'm talking about billions with
- 8:49these like first few numbers. And then like I heard someone
- 8:51saying like, oh, you know, actually I think anything under
- 8:547 billion is a small language model.
- 8:56And I was like, I don't know, it seems pretty big to me.
- 9:00Yeah, like, just like, like. Literally three, yeah.
- 9:04Yeah. Like literally like last year
- 9:05we're like ohh large language model with 5 billion parameters
- 9:09and now it's kind of like, yeah, if you don't have more than 10
- 9:11billion parameters is a really large number if I don't know and
- 9:14then. You guessing, you don't kick
- 9:16them, you don't get the stamp of approval of being large.
- 9:20You're not large enough. And yeah, it's funny because a
- 9:23lot of people are coming through and saying, yeah, this year it's
- 9:26all about the small language models.
- 9:28And so now it's like who's deeming what is large and what
- 9:34is small? Where have we come to a
- 9:37consensus on that yet? I don't.
- 9:38I don't think so. So I know I don't.
- 9:41Know so you were and these people are like, yeah we're
- 9:43talking about small language models and they're gonna be
- 9:45talking about like 3 billion parameter models like, I don't
- 9:48know man. And then the last part is the
- 9:50vector database piece, which is where you store your vector
- 9:53embeddings. Once you get your vector
- 9:54embeddings and you basically use this as a semantic store, as a
- 9:59way to store the meaning behind the image and the text and the
- 10:02audios and the videos that you have, and a way to work with
- 10:06that semantic meaning in a mathematical manner.
- 10:09Yes and no. And the plane?
- 10:11What does it look like when you're actually building the
- 10:16application? The end user will whatever type
- 10:20into their Q and A. Bot what does the user actually
- 10:22have to do? Well, I I think I'm more just
- 10:26thinking the end user will type into the QA bot right?
- 10:30Like I'm looking for more examples of this or whenever it
- 10:35says that and or tell me tell me about the if I'm if I'm reading
- 10:42a book where I have a bunch of PDF documents, tell me about
- 10:46this paragraph more or where it talks about this more right then
- 10:53behind the scenes what happens. Ohh, yeah yeah so there's.
- 10:59OK. So actually the way that a user
- 11:01is expected to interact with the app also plays into like the way
- 11:04that you think about designing your app.
- 11:05But we can we'll touch more on that in a bit.
- 11:09So what actually happens behind the scene is.
- 11:11So there's a few ways that you can structure your architecture
- 11:13and it depends on how you would like to build it.
- 11:16But what I would suggest, this is my suggested architecture is
- 11:20what happens behind the scenes is the query comes in, it goes
- 11:22to the LLM for the LLM to determine what the actual
- 11:27question is. So perhaps you have, like, you
- 11:29know, here's the you want to give us some context.
- 11:31You want to say like I'm pretend that I'm in, I don't know, like
- 11:35an astrophysicist. And I'm reading this book about
- 11:37the cosmos and I want to know about black holes or whatever.
- 11:41So then, you know, it gives us some context that pulls out like
- 11:43what it actually is. And so when you say that the LM
- 11:46has to know that, OK, well, actually what I want to go look
- 11:49for in the database, let's say you have a database of books is
- 11:52I want to go look for and I want to philtre on the book Cosmos
- 11:55and I want to look for black holes.
- 11:57And So what it will do is then it will say, OK, it will form a
- 12:02way to query the vector database.
- 12:04And so vector database queries are typically formed in like,
- 12:07you know, like a call, right, like either some sort of like
- 12:11API call, some sort of HTTP://GERC, some sort of call
- 12:15like that. So it's passing data along, it
- 12:17passes it, It makes some sort of, you know, call to the
- 12:20venture database and it says, OK, let's philtre on this book
- 12:25and Cosmos, we're only going to look for text about black holes.
- 12:29OK, so then maybe you get, I don't know, 10 responses back.
- 12:33Right. So you get 10 responses back and
- 12:35then you send those responses back to the LM and and you know,
- 12:39you give the, remember the first query, it's like, OK, we want to
- 12:42know about black holes from this book.
- 12:45And then it says, OK, here's my response, Here's what it is in
- 12:48the back of database. Here's the book name.
- 12:50Here's the, I don't know the section name, chapter name, the
- 12:53author name and like all this information.
- 12:56And then what I'll do is I'll take that information, we'll
- 12:59punch it down and say OK, here you go, black holes are, I don't
- 13:02know supermassive clusters of gravity or something.
- 13:06I'm not really sure what they are.
- 13:07But yeah, then it will return you the The answer to you
- 13:09basically was. So why?
- 13:10What goes on in the background is basically the Allen first
- 13:13takes your input and that interprets it, turns that into a
- 13:18query, queries the vector database, takes that context,
- 13:22and then turns that context into something as human readable and
- 13:25gives you back something that makes sense.
- 13:28I was really hoping you were going to give me some crazy
- 13:33definition of a black hole right there.
- 13:35I miss, but we can hopefully edit it.
- 13:39Attack in in post production. I don't have any any crazy
- 13:42things, all my goals. Let me think if there's anything
- 13:44I know a lot about that would be like fun to know about.
- 13:48The fun fact I do appreciate this is just like a little bit
- 13:51of a side note and a tangent. Since we are going on a little
- 13:56tangent here, I I ask speakers of the podcast to fill out a
- 14:02speaker form when they come on to this podcast.
- 14:06You filled that out and one of the questions on there is a fun
- 14:10fact about you. Do you remember what you put for
- 14:14your fun fact? You said I can build a fire.
- 14:17Is it like Boy Scouts fire where you're just kind of in the woods
- 14:21and you have Flint and that stuff, or is it with a whole
- 14:24bottle of kerosene? Yes.
- 14:26So I don't know why, but that was like one of the first things
- 14:29that came to mind for that question.
- 14:31And I am really proud of being able to build a fire because of
- 14:34like one specific instance, which was like I was down in
- 14:38Coronado Beach with some friends and we brought like Korean
- 14:43barbecue and we've brought like something to cook it on.
- 14:45And we brought like like a bunch of things.
- 14:49But ohh and we and we have like firewood and all this stuff.
- 14:52And then we're having a lot of trouble starting the actual
- 14:55fire. Right.
- 14:55You gotta imagine, like you have three kids who spend most of
- 15:01their time in front of computers, like, you know,
- 15:03things like, you know, very like nerdy, like, I mean I'm, I come
- 15:06from a software background, right.
- 15:07So you've got these three kids who spend basically like 20
- 15:10hours a day in front of a computer, and they're just
- 15:12sitting at a beast trying to figure out how to, like, start
- 15:14fire. And so we actually get the fire
- 15:16started. So first we figure out like, OK,
- 15:20we're just going going to go around and find like dry leaves
- 15:22and like stuff like that and it finally works.
- 15:25We Oh my It was probably like my first
- 15:50time ever actually building a fire and I was like just like
- 15:52one random thing that I came to my when I was filling out the
- 15:55form. I was like, OK, here we.
- 15:56Go so the mental picture that I have in my head of the three of
- 16:00you trying to build this fire, and you're used to writing unit
- 16:05tests and all that fun stuff, and there's no unit tests for
- 16:08these fires. It's.
- 16:09Like there's no. We need, we need more kindling.
- 16:12Do we need more gasoline? Let's just go get gasoline and
- 16:16dump it on this and see if that'll work.
- 16:18So this as as you were telling this story, basically I was
- 16:25thinking about the parallels in what I just did to get more
- 16:29context out of you on this fire. It was it was like I was I was
- 16:35raging right there. Yeah, I was.
- 16:38I was your I was a human rag. Cause you get you said I can
- 16:43build fire. But then I said give me more
- 16:45context, I need more context. And I went to the vector
- 16:50database, which is you. And I've got more context.
- 16:54And now I can plug it into the LLM and I can say, all right,
- 16:58here's all the context you need about Eugene's fire
- 17:01capabilities. So we went on a huge tangent
- 17:04there, man, I want to get back on track.
- 17:07And for those that are listening, I promise we're going
- 17:09to get deep into the rags and rag stack.
- 17:14I like that word that used. It's good.
- 17:16One huge question that is on my mind when it comes to rags.
- 17:22I'm sure you've heard a lot of people talk about this is the
- 17:26rags Eliminate the ability for LM's Toulouse Senate because you
- 17:33give it that context. No, it doesn't.
- 17:36So this is something that we talked about a lot in like many
- 17:40of our earlier presentations and I think a lot of people talk
- 17:42about this when it comes to tarak stuff is like rats
- 17:46hallucinate. How do you get rid of that?
- 17:48While you should use some sort of contacts to inject your data,
- 17:52and injecting your data does it reduces like a certain like type
- 17:57of hallucination? Like, you know it's not gonna
- 18:00just like make things up about your data anymore.
- 18:03But that doesn't mean that it's not possible for the rag to like
- 18:07still like put out the wrong answer.
- 18:09Because in the end, like the way the LM's work is still using
- 18:15statistics, and it's still just like, here's the context.
- 18:19I'm gonna predict based off the context.
- 18:22But if the training data was weird and the contact
- 18:24contradicts the training data, you might get some weird, some
- 18:26weird results. And so an important thing to do
- 18:29to kind of deal with that is basically to have your
- 18:33observability tools and have like you know, your your
- 18:36evaluation tools afterwards. And I think that's part of like
- 18:39the whole reason that there's so many tools that have recently
- 18:45kind of like moved from what was originally like ML OPS into now
- 18:48what they're calling LM OPS. Yeah, and do you feel like that
- 18:52is a critical part of the rag stack?
- 18:54Oh for sure. Like if you're going to be doing
- 18:56this in production like you don't want like, you gotta know
- 19:00like that your your answers are like decently, like, right,
- 19:05right, like, not like even humans.
- 19:07Like, you know, no, no human is right 100% of the time.
- 19:11But it's you know like you gotta make sure that your rags are at
- 19:16least matching up to what people are capable of.
- 19:17And so like examples of like you know some of the things that
- 19:21people talk about in this space like make sure that the, the the
- 19:24context that you get is relevant, right.
- 19:26Just because some of these semantically similar doesn't
- 19:29mean that it may necessarily be semantically relevant and make
- 19:33sure that you cite your sources right.
- 19:35So this is something that I was building earlier last year using
- 19:39like Llama index was like how do you build a rag app with
- 19:44citations and how do you ensure that, like you know the actual
- 19:50answer given doesn't deviate too far from the the data that's
- 19:55pulled back from the vector database?
- 19:57And how did you do that? Building citations is actually
- 20:02very, very easy. What it kind of requires you to
- 20:06do is to realise that you're going to build an application
- 20:08that's gonna need citations, and so you have to store the text
- 20:12that you're going to use along with your embeddings.
- 20:16So you're going to store more data, but you're gonna in
- 20:19return, you're going to get that groundedness in that context and
- 20:22that relevance and that ground truth data back.
- 20:27And then actually, so this was something that wasn't originally
- 20:32available on Lama Index that I actually ended up writing.
- 20:35I ended up writing a PR to make this available.
- 20:38Nice. Yeah, it's almost that trade off
- 20:40of, hey, we're going to store more data, but we're going to
- 20:43have more trust. So yeah, it's worth it 100% of
- 20:47the time. Yeah.
- 20:48And you said something else that's interesting in there that
- 20:50I wanted to just dig into for a second, the context and
- 20:55relevance, like what's the difference between those two
- 20:58there? Right.
- 21:03I think it's probably more it's probably, it probably makes more
- 21:06sense to differentiate between like relevance and similarity.
- 21:09I guess these are both like attributes of contacts.
- 21:11I was I would say, but context is like you know like the the
- 21:17the additional data or the data that the original form of the
- 21:21data or like the data that you know like the surrounding data
- 21:24for something. So for example, like an apple a
- 21:27day keeps the doctor away, like you need the contacts that the
- 21:30apple you're talking about is a fruit and not like, you know,
- 21:33the Mac, right? Laptop.
- 21:36So context is kind of like that. And then similarity and
- 21:39relevance is like let's say I wanna find something for an
- 21:45apple. A day keeps the doctor away, and
- 21:48maybe a similar sentence to that might be like a banana a day
- 21:53keeps the chiropractor away. But you know, is that.
- 21:57You just made that shit up, didn't you?
- 21:59You just made that shit up, but is a banana a day?
- 22:03Keeps the chiropractor away. Relevant to my question about,
- 22:07you know what keeps the doctor away and not really.
- 22:10So that's kind of like the difference there is like, you
- 22:12know, like what would be relevant might be like, you
- 22:15know, an apple a day keeps the doctor away because it makes you
- 22:19E fibre. I don't know, something like
- 22:21that. Yeah, fibre, it's a big one
- 22:23these days. Get that gut health right and
- 22:26you won't have to see the doctors, Yeah.
- 22:28Yeah, I just heard a podcast about it, so that's why I was
- 22:31thinking. About was it the Peter ratio 1?
- 22:34No, no. It was like one of the ones with
- 22:36Angie Huberman. No way.
- 22:39All right, I gotta go watch that.
- 22:40Now that's on my list. I just watched the ERA Tio 1.
- 22:43So, OK, so now I want to just make sure that I'm getting this
- 22:48right. Just a little pause because the
- 22:51rag stack, we introduced something new into it that we
- 22:54didn't have in the beginning When you said, oh, these are the
- 22:57things that you need for the rag stack, which is the embedding
- 22:59model, the LM and the vector database.
- 23:04But then we just said, Oh yeah, and by the way, you might want
- 23:07to have some kind of and evaluation guardrails tool on
- 23:11there. And funny enough, I'm sure
- 23:14you've been seeing some of this stuff OU on social media where I
- 23:17think it's Chevrolet. If you go to the Chevrolet
- 23:20website, they use an LLM for their customer service bot and
- 23:26it's just straight plugged into GPT 4.
- 23:29And so I've seen people talking about how, like why pay for open
- 23:35AI when you can just get it through a Chevrolet website?
- 23:39Or I've also seen people asking like, are Tesla's better than
- 23:44Chevys And it will come back like Teslas are known to be
- 23:48better than Chevys. Yes, on the Chevrolet website is
- 23:51just like the amount of brand damage that you're doing right
- 23:54now is incredible. So it's worth its weight in gold
- 24:00to get some kind of tool that will make sure you're rag is not
- 24:05spewing out things it should not be spewing out.
- 24:09Yes, it is definitely worth looking at doing something like
- 24:13that. And you definitely need
- 24:15something like that when you're gonna be putting this into
- 24:16production. I guess like since we're on the
- 24:19topic of tools that you can add to your rack sack, other things
- 24:25to think about could be like data pipelines, like for
- 24:29example, how do you pipe new data into your vector database.
- 24:34And this is actually something that we have been building a
- 24:38Zillis. So Zillas recently released our
- 24:40own pipelines thing. And so one of the things that
- 24:43people always ask me like I I'm pretty sure I did, I didn't
- 24:48really like 14 talks last year and I got this question at least
- 24:51like 12 or 13 of them, which was like how do I get my data into a
- 24:54vector database? And it's like, ohh, well you
- 24:56need to use the embeddings model, but you can make it
- 25:00easier by building a pipeline around it or something like
- 25:03that, right? Where so far we have for Zillis.
- 25:06Right now we have an open source.
- 25:09We have an open source model as our embeddings model on
- 25:11pipeline, but uh, you know, like that's kind of a just a one way
- 25:17to get into it, right? We want to offer people a way to
- 25:19get into it. And the thing about using
- 25:21pipelines, because when you're in production, you probably
- 25:23don't want to. I mean, you could, I guess
- 25:26people do actually do this in production.
- 25:28You could just every, you know, day or so, execute a script,
- 25:32runs for 10 minutes, put your data into your vector database.
- 25:36Yeah. Hey everyone, My name is Aparna,
- 25:38founder of Verizon. And the best way to stay up to
- 25:40date with Emma Lops is by subscribing to this podcast.
- 25:46But if you want like a, you know, more automated version of
- 25:50that, like if it starts taking you too long to go and, you
- 25:53know, do the script and then get a pipeline.
- 25:55Right. And Zoe, pipelines aren't the
- 25:57only pipelines that are available.
- 25:58But you know, this is like one way that you can use a pipeline
- 26:00to pipe your data from some sort of data source into your
- 26:04database in a more, let's say, streamlined, automatic, easy,
- 26:08whatever kind of manner. Yeah, so, so then basically, if
- 26:13I if I understand this correctly, it's like as we build
- 26:17out this RAG stack in my head, we've got the LLM, we've got the
- 26:20vector database, we've got the embedding model.
- 26:23We need a way to connect that and connect all of these along
- 26:28with on the output. We need a way to make sure that
- 26:32there are guardrails and that we validate the output before the
- 26:35end user sees it. Is there anything else I'm
- 26:39missing there? I feel like probably potentially
- 26:41some kind of prompt tooling? Like the, I mean like like you
- 26:47know lane chain, Lama index, these are orchestration
- 26:50frameworks like as Pont tooling prompt engineering kind of
- 26:52frameworks also kind of like fits the if the shoe fits, you
- 26:56know I guess um so that's yeah that would probably be like one
- 27:00more thing in there. I I have seen that a lot of
- 27:03people like to also do their own prompt engineering and I think
- 27:08that that is actually something that.
- 27:11So I I would I would really like to see this is a feature request
- 27:15for the link chain law people are still listening.
- 27:17I'd really like to see a way to to mess with the prompts inside
- 27:21of the apps which is kind of I guess it's kind of weird because
- 27:24it kind of defeats the purpose of the apps themselves like you
- 27:26know the frameworks themselves are supposed to be there to give
- 27:28you this this way to interact with the island.
- 27:30I'm not sure, but that's something that I think is like
- 27:34if you're working in production like, you're probably gonna want
- 27:37to tweak your own prompts. Yeah, yeah.
- 27:40You want easy access to that. You don't have to dig around,
- 27:43that's for sure, yeah. So.
- 27:45The other piece that I I'm fascinated by is I think some
- 27:50people have come and asked about why would you need to use RAG
- 27:59for some use cases. Is it not good enough just to
- 28:04use LIKE search? Like keyword search.
- 28:07Or similarity search for that matter.
- 28:10Like do you need the whole throwing it into an LLM and
- 28:14getting a bunch of output, or can you just do search and have
- 28:18it give you back something you know?
- 28:20Like is LM over engineering yet just because of the height?
- 28:25Yeah, I mean like, so for this, I would like invite you and
- 28:30other people to kind of consider like a thought experiment, which
- 28:33is let's say I have semantic search and I asked the question,
- 28:42you know, what ingredients are in an apple pie.
- 28:48When I do a similarity search for that, I'm not gonna find,
- 28:53like an answer that says you need three apples, a pound of
- 28:57butter, you know, a pound of flour or whatever.
- 29:02What I'm gonna find is things like what are the ingredients
- 29:05for a blueberry pie, what are the ingredients for a pecan pie?
- 29:09And that's what I'm going to get back.
- 29:11And so if you think about, if you think about it in that
- 29:15manner, you'll quickly recognise that you need something that's
- 29:19going to take your natural language, query your question
- 29:22and turn it into how do I find the things that's going to be
- 29:25similar to the answers of this question?
- 29:27Yes, I see. That makes 100% sense.
- 29:31Yeah. And it's like we want the
- 29:33answer, we don't want the similarity of this question.
- 29:38Correct. I should have known that.
- 29:40I can't believe I didn't know that.
- 29:41And I'm asking you that. Now that I think about it, I
- 29:44kind of feel like an idiot itself.
- 29:48Is a very common question that I also get.
- 29:52Good. So one other piece that I'm
- 29:55wondering is like what kind of RAG optimization do you do?
- 30:02And should we be thinking about like let's say we've got the RAG
- 30:06up and running, but now we want to make it better.
- 30:09What are some ways that you can turn some knobs and levers you
- 30:12can pull? Yeah, so I think this is part of
- 30:15where some of the preprocessing stuff comes in.
- 30:19And this is also something that kind of this comes before the
- 30:22embeddings model, which is thinking about how you want to
- 30:25chunk up your data, how do you want to split up your data.
- 30:27And earlier when we were talking about like the end user and how
- 30:30the end user is going to use the RAG app, this is I referred to
- 30:33this. I alluded to this like, oh,
- 30:35we'll cover this later. Yes, foreshadowing.
- 30:40When you think about the way the user is going to use an app, it
- 30:45also makes you think about the way you want to check up your
- 30:47data. So for example, if you want your
- 30:50user to use your app in a conversational manner, like it's
- 30:52gonna be a chatbot, then you probably can chunk up your data
- 30:56into smaller sections like. It's like OK, like we probably
- 31:02need to find very specific, very like small kind of things.
- 31:04But if you perhaps want your user to use your application as
- 31:09something like something that helps them complete, like blogs
- 31:16or writing things, kind of like, you know, kind of like what
- 31:18Jasper does or copy AI you know, then maybe what you want is you
- 31:22want to give it more data. That is an example of bigger
- 31:26blocks of paragraphs or maybe also like depending on not even
- 31:32not even getting to the part where we talk about what the
- 31:34user is going to do. But maybe let's think about what
- 31:36data you are working with to begin with and was it look like.
- 31:39So if you have data in the format of a conversation of like
- 31:43a, you know, like a text back and forth, then you're going to
- 31:46want smaller chunks and you're probably going to want to chunk
- 31:48on specific characters. Maybe you have specific
- 31:50characters to separate new text blobs and you're gonna want to
- 31:56check on that. And then you know, if you have a
- 31:59big document then you're gonna want bigger chunks.
- 32:02If you have maybe a QA or a lecture where there's going to
- 32:05be like a short and then long answers, you're going to want a
- 32:08way to chunk on specific characters.
- 32:10And possibly also you're going to want to be able to save
- 32:16coupled texts. And then one other thing to
- 32:20think about with that is how much context overlap do you need
- 32:23between between your data chunks, right.
- 32:26So maybe you have a document and you know these paragraphs are
- 32:30like 500 characters, but you need the sentence before and the
- 32:34sentence the sentence, the last one of the, the last sentence of
- 32:36the paragraph before, and the first sentence of the paragraph
- 32:38after. Then you're gonna need some sort
- 32:40of chunk overlapping, right? So there's a bunch of different
- 32:43things to think about when it comes to how am I gonna set up
- 32:46my data To even embed this is like prior to building your rag
- 32:49app. Like you can build an example
- 32:51one, and then once you build an example one you probably want to
- 32:53think like OK, there's definitely ways I can make this
- 32:56better. How do I make this better?
- 32:57The first step you're going to want to look at is what does my
- 32:59data actually look like inside of the application?
- 33:01And then of course the eval stop.
- 33:03Yeah, that is really interesting when it comes to this idea of
- 33:09like start from the end and then go backwards and recognise how
- 33:14you can optimise that way. And I also look at like other
- 33:18ways that we are interacting with LMS as far as like the
- 33:24point and click with that, we're doing it too, right?
- 33:27Like I think about Notion AI and that's a great interface of it.
- 33:31We don't have to use it like a chat bot, but we can if we want
- 33:34to. So if you have all of those
- 33:39options open, how are you then thinking about optimising in the
- 33:43background? You know what I mean?
- 33:44Like do you do both and then just sacrifice on the storage
- 33:48like we talked about before where yes you are going to store
- 33:52more but you're also going to have more trust or is it
- 33:56something like you're you're finding that happy medium?
- 34:00Yeah. So there's actually, I have
- 34:02something to touch on that as well.
- 34:03So there's a couple of ways you can even think about storing the
- 34:06way you store your chunks and embeddings can also affect the
- 34:09way that your application works. So a couple of techniques that
- 34:12I've talked about in some of my talks have been like, you can
- 34:17have, you can store larger chunks of data with smaller like
- 34:22with only like maybe one of those sentences embedded and you
- 34:25can use that as the embedding. You can store the entire chunk
- 34:27with it. Then you get more context every
- 34:29time you have, you know, specific things you're looking
- 34:31up. The other way is that you do the
- 34:33reverse. So you sorry, you embed an
- 34:36entire paragraph and maybe you only store a sentence and that
- 34:39way you can get more specific responses to a more generalised
- 34:44query perhaps. So there's a couple different
- 34:47ways to kind of address that as well, just like the way that you
- 34:49store your data. As for the trade off there, you
- 34:54know, I I actually haven't seen this in production.
- 34:56So I'm not, I'm not entirely sure exactly how the trade-offs
- 35:00work, but it sounds like, yeah, like you know, kind of once
- 35:04again, one of the many, many trade-offs that we make here is
- 35:08like compute versus storage or storage versus latency or
- 35:13storage versus quality or you know, things like that.
- 35:15And this is just another one of those things that we'll have to
- 35:18optimise for when we build in production.
- 35:22And along those lines, what are things that you feel like rags
- 35:27are not suited for? Because it feels like you,
- 35:32you've seen a lot of square pegs trying to be fit into round
- 35:37holes, right? Just because it rags our rags
- 35:40and they're the height these days.
- 35:43Yeah, what a rise. Not suited for.
- 35:47I mean really, you can use a RAD for anything you want.
- 35:50I don't know how well it works. Just throw all your data in the
- 35:54vector database and use it for whatever you need.
- 35:56We got you covered. Yeah, exactly.
- 35:59Throw all your data in the middle of this.
- 36:00Use it for whatever you need. We got you covered.
- 36:03Someone asked me the other day, they were like, oh, I wanna be
- 36:06able to map all my users and I want to be able to track all my
- 36:08users and I want to map them based on specific
- 36:11characteristics that I've predefined for them.
- 36:13And so I'm like, well you know, then you're not even looking at
- 36:16unstructured data, you're looking at structured data like
- 36:18go use a SQL database and write an automation.
- 36:22That's what you should do. Yeah, don't come.
- 36:24That's. That's not that's that's a great
- 36:26example of like when to not to use rag.
- 36:28OK, there you go. I don't get a lot of people
- 36:32asking me about so like a lot of people just ask about RAG
- 36:35because it's like familiar, but it's also like different, right?
- 36:39People are like, oh this is like, we've seen this before in
- 36:42like 2013 and like 2000 whatever.
- 36:45Like the chat bots that pop up and people like Ohh, it's a chat
- 36:47bot and it has that familiarity to it.
- 36:51But then when it comes to actually using them and building
- 36:53them and it's like how do you make these better than it's kind
- 36:55of interesting. It's kind of different people
- 36:56like that. So I would say anything that you
- 36:58can think of that you know relates back to chat bots from
- 37:032013, then use RAG to replace that.
- 37:06Things like, oh, actually I have a great example of something
- 37:09that might not need an LM for like similarity search.
- 37:12So I recently talked to somebody who's building some sort of like
- 37:15fashion AI tool and I build like a couple of these myself for fun
- 37:20and one of the. Things from Wait, wait wait
- 37:22wait. You gotta go a little deeper
- 37:25into that fashion. I I didn't take you much as a
- 37:29fashionable guy There. Not.
- 37:30No offence, but I feel like you wear a uniform of a T-shirt and
- 37:38jeans or or sweatpants maybe every day and you're often on
- 37:44your free time building fashion apps.
- 37:46What's going on there? I need more context.
- 37:48I need to do the LLM thing. The rag thing again?
- 37:52I'm not necessarily a fashionable person, but I, I, I,
- 37:58I just like, it's just like a fun thing to mess around with.
- 38:00You know, people, everybody wears clothes and a lot of
- 38:03people wear clothes and they look kind of foolish.
- 38:06And, you know, yes, me too. Like, I get, you know, I I get
- 38:11it. So.
- 38:12But, but, you know, some people wear clothes and they look
- 38:14really nice. Like, I, when I was at a WSI saw
- 38:17this one lady very dressed up. She had like this nice pic code.
- 38:20Like, I don't know, I actually don't know a lot of the words
- 38:22for some of the other things that she was like, wow, this
- 38:24person looks really put together and you like, look, everyone
- 38:26else and everyone else is wearing like a, like a text
- 38:28shirt. Like I'm wearing a tight shirt
- 38:30and like jeans, sweatpants walking around and like, I'm
- 38:33like, oh, OK. I don't know.
- 38:35It's just like, it was just like a thing that kind of like popped
- 38:37into my mind, you know, like it would be cool, it'd be fine.
- 38:40So I'd build wine and. Now we have more context.
- 38:44Yeah. Give me give me what you were
- 38:46gonna say. What was the takeaway?
- 38:47Sorry, I totally derailed that. I had to know.
- 38:50What is the contact there? Yes, yes, yes.
- 38:53You you don't need an LM to convert your picture of a dress
- 38:57into the description that this is a picture of a dress.
- 39:00If you have pictures of dresses in your vector database.
- 39:03So that's an example of something that's not a rag app,
- 39:05doesn't use an LM, still uses the Metro database similarity
- 39:09search. OK, but you're not using Clip or
- 39:12anything like that to get the metadata.
- 39:16Around that you can the the person who built this fine-tuned
- 39:22her own like segmentation model. OK.
- 39:24Nice. I was like, wow, I I I
- 39:27personally wouldn't put that much effort into building a
- 39:29fashion app. But I'm glad that you did,
- 39:31because this is cool. All right, so wait, what did
- 39:34your fashion app do? I basically found like an open
- 39:38source like site, former like you know segmentation
- 39:40transformer thing and it's just like segments out like like like
- 39:44clips like your shirt and your pants and whatever and then it
- 39:47matches it to other pictures. I had a picture, a bunch of
- 39:50pictures of Taylor Swift, a bunch of pictures of like random
- 39:52celebrities and just like put them up there was like match
- 39:54your outfit to Taylor Swift or match your outfit to some random
- 39:57celebrity and just like ohh room in there and I was like,
- 39:59alright, here you go you know. Ohh, I'm gonna go see if I can
- 40:03match my Taylor Swift. Now give me the link for that.
- 40:07What is it? Is it live?
- 40:11All right. We're going to put this in.
- 40:12Ohh. No, it's for anybody.
- 40:13OK. It's on.
- 40:15It's on the back. We will put.
- 40:16That out here in this Fashion V it's actually kind of it's it's
- 40:23yeah, here we go and drop in here.
- 40:24Yes, I love it. This is all.
- 40:27It's not super simple to run. You have to run like the
- 40:30ingestion and then yeah there's like 2 things you have to run.
- 40:32I think like one is like ingest and then the other is like ohh
- 40:35no one is set UK radio fashion the other one's radio fashion
- 40:41and then just you get a nice UI drag and drop.
- 40:45See pictures of Taylor Swift compared to you.
- 40:48Ohh, I love it dude. That's cool.
- 40:50That is really cool. And you didn't need any LM to
- 40:53deal with that, and you don't need to do rags at all for.
- 40:56That no LM not a. Rag need to overcomplicate
- 40:59things you but it's not, is it? Giving you a recommendation of
- 41:02like what you should wear if you want to look like.
- 41:06It's just like, it's just like it's just like your outfit looks
- 41:09kind of like this one. Ohh.
- 41:11It's not that far along. It's not like Ohh.
- 41:14I see. I see.
- 41:15Alright. Cool.
- 41:16I I don't really think that like I'm not really sure that like I
- 41:19would be qualified to be telling anybody like what they should be
- 41:22wearing, you know, need someone with like some some background
- 41:25on that. You know, like, ohh, this
- 41:27person's a fashion designer. OK, that makes sense, right?
- 41:29There you go. And so if you were to make this
- 41:34into a rag app, I feel like you could do a few things where
- 41:38maybe you're recommending it. Is that recommendation on how to
- 41:42you make this outfit look better or look more like Taylor Swift?
- 41:46And then you send it to the LM and it will give some kind of a
- 41:51recommendation. Yes.
- 41:53So first up, this could be, this could be easily a first step
- 41:57into launching A multimodal rag app, right?
- 42:00Like you've got images and you want to do rag, so now you've
- 42:03got text, you've got images. This is perfect to get into
- 42:05multimodal. What you could do is you could
- 42:07have some sort of LM or clip fit or something like that and be
- 42:11like, describe the pictures to me and now you can search the
- 42:14pictures. So instead of putting a picture
- 42:15of yourself and saying finding like, one that's close to
- 42:18whatever Taylor Swift, you can be like, ohh, show me a picture
- 42:21of Taylor Swift performing at a concert in a green dress.
- 42:24And it'll pull like, it'll look at the pictures and it'll pull
- 42:27like, oh, OK, here you go. Or you can give it a picture of
- 42:30you and be like, describe what I'm wearing in this picture and
- 42:33then I'll describe what you're wearing.
- 42:34And then you can be like, find me a picture of Taylor Swift
- 42:36wearing something similar to it, and then it will find a picture
- 42:40of Taylor. So for me, something similar to
- 42:41whatever it is you're. And are there any considerations
- 42:45that we need to be thinking about when it comes to
- 42:47multimodal rags versus just the LLM rags?
- 42:52Ohh man, I think that we are just on the tip of the iceberg
- 42:56with multimodal rags. I think the 2024 right now we're
- 43:00talking about multimodal rags. We're you know no one's, there's
- 43:03not a lot of these have really been built.
- 43:05I haven't seen any in production yet.
- 43:07I think this is the year that a lot of people going to build
- 43:09them. We're going to see a lot of
- 43:10things that people are going to run into.
- 43:12I think one of the problems that we're gonna run into with
- 43:14multimodal rags that I have no solution for that I don't, I
- 43:17haven't heard any solutions for yet is just the fact that there
- 43:21is a likelihood or a possibility or probability.
- 43:24Let's say there's a probability that your LLM is also going to
- 43:28hallucinate on what's in the image.
- 43:30And so now you have two steps of hallucination.
- 43:32So you have a hallucination of what may be returned and a
- 43:36hallucination of what may be in the image.
- 43:38And so I think this is going to be something that is going to be
- 43:41kind of the next like as we as we use the LLM more and more in
- 43:45an application in LLM applications.
- 43:48I think one of the main issues is going to be this issue of
- 43:50reducing compounded hallucinations.
- 43:54Yeah, because if it hallucinates once, then it's going to create
- 43:58downstream effects and it's going to be.
- 44:02Exactly. Less reliable?
- 44:04Yeah, that makes a lot of sense. And then to debug that also is
- 44:08not as straightforward as where did it hallucinate?
- 44:10You have to. You have now two points of
- 44:12failure, not that single area where it could be eliminated.
- 44:17All right, all right. And any other ideas on AS that
- 44:23are of interest when it comes to using multimodal rags?
- 44:27Like, what are some other use cases that you've seen or that
- 44:30you are thinking about? I've heard requests for video
- 44:34search or catalogue search from people.
- 44:37I think video search, if you're gonna do true video search, oof,
- 44:40that's gonna be computationally expensive.
- 44:42That's gonna be tough. Why do you say that?
- 44:44Just cause frame by frame. Yeah, I mean, you know, how many
- 44:49frames do you have and then not. It's not just like the frames,
- 44:52right? Like when you have a video file,
- 44:55it's not just the images, you also have the audio and they
- 44:58have to match up. And so you can't, like you can't
- 45:01individually do image, audio stuff on videos.
- 45:04You have to do on video files, right?
- 45:06I mean, you can try to do it image, audio stuff separately,
- 45:10but you have to work it on the video files themselves and they
- 45:15just take up more space. They're they're they're memory
- 45:17heavy and they have a lot of numbers, so they're naturally
- 45:21compute heavy. So I think that's going to be an
- 45:24interesting space. It's going to be kind of tough.
- 45:27And just so just so we're clear on that one, I feel like the
- 45:31multimodal can be one. Imagine we are having a chat bot
- 45:38that can chat with a movie and you have different parts of this
- 45:45multimodal which is 1 all the frames in the scene.
- 45:49And then you have another which is all of the audio that comes
- 45:53out of that. And then you have another which
- 45:55is like the script that I imagine you could try and get
- 45:59right. So there's all those different
- 46:01pieces that come along with it. Yes, there's the frames, the
- 46:06audio, the script. You can turn the audio into
- 46:10images. Using MFCC you can one thing
- 46:15that I I really would would like to see and I think this is going
- 46:19to be quite tough for people to build is like video to video
- 46:23search. Like I want to know like, hey,
- 46:26like, I see this, alright, this is going to sound, this is going
- 46:30to sound really nerdy. OK, so I'm watching this like
- 46:32Naruto like music video, right? I wanna see where these clips
- 46:36are coming from. What episode is this from?
- 46:39What did I miss? Because a lot of times I'm like,
- 46:40I haven't watched all of this series, but like sometimes like,
- 46:43you know, like, Oh yes, this is cool.
- 46:45Like, we'll watch one of these and then I'll be like, ohh,
- 46:47where's that from, you know? Nice.
- 46:50Yeah. So it's almost like the what we
- 46:52were talking about before where you have citation, you have
- 46:56citation in the. Videos.
- 46:58I'll see citations for videos. Yeah, there you go.
- 47:02Dude, Awesome. A little bit away from that, but
- 47:04it'll be cool, yeah. But I mean a little bit away as
- 47:08in this year or this decade. Ohh, I think it'll I think I I
- 47:14would be surprised if this wasn't solved in this decade.
- 47:19I would not be surprised if they wasn't solved this year.
- 47:22OK. Cool or salt?
- 47:25Mostly Salt, let's say. Yeah, usably.
- 47:27Salt. Usably.
- 47:28Salt. Yeah, that first iteration,
- 47:31dude. Well, this has been fascinating.
- 47:34For everybody out there who wants to play around with the
- 47:37pipelines that you were talking about, we can just go to
- 47:41silas.com/pipelines or Google. Pipeline for You can just
- 47:47cloud.com sign up for a free account if you spin up one of
- 47:51the serverless options, The serverless options, the free
- 47:54option, you get immediate access to pipelines and it's in the UI.
- 47:58You can click around and build your own.
- 48:00Excellent. And if you do that, make sure
- 48:03they send out. I think you mentioned you send
- 48:06out a feedback form to anyone that does that.
- 48:11And so in that feedback form let them know that you listen to
- 48:15this crazy chat that you did and I just had and let them know
- 48:19that we sent you over that way. It would be great to to hear
- 48:25that. Man.
- 48:27I am still impressed that you can build fire and I appreciate
- 48:31you coming on here and talking with me.
- 48:33This was brilliant. Hey, Lazlo here.
- 48:39If you're serious about Emma Lops, you hit subscribe, right?
- 48:42Now.