WEBVTT

00:00:30.679 --> 00:00:35.719
<v Andreas Welsch>Today, we'll talk about how you can augment your generative AI model with new data.

00:00:36.479 --> 00:00:41.619
<v Andreas Welsch>And who better to talk about it than someone who's actively teaching others how to do that.

00:00:41.619 --> 00:00:42.810
<v Andreas Welsch>Hapreet Sahota.

00:00:43.179 --> 00:00:44.869
<v Andreas Welsch>Hey, Hapreet, thank you so much for joining.

00:00:46.019 --> 00:00:47.019
<v Harpreet Sahota>Thank you for having me, Andreas.

00:00:47.019 --> 00:00:47.619
<v Harpreet Sahota>Good to be here.

00:00:48.549 --> 00:00:52.230
<v Andreas Welsch>Why don't you tell our audience a little bit about yourself, who you are, and what you do?

00:00:53.310 --> 00:00:53.939
<v Harpreet Sahota>Yeah, definitely.

00:00:54.209 --> 00:00:57.189
<v Harpreet Sahota>I'm currently working in developer relations.

00:00:57.189 --> 00:01:00.289
<v Harpreet Sahota>I've been in the DevRel kind of space for about two and a half years.

00:01:00.570 --> 00:01:01.459
<v Harpreet Sahota>Right now, I'm at Deci.

00:01:01.480 --> 00:01:01.969
<v Harpreet Sahota>AI.

00:01:02.619 --> 00:01:04.349
<v Harpreet Sahota>Before this, I was at Pachyderm and Comet.

00:01:06.060 --> 00:01:10.900
<v Harpreet Sahota>In the eight years before I got into DevRel, I was a practitioner, a data scientist.

00:01:10.900 --> 00:01:16.310
<v Harpreet Sahota>I've worked as an actuary, biostatistician senior data scientist, lead data scientist.

00:01:16.969 --> 00:01:20.140
<v Harpreet Sahota>So definitely been quantitative for quite some time.

00:01:20.739 --> 00:01:27.819
<v Harpreet Sahota>In addition to that, I've got some LinkedIn Learning courses that I've done: one on computer vision, one that I'm going to be actively recording next month.

00:01:27.879 --> 00:01:29.280
<v Harpreet Sahota>That's all about LangChain.

00:01:29.299 --> 00:01:33.549
<v Harpreet Sahota>And another one that's using LlamaIndex for retrieval augmented generation.

00:01:34.605 --> 00:01:36.734
<v Harpreet Sahota>So yeah, that's just the me in a nutshell.

00:01:37.854 --> 00:01:38.584
<v Andreas Welsch>It's awesome.

00:01:39.054 --> 00:01:43.334
<v Andreas Welsch>I know you're super passionate about the topic and about helping others learn about it.

00:01:43.334 --> 00:01:49.924
<v Andreas Welsch>And what you mentioned just now about Retrieval Augmented Generation, that really fits the theme and the topic of today's episode.

00:01:50.444 --> 00:01:51.724
<v Andreas Welsch>So, super excited to have you on.

00:01:52.614 --> 00:01:52.795
<v Harpreet Sahota>Yeah.

00:01:52.894 --> 00:01:58.004
<v Andreas Welsch>For those of you in the audience, if you're just joining the stream, drop a comment in the chat where you're joining us from today.

00:01:58.094 --> 00:02:00.875
<v Andreas Welsch>I'm always curious to see how global our audience is.

00:02:01.254 --> 00:02:03.454
<v Andreas Welsch>Should we play a little game to kick things off?

00:02:04.564 --> 00:02:05.574
<v Harpreet Sahota>Yeah, let's do it, man.

00:02:05.655 --> 00:02:06.185
<v Harpreet Sahota>Let's do it.

00:02:07.004 --> 00:02:07.564
<v Andreas Welsch>Perfect.

00:02:07.584 --> 00:02:10.835
<v Andreas Welsch>Alright, so this game is called In Your Own Words.

00:02:11.585 --> 00:02:15.104
<v Andreas Welsch>And when I hit the buzzer, the wheels will start spinning.

00:02:15.265 --> 00:02:17.875
<v Andreas Welsch>And when they stop, you see a sentence.

00:02:17.925 --> 00:02:21.074
<v Andreas Welsch>And I'd like you to complete that in your own words.

00:02:21.944 --> 00:02:24.455
<v Andreas Welsch>You only have 60 seconds to make it a little more interesting.

00:02:25.675 --> 00:02:27.824
<v Andreas Welsch>Are you ready for What's the Buzz?

00:02:29.224 --> 00:02:30.164
<v Harpreet Sahota>Ready as I'll ever be.

00:02:30.305 --> 00:02:30.865
<v Harpreet Sahota>Let's do it.

00:02:31.504 --> 00:02:32.224
<v Andreas Welsch>Perfect.

00:02:33.960 --> 00:02:38.439
<v Andreas Welsch>If AI were a month of the year, what would it be?

00:02:39.129 --> 00:02:40.469
<v Andreas Welsch>60 seconds, go.

00:02:41.669 --> 00:02:45.990
<v Harpreet Sahota>I think AI would be the month of May, because people always talk about AI winters.

00:02:46.379 --> 00:02:48.460
<v Harpreet Sahota>But when an AI winter comes through, what do we have?

00:02:48.460 --> 00:02:49.699
<v Harpreet Sahota>We have the month of May.

00:02:50.199 --> 00:02:51.250
<v Harpreet Sahota>When it's cold outside...

00:02:51.740 --> 00:02:52.629
<v Harpreet Sahota>We got the month of May.

00:02:52.729 --> 00:02:55.609
<v Harpreet Sahota>May is the beginning of spring and that is where we are in AI right now.

00:02:55.639 --> 00:02:58.419
<v Harpreet Sahota>We are in the spring of AI.

00:02:58.460 --> 00:03:01.090
<v Harpreet Sahota>So what better month for AI to be than May?

00:03:02.139 --> 00:03:03.030
<v Andreas Welsch>That's perfect.

00:03:03.079 --> 00:03:10.180
<v Andreas Welsch>I'm already looking forward again to spring before it gets cold here on the east coast in the US.

00:03:10.180 --> 00:03:11.030
<v Andreas Welsch>Really like that answer.

00:03:11.159 --> 00:03:11.620
<v Andreas Welsch>Awesome.

00:03:13.844 --> 00:03:18.384
<v Andreas Welsch>By the way, folks in the audience, if you have questions for Harpreet, feel free to pop them in the chat as well.

00:03:18.444 --> 00:03:20.064
<v Andreas Welsch>We'll go through them in a few minutes.

00:03:20.604 --> 00:03:24.074
<v Andreas Welsch>But maybe we can kick things off with our first question.

00:03:24.125 --> 00:03:28.504
<v Andreas Welsch>There's been a lot of talk about off the shelf models having a cut off date.

00:03:28.525 --> 00:03:35.125
<v Andreas Welsch>Think of things like GPT-3.5 or 4 generating just generic content.

00:03:35.659 --> 00:03:41.060
<v Andreas Welsch>Sure, you can fix a lot of things with better prompting, but there are limitations in these off the shelf models.

00:03:41.699 --> 00:03:45.729
<v Andreas Welsch>On the other hand, you have fine-tuning, which is resource and budget intensive.

00:03:46.819 --> 00:03:52.240
<v Andreas Welsch>I think over the last couple of months, especially, one approach that's emerged that seems to me like it's a middle ground.

00:03:52.319 --> 00:03:54.500
<v Andreas Welsch>You already mentioned it in your intro.

00:03:54.769 --> 00:03:57.079
<v Andreas Welsch>Retrieval Augmented Generation, RAG.

00:03:57.840 --> 00:04:01.889
<v Andreas Welsch>I was wondering, from your point of view, what's the benefit and what is it even about?

00:04:02.394 --> 00:04:03.064
<v Andreas Welsch>Maybe to begin with.

00:04:04.514 --> 00:04:18.500
<v Harpreet Sahota>First, let's talk about the differences between fine-tuning and RAG, touching on some of the technical aspects of them at a high level and then get into some of the benefits of using RAG and then just close on when do you switch.

00:04:18.949 --> 00:04:20.259
<v Harpreet Sahota>So what is fine-tuning?

00:04:20.280 --> 00:04:28.019
<v Harpreet Sahota>So fine-tuning basically means that you're updating a pre-trained model's weights via backpropagation on either a domain or task-specific dataset, right?

00:04:28.650 --> 00:04:37.980
<v Harpreet Sahota>So when you do this, you end up refining the broad knowledge that the model has learned during its initial pre-training, and you're now adapting its behavior to a specific task or domain.

00:04:38.129 --> 00:04:39.470
<v Harpreet Sahota>So I think about it this way.

00:04:39.470 --> 00:04:42.949
<v Harpreet Sahota>I have a graduate degree in mathematics and a graduate degree in statistics.

00:04:43.210 --> 00:04:44.370
<v Harpreet Sahota>Tons of quantitative knowledge.

00:04:44.860 --> 00:04:48.060
<v Harpreet Sahota>But I need to fine-tune my knowledge for machine learning somehow.

00:04:48.060 --> 00:04:51.250
<v Harpreet Sahota>So I train and study and learn up on books.

00:04:52.110 --> 00:04:56.319
<v Harpreet Sahota>And that kind of fine-tuned my worldview for machine learning and AI.

00:04:57.600 --> 00:04:59.779
<v Harpreet Sahota>And that's how I like to think about RAG.

00:04:59.839 --> 00:05:06.290
<v Harpreet Sahota>Like I've got general quantitative skills but those quantitative skills might not directly map to AI or ML.

00:05:06.350 --> 00:05:07.500
<v Harpreet Sahota>I need further training on that.

00:05:08.529 --> 00:05:14.709
<v Harpreet Sahota>But the thing with RAG is that you need technical expertise to get started with fine-tuning.

00:05:14.730 --> 00:05:27.459
<v Harpreet Sahota>So everything from data curation to managing computational resources, to understanding how to allocate and utilize those resources, all the way down to how do we set up the right evaluation metrics to assess the model performance.

00:05:28.009 --> 00:05:30.969
<v Harpreet Sahota>So fine-tuning really is a model training kind of pipeline.

00:05:31.709 --> 00:05:34.719
<v Harpreet Sahota>You have to prepare, curate, and manage high quality data.

00:05:34.740 --> 00:05:37.060
<v Harpreet Sahota>You've got to clean and pre-process the data.

00:05:37.409 --> 00:05:42.360
<v Harpreet Sahota>You need to select a base model as your kind of foundation that you're going to build on.

00:05:42.959 --> 00:05:43.980
<v Harpreet Sahota>Then you've got to train the model.

00:05:44.029 --> 00:05:46.110
<v Harpreet Sahota>You've got to adjust the weights on that new data set.

00:05:46.839 --> 00:05:48.709
<v Harpreet Sahota>Then evaluate the performance and finally deploy it.

00:05:48.759 --> 00:05:51.329
<v Harpreet Sahota>So it's a machine learning task at the end of the day.

00:05:51.610 --> 00:06:04.649
<v Harpreet Sahota>Retrieval Augmented Generation though this is combining So now instead of just solely being reliant on its internal training data, you have the model query some external database for relevant knowledge.

00:06:05.149 --> 00:06:07.490
<v Harpreet Sahota>So that's going to help assist in generating a response.

00:06:07.569 --> 00:06:11.939
<v Harpreet Sahota>I've got a ton of books back there, right behind me, touching all the quantitative topics that I know.

00:06:11.969 --> 00:06:14.589
<v Harpreet Sahota>Sometimes I just need a quick refresher on some topics.

00:06:14.610 --> 00:06:16.149
<v Harpreet Sahota>I need to get some additional context.

00:06:16.600 --> 00:06:17.339
<v Harpreet Sahota>I'll grab a book.

00:06:17.350 --> 00:06:20.139
<v Harpreet Sahota>I'll look it up and then I'll bake it into whatever it is I'm doing.

00:06:20.449 --> 00:06:22.569
<v Harpreet Sahota>So that's the kind of retrieval augmented generation there.

00:06:23.699 --> 00:06:34.790
<v Harpreet Sahota>And so implementing this requires a medium level of technical expertise because you're having to encode your data into embeddings, then you have to index that into a vector database.

00:06:35.310 --> 00:06:51.620
<v Harpreet Sahota>And so then when a user is posing a query, you need to convert that query into an embedding, and then have a system that kind of searches your vector database for similar embeddings, retrieves those embeddings, and then injects it into a prompt that can give the LLM more context so it can answer the user's query.

00:06:53.389 --> 00:06:57.370
<v Harpreet Sahota>So there's a number of things you need to get started with RAG.

00:06:57.600 --> 00:07:02.159
<v Harpreet Sahota>One, there's really no training pipeline at a high level.

00:07:02.159 --> 00:07:05.920
<v Harpreet Sahota>You can always fine-tune your embeddings and things like that, but we're not going to discuss that here.

00:07:06.100 --> 00:07:08.579
<v Harpreet Sahota>But there's really no model training that's going on.

00:07:09.779 --> 00:07:15.009
<v Harpreet Sahota>You need a data ingestion pipeline, data storage, you need embeddings, you need a vector database.

00:07:15.050 --> 00:07:21.319
<v Harpreet Sahota>So then your system design or pipeline for RAG is essentially five components.

00:07:21.339 --> 00:07:22.730
<v Harpreet Sahota>You've got the indexing pipeline.

00:07:22.969 --> 00:07:26.939
<v Harpreet Sahota>So this is just a way to index data into your vector database.

00:07:27.029 --> 00:07:34.069
<v Harpreet Sahota>You've got your user's query because you need to transform the user's query to an embedding so that you can search for the relevant documents in the database.

00:07:34.159 --> 00:07:36.060
<v Harpreet Sahota>Then there's the retrieval aspect of it.

00:07:36.689 --> 00:07:39.959
<v Harpreet Sahota>So how do you extract relevant data based on the user's query?

00:07:40.814 --> 00:07:44.745
<v Harpreet Sahota>So you can use some classical information retrieval techniques.

00:07:44.795 --> 00:07:54.194
<v Harpreet Sahota>You can do cosine similarity, you can do bn25, whatever you choose so that you can comb through this database and retrieve the relevant vectors for your user's query.

00:07:55.305 --> 00:07:59.764
<v Harpreet Sahota>But then even once the doc, once those vectors are retrieved, you need a way to select the right vectors, right?

00:07:59.764 --> 00:08:08.920
<v Harpreet Sahota>Because you want to be able to filter out those less relevant documents from those retrieved documents so that you can have better context for your model.

00:08:11.110 --> 00:08:22.649
<v Harpreet Sahota>I hope it's becoming clear how RAG is overcoming the limitations of fine-tuning, but just to make it absolutely clear we can start by stating like the biggest limitations of a pre-trained model.

00:08:22.699 --> 00:08:24.990
<v Harpreet Sahota>You mentioned before fixed knowledge cutoff dates.

00:08:25.159 --> 00:08:28.829
<v Harpreet Sahota>So this is going to lead to outdated or stale responses.

00:08:29.029 --> 00:08:38.345
<v Harpreet Sahota>And then there's also a tendency for a language model to generate just overly generic or broad content because of its generalized training.

00:08:38.764 --> 00:08:41.325
<v Harpreet Sahota>And so this is where RAG steps in, right?

00:08:41.335 --> 00:08:48.524
<v Harpreet Sahota>RAG is able to query a database and make sure that the responses that we're getting are now timely, they're relevant, they're factual.

00:08:49.514 --> 00:08:58.435
<v Harpreet Sahota>It's also helping to augment the capabilities of a large language model, because now we're going to be able to get more informed context aware answers.

00:08:58.784 --> 00:09:01.555
<v Harpreet Sahota>You could also use RAG to do kind of source attribution as well.

00:09:04.174 --> 00:09:09.365
<v Harpreet Sahota>And I guess the last thing I need to talk to you about was like a general framework of when to choose what, right?

00:09:10.575 --> 00:09:21.634
<v Harpreet Sahota>So when it comes to fine-tuning, the questions you need to be asking yourself is, okay, do I want a model that needs to have deep domain understanding or specificity in a particular topic?

00:09:22.014 --> 00:09:24.004
<v Harpreet Sahota>If yes, maybe go with fine-tuning.

00:09:24.845 --> 00:09:30.809
<v Harpreet Sahota>If you need consistent or predictable behavior in the pattern of responses, then go with fine-tuning.

00:09:31.350 --> 00:09:45.850
<v Harpreet Sahota>If you got a ton of domain-specific data that you can use to tune a model so that model can make better decisions or produce more consistent output beyond what you can do with prompting a few shot examples, then you might need fine-tuning.

00:09:45.870 --> 00:09:49.000
<v Harpreet Sahota>And RAG, you would use RAG, Retrieval Augmented Generation.

00:09:49.450 --> 00:09:57.419
<v Harpreet Sahota>If you have a use case where an LLM needs access to real time current data, knowledge, information, all that.

00:09:58.429 --> 00:10:09.490
<v Harpreet Sahota>If your application requires like broad, general, topical coverage or the ability to adapt its responses, but just needs access to new data, then RAG is a good one as well.

00:10:10.620 --> 00:10:13.279
<v Harpreet Sahota>Yeah, it's just a cost-effective, scalable solution.

00:10:13.980 --> 00:10:17.850
<v Harpreet Sahota>So it doesn't really require any constant retraining, just constantly retrieving.

00:10:19.679 --> 00:10:20.090
<v Andreas Welsch>Awesome.

00:10:20.350 --> 00:10:21.990
<v Andreas Welsch>Thank you for walking us through that.

00:10:21.990 --> 00:10:28.689
<v Andreas Welsch>I think it's always important to level set on what are the different terms and techniques that we're talking about anyways.

00:10:29.149 --> 00:10:32.509
<v Andreas Welsch>And then in this case, specifically, what are the pros and cons?

00:10:32.549 --> 00:10:40.825
<v Andreas Welsch>And if I look at use cases in business, it's rarely about just general and generic information.

00:10:40.865 --> 00:10:42.884
<v Andreas Welsch>It's about proprietary information.

00:10:43.075 --> 00:10:48.034
<v Andreas Welsch>It's about information that's specific to your business, maybe to your products, to your services.

00:10:48.335 --> 00:10:52.274
<v Andreas Welsch>So you have that, but you might not necessarily have that stored somewhere in the database.

00:10:52.304 --> 00:10:54.754
<v Andreas Welsch>Maybe it's in a file or it's in a bunch of files.

00:10:54.754 --> 00:10:59.804
<v Andreas Welsch>Maybe it's a policy or it's an FAQ document or many other things.

00:10:59.814 --> 00:11:16.139
<v Andreas Welsch>So I think that's where, to your point, this can really play out its strength while being a happy medium between the power of natural language generation and the depth and relevance of the information that the model itself doesn't have access to.

00:11:16.289 --> 00:11:18.129
<v Andreas Welsch>Awesome, thank you for walking us through that.

00:11:18.960 --> 00:11:19.830
<v Harpreet Sahota>Yeah, no problem.

00:11:19.929 --> 00:11:24.804
<v Andreas Welsch>I think data has always been a problem when you're building your own model.

00:11:24.804 --> 00:11:30.445
<v Andreas Welsch>I think you alluded to parts of that earlier, that you obviously need data, you need your own data.

00:11:30.455 --> 00:11:43.314
<v Andreas Welsch>It comes in different shapes and forms, maybe it's structured, maybe it's unstructured, but how does the requirement for data or good data change or maybe even stay the same when you're looking at things like RAG?

00:11:44.674 --> 00:11:47.264
<v Harpreet Sahota>Oh, it's like the least important part of the equation.

00:11:47.264 --> 00:11:48.475
<v Harpreet Sahota>Obviously, I'm joking, right?

00:11:48.534 --> 00:11:49.325
<v Harpreet Sahota>Obviously, I'm joking.

00:11:51.254 --> 00:11:54.085
<v Harpreet Sahota>Remember, yes, let's talk about, remember, what does RAG do?

00:11:54.085 --> 00:12:00.284
<v Harpreet Sahota>RAG is combining our model with an external data that's going to be retrieved based on a user's query or context, right?

00:12:00.585 --> 00:12:11.304
<v Harpreet Sahota>It goes without saying that the quality of data in that external repository or database that your RAG system is going to interface with is extremely, absolutely critical.

00:12:11.835 --> 00:12:12.404
<v Harpreet Sahota>And why?

00:12:12.610 --> 00:12:18.830
<v Harpreet Sahota>Because the performance of RAG is going to be directly influenced by the quality and relevance of that document store.

00:12:19.230 --> 00:12:29.159
<v Harpreet Sahota>So if that corpus of data you have contains outdated or irrelevant documents, then your generations are going to look not good.

00:12:29.179 --> 00:12:30.480
<v Harpreet Sahota>They're going to lack accuracy.

00:12:30.960 --> 00:12:37.039
<v Harpreet Sahota>So you can think of this actually as the same song that Andrew Ng has been singing about data-centric AI.

00:12:37.090 --> 00:12:44.340
<v Harpreet Sahota>We're holding the LLM and the embedding model fixed, and we're just iterating on the data that we can shove into the context window of the LLM.

00:12:46.840 --> 00:12:51.279
<v Harpreet Sahota>Just concretely talking about a few ways that data quality can impact a RAG system.

00:12:51.490 --> 00:12:53.220
<v Harpreet Sahota>One is the accuracy of responses.

00:12:53.320 --> 00:12:56.379
<v Harpreet Sahota>To get accurate responses, you need accurate data.

00:12:56.439 --> 00:13:03.835
<v Harpreet Sahota>So high quality, accurate data is going to allow your language model, whatever one you're using, to generate more reliable and accurate responses.

00:13:03.904 --> 00:13:10.975
<v Harpreet Sahota>If that external data is outdated or inaccurate, then the LLM's generation is going to reflect that.

00:13:12.735 --> 00:13:15.825
<v Harpreet Sahota>Then there's the issue of the relevance of the retrieved documents.

00:13:15.894 --> 00:13:21.434
<v Harpreet Sahota>Because it's just crucial for generating meaningful and contextually appropriate responses.

00:13:21.485 --> 00:13:32.195
<v Harpreet Sahota>So high quality data, organized, properly tagged with metadata, is going to result in more relevant information being retrieved out of your database and utilized in the generation process.

00:13:32.965 --> 00:13:43.909
<v Harpreet Sahota>Efficiency and speed, obviously, if you have well structured, clean data, then it means that it will be more quick to be retrieved easier to index.

00:13:43.980 --> 00:13:50.460
<v Harpreet Sahota>This is going to lead to lower retrieval latency, faster response times, and less computational overhead, of course.

00:13:51.220 --> 00:13:53.159
<v Harpreet Sahota>Trustworthiness is another huge key.

00:13:53.279 --> 00:14:06.034
<v Harpreet Sahota>If you have a high amount, you better have a high amount of trust in that external data because this is going to impact again the trustworthiness of the generated response and this again goes back to the quality of the external data.

00:14:07.835 --> 00:14:09.504
<v Harpreet Sahota>Data freshness is key as well.

00:14:09.524 --> 00:14:13.059
<v Harpreet Sahota>So just make sure that the external database remains up to date.

00:14:13.850 --> 00:14:18.779
<v Harpreet Sahota>This is crucial for RAG so yeah, high quality data is crucial.

00:14:19.059 --> 00:14:20.429
<v Harpreet Sahota>You have to spend some time cleaning data.

00:14:20.460 --> 00:14:51.419
<v Harpreet Sahota>Like I recently wrote a blog post where I was using LlamaIndex to I was doing like a crash course in LlamaIndex using using our Deci LM with the state of AI 2023 report.

00:14:52.799 --> 00:15:04.889
<v Harpreet Sahota>And as I converted each slide into a document, I noticed that, okay, every single slide has like the header and the footer, and it's just a lot of extra data that would be clogging my vector database.

00:15:04.899 --> 00:15:06.729
<v Harpreet Sahota>So you have to go through, clean it, parse it.

00:15:08.449 --> 00:15:11.114
<v Harpreet Sahota>Yeah, so data quality is definitely, definitely crucial.

00:15:13.054 --> 00:15:13.495
<v Andreas Welsch>Awesome.

00:15:14.495 --> 00:15:16.614
<v Andreas Welsch>There was another question in the chat.

00:15:16.614 --> 00:15:19.144
<v Andreas Welsch>Can we combine fine-tuning with RAG?

00:15:19.154 --> 00:15:20.844
<v Andreas Welsch>And if yes, how does it work?

00:15:21.334 --> 00:15:25.224
<v Andreas Welsch>I think that's a really good question because with different different techniques, right?

00:15:25.224 --> 00:15:28.034
<v Andreas Welsch>The question is, can you layer them on top of each other?

00:15:28.084 --> 00:15:29.814
<v Andreas Welsch>Does one replace the other?

00:15:30.844 --> 00:15:31.794
<v Andreas Welsch>What would you say there?

00:15:32.009 --> 00:15:32.829
<v Andreas Welsch>What do you recommend?

00:15:32.839 --> 00:15:35.169
<v Harpreet Sahota>Yeah, that's a good question.

00:15:36.219 --> 00:15:38.359
<v Harpreet Sahota>And I don't know if my answer will be a good one.

00:15:38.359 --> 00:15:41.089
<v Harpreet Sahota>When I think of fine-tuning, I think of changing the behavior of a model.

00:15:41.239 --> 00:15:45.879
<v Harpreet Sahota>I'm not necessarily fine-tuning to augment the parametric knowledge of a model.

00:15:45.929 --> 00:15:48.399
<v Harpreet Sahota>You want to fine-tune to change the behavior of a model.

00:15:48.979 --> 00:15:54.809
<v Harpreet Sahota>Whereas RAG, it's injecting new knowledge into the context window of an LLM.

00:15:55.379 --> 00:16:04.000
<v Harpreet Sahota>But that being said, you can fine-tune your embeddings model over your particular document corpus so that you get more relevant retrievals.

00:16:04.839 --> 00:16:09.804
<v Harpreet Sahota>So in that sense, yes you can combine combined fine-tuning with RAG.

00:16:11.924 --> 00:16:22.464
<v Harpreet Sahota>I haven't seen any papers or read much about actual fine-tuning to change the behavior combined with RAG, but there's so much happening in this space that it's hard for me to keep up.

00:16:23.114 --> 00:16:24.294
<v Harpreet Sahota>So if anybody has links to that.

00:16:24.924 --> 00:16:25.454
<v Harpreet Sahota>Let me know.

00:16:27.154 --> 00:16:39.789
<v Andreas Welsch>So obviously we're a lot more technical in today's episode than we typically are, but I think it's important to also cover these aspects and more and more of these aspects as the field matures as we go through different techniques.

00:16:39.839 --> 00:16:44.389
<v Andreas Welsch>I feel earlier in the year, it was all about, hey, you should prompt your model and don't think about fine-tuning.

00:16:44.409 --> 00:16:48.849
<v Andreas Welsch>And I didn't see a lot of people talk about retrieval augmented generation.

00:16:48.849 --> 00:16:53.129
<v Andreas Welsch>Now I feel that's shifted, especially as there's more adoption, there's more exploration.

00:16:53.129 --> 00:16:54.120
<v Andreas Welsch>What can we do with it?

00:16:54.479 --> 00:16:55.809
<v Andreas Welsch>Where are the opportunities?

00:16:55.809 --> 00:16:56.939
<v Andreas Welsch>Where are the limitations?

00:16:57.039 --> 00:16:57.329
<v Andreas Welsch>I don't know.

00:16:57.329 --> 00:17:00.079
<v Andreas Welsch>Maybe we'll talk about fine-tuning a couple of months from now.

00:17:00.089 --> 00:17:00.879
<v Andreas Welsch>Who knows?

00:17:01.339 --> 00:17:11.345
<v Andreas Welsch>But since we're already talking about this foundational layer in the technology, are there specific models that you see that are best suited for RAG?

00:17:11.345 --> 00:17:17.595
<v Andreas Welsch>Can I just use my GPT-3.5 or GPT-4 or Claude, or others?

00:17:18.134 --> 00:17:18.995
<v Andreas Welsch>What do you see?

00:17:19.075 --> 00:17:20.545
<v Andreas Welsch>What's best suited for RAG?

00:17:21.944 --> 00:17:28.835
<v Harpreet Sahota>You can broadly categorize large language models into two categories There's the base LLM and then there's instruction-tuned LLMs.

00:17:30.134 --> 00:17:31.055
<v Harpreet Sahota>So base LLM.

00:17:31.289 --> 00:17:34.460
<v Harpreet Sahota>It's just designed to predict the next word based on the training data.

00:17:34.460 --> 00:17:38.870
<v Harpreet Sahota>So they're not really designed to answer questions or carry out a conversation or help you solve a problem.

00:17:38.920 --> 00:17:45.890
<v Harpreet Sahota>If you just feed a bunch of context into a base LLM it's just going to try to complete the next token, right?

00:17:45.900 --> 00:17:51.115
<v Harpreet Sahota>For however many tokens you have to generate for and this is different from the instruction tuned LLM.

00:17:51.164 --> 00:18:02.445
<v Harpreet Sahota>So an instruction-tuned LLM instead of trying to auto complete your text, it's going to try to follow the given instructions using the data that they've been trained on, plus whatever context you provide it with.

00:18:04.375 --> 00:18:17.725
<v Harpreet Sahota>So in that sense, opt for an instruction-tuned or a chat-tuned model for LLM, because if you try to shove a bunch of context into a base LLM, you'll end up with not the result that you're looking for.

00:18:18.725 --> 00:18:24.674
<v Andreas Welsch>What would be some examples of instruction-tuned versus the other option you mentioned here?

00:18:25.845 --> 00:18:31.935
<v Harpreet Sahota>So GPT-3, the original GPT-3, that's that's a base LLM.

00:18:31.995 --> 00:18:33.195
<v Harpreet Sahota>It's a completion model.

00:18:34.095 --> 00:18:41.485
<v Harpreet Sahota>If you look at any of the major releases that happened, whether it's Llama, Mistral, Deci LM there's always two different models that you'll see.

00:18:41.485 --> 00:18:45.525
<v Harpreet Sahota>You'll have one be the base model, And then one be the instruction-tuned model.

00:18:48.045 --> 00:18:54.835
<v Harpreet Sahota>All models that are out there that I've seen released in the last few months we'll have that release pattern base model with the instruction-tuned model.

00:18:55.875 --> 00:18:56.285
<v Andreas Welsch>Awesome.

00:18:57.904 --> 00:19:09.945
<v Andreas Welsch>So to make it actionable and make it concrete, because I know a lot of leaders are watching the show and people who want to move into leadership positions are in an expert role right now.

00:19:10.525 --> 00:19:11.394
<v Andreas Welsch>What's your advice?

00:19:11.414 --> 00:19:15.315
<v Andreas Welsch>How can leaders and experts get started with RAG?

00:19:15.355 --> 00:19:22.160
<v Andreas Welsch>What do they need to know if they're either just hearing it for the first time or want to learn more about it and go more in depth.

00:19:23.810 --> 00:19:27.539
<v Harpreet Sahota>For leaders, definitely first and foremost, just what does RAG actually allows you to do.

00:19:27.590 --> 00:19:33.210
<v Harpreet Sahota>Remember it allows an LLM to retrieve real time data from external databases at inference time.

00:19:33.320 --> 00:19:36.990
<v Harpreet Sahota>So instead of just solely relying on parametric or pre-trained knowledge.

00:19:37.990 --> 00:19:44.660
<v Harpreet Sahota>Also like any technology, it's essential to approach your implementation of it thoughtfully.

00:19:45.740 --> 00:19:51.009
<v Harpreet Sahota>So I guess just at a high level, like leaders for sure would be just know a little bit about the system design, right?

00:19:51.029 --> 00:19:59.350
<v Harpreet Sahota>That there's data pipelines that you gotta think about continuously updating and pre-processing the data for retrieval for your LLM.

00:20:00.515 --> 00:20:02.495
<v Harpreet Sahota>The embeddings and indexing, right.

00:20:02.495 --> 00:20:07.325
<v Harpreet Sahota>Because we have to convert data to vector representations and then index that into a vector database.

00:20:08.160 --> 00:20:13.125
<v Harpreet Sahota>Understanding just the advantages of RAG in terms of like cost efficiency.

00:20:13.195 --> 00:20:19.835
<v Harpreet Sahota>Because there's lower upfront investment compared to fine-tuning data security is obviously always critical.

00:20:22.424 --> 00:20:23.865
<v Harpreet Sahota>Technical complexity.

00:20:23.965 --> 00:20:30.465
<v Harpreet Sahota>We talked about how RAG doesn't require as much technical expertise as fine-tuning a model.

00:20:32.565 --> 00:20:36.205
<v Harpreet Sahota>And just maybe strategic kind of implementation for it.

00:20:37.674 --> 00:20:44.715
<v Harpreet Sahota>Because RAG is nice because we have a balance of real time data access with computational efficiency.

00:20:45.715 --> 00:20:53.485
<v Harpreet Sahota>But in order to successfully deploy it, you need to have really solid data infrastructure and all that comes with that.

00:20:54.495 --> 00:20:57.134
<v Harpreet Sahota>Also just pros and cons of each.

00:20:58.230 --> 00:21:07.960
<v Harpreet Sahota>When we talk about fine-tuning some of the pros and cons, fine-tuning you get more uniform and predictable responses because you're training it to behave in a particular way.

00:21:08.880 --> 00:21:17.310
<v Harpreet Sahota>We can also get a little bit of more domain expertise because the model's going to gain proficiency in a targeted area or a specific domain.

00:21:18.240 --> 00:21:23.759
<v Harpreet Sahota>You'll get more influence over the model's output because it's conditioned by the data that it's trained on.

00:21:25.120 --> 00:21:26.730
<v Harpreet Sahota>There's some cons of that as well.

00:21:27.005 --> 00:21:34.835
<v Harpreet Sahota>It's resource intensive it requires a ton of data, large volumes of high quality domain specific data.

00:21:35.985 --> 00:21:37.914
<v Harpreet Sahota>There's also the risk of overfitting.

00:21:39.445 --> 00:21:53.505
<v Harpreet Sahota>You can train a model to the point of what's called catastrophic forgetting, where it becomes overly specified, specialized, and might even forget things or lose its broader applicability.

00:21:53.595 --> 00:21:55.654
<v Harpreet Sahota>RAG also has pros and cons.

00:21:56.505 --> 00:21:58.865
<v Harpreet Sahota>Pros is definitely that dynamic knowledge, right?

00:21:58.865 --> 00:22:01.105
<v Harpreet Sahota>We have access to continuously updated data.

00:22:02.115 --> 00:22:06.115
<v Harpreet Sahota>We can adjust the model's responses based on the data that we're retrieving.

00:22:07.674 --> 00:22:12.664
<v Harpreet Sahota>And that helps reduce the, that Tendency for an LLM to give like a generic answer.

00:22:13.325 --> 00:22:25.785
<v Harpreet Sahota>It's a lot more cost efficient as well, because we don't need to constantly fine-tune or do any kind of resource intensive work, because we're essentially just querying an external database.

00:22:26.664 --> 00:22:30.325
<v Harpreet Sahota>RAG's not without its cons either, right?

00:22:32.085 --> 00:22:43.029
<v Harpreet Sahota>There is still a complex system, because we have an additional layer of complexity on top of just the language model, because now we've got that retrieval later as well.

00:22:43.080 --> 00:22:46.920
<v Harpreet Sahota>So that's gonna have that additional bit of complexity.

00:22:46.920 --> 00:22:52.815
<v Harpreet Sahota>There's also things you need to keep in mind in terms of data relevance.

00:22:52.914 --> 00:23:06.375
<v Harpreet Sahota>You need to constantly update that data store so that the retrieved documents are relevant, so that could make that kind of maintenance process ongoing and could possibly get demanding.

00:23:08.515 --> 00:23:10.835
<v Harpreet Sahota>There's a number of other things you need to worry about.

00:23:11.835 --> 00:23:16.105
<v Harpreet Sahota>How do we actually index data is a thing in RAG.

00:23:16.154 --> 00:23:22.095
<v Harpreet Sahota>Because a user's query might not actually align semantically with the documents that we have.

00:23:23.695 --> 00:23:25.055
<v Harpreet Sahota>How does similarity search work, right?

00:23:25.055 --> 00:23:34.575
<v Harpreet Sahota>Similarity search is often going to retrieve documents that have the same words or context as the question, but sometimes those documents are not going to have meaningful answers to the user's query, right?

00:23:34.924 --> 00:23:37.810
<v Harpreet Sahota>So you need to come up with good ways of indexing your data.

00:23:38.740 --> 00:23:42.070
<v Harpreet Sahota>And then once we get the data into the database, like how do we chunk it?

00:23:42.299 --> 00:23:43.870
<v Harpreet Sahota>Like that, that matters a lot, right?

00:23:43.890 --> 00:23:53.620
<v Harpreet Sahota>Because if the data that's indexed to the vector is large chunks, that's going to have a lot of diverse information in it, then maybe important details will be diluted.

00:23:54.140 --> 00:23:56.269
<v Harpreet Sahota>Or we might get irrelevant documents retrieved.

00:23:56.430 --> 00:23:58.680
<v Harpreet Sahota>So we need to make sure that data chunks are concise.

00:24:01.289 --> 00:24:03.080
<v Harpreet Sahota>Yeah, so there's lots in the middle.

00:24:03.080 --> 00:24:05.140
<v Harpreet Sahota>There's all sorts of stuff pros and cons.

00:24:06.250 --> 00:24:06.680
<v Andreas Welsch>That's great.

00:24:07.060 --> 00:24:11.970
<v Andreas Welsch>You can clearly see how it starts at a high level view of understanding what you can do with it.

00:24:11.970 --> 00:24:15.400
<v Andreas Welsch>And it goes all the way down to the actual data in bits and bytes.

00:24:15.400 --> 00:24:21.560
<v Andreas Welsch>And I must say I never thought that after college I would need to use vectors again.

00:24:21.845 --> 00:24:23.375
<v Andreas Welsch>I don't know about how you in the audience feel.

00:24:23.424 --> 00:24:34.414
<v Andreas Welsch>But to avoid the catastrophic forgetting that you mentioned for our audience, can you summarize what are the top three takeaways as we're wrapping up today's episode.

00:24:35.575 --> 00:24:40.674
<v Harpreet Sahota>I think top three takeaways is just understanding what it is that retrieval augmented generation does.

00:24:41.545 --> 00:24:45.365
<v Harpreet Sahota>We're allowing a large language model to interact with an external database.

00:24:45.414 --> 00:24:46.615
<v Harpreet Sahota>That's essentially what RAG does.

00:24:47.045 --> 00:24:48.455
<v Harpreet Sahota>How is it different from fine-tuning?

00:24:48.565 --> 00:24:52.785
<v Harpreet Sahota>Essentially, we're trying to change the behavior of a model, change the way that it responds.

00:24:53.475 --> 00:24:55.535
<v Harpreet Sahota>So that's a bit of a difference there.

00:24:56.235 --> 00:25:03.460
<v Harpreet Sahota>I'd say that pros and cons of fine-tuning and RAG is important to consider as well.

00:25:05.710 --> 00:25:20.110
<v Harpreet Sahota>And then also just realizing that the third takeaway here just make sure that when you are building your vector store that you need to consider how you're indexing and how you're chunking your data.

00:25:20.160 --> 00:25:29.480
<v Harpreet Sahota>It's really easy just to take we've seen a lot of tutorials out there with RAG, we just take a document and just embed it as is and just that's it.

00:25:29.480 --> 00:25:36.759
<v Harpreet Sahota>But be thoughtful about how we're chunking and indexing your data, because this is really going to affect the quality of generation.

00:25:38.410 --> 00:25:38.850
<v Andreas Welsch>Awesome.

00:25:39.400 --> 00:25:40.310
<v Andreas Welsch>Thank you so much.

00:25:40.810 --> 00:25:46.360
<v Andreas Welsch>I really appreciate the depth that you bring to the subject and for sharing your expertise with us today.

00:25:47.210 --> 00:25:48.289
<v Andreas Welsch>It was great having you on.

00:25:49.519 --> 00:25:50.190
<v Harpreet Sahota>Thank you so much, man.

00:25:50.200 --> 00:25:51.570
<v Harpreet Sahota>Appreciate you bringing me here.

00:25:51.840 --> 00:25:54.900
<v Harpreet Sahota>And if anybody has questions, by all means hit me up, shoot me a message.

00:25:55.720 --> 00:25:56.269
<v Andreas Welsch>Sounds great.

00:25:56.320 --> 00:25:58.660
<v Andreas Welsch>And for you in the audience, thank you so much for learning with us.
