← All episodes
Data Neighbor · Episode 28

7 Steps to Building Production GenAI Apps

Generative AI applications are transforming industries, but taking a GenAI model from prototype to production can be challenging. How can teams effectively build, evaluate, and deploy powerful generative AI systems in real-world scenarios?

From the conversation

About this episode

We explore how to properly evaluate GenAI models using automated and human-in-the-loop strategies, discuss practical metrics to measure AI accuracy and performance, and reveal common pitfalls in AI application development. You'll also gain insights into personalization, user experience considerations, resource management, and understanding when not to use LLMs.

If you’re a data scientist, engineer, product manager, or executive looking to deepen your understanding of generative AI and effectively move AI projects from concept to production, this episode is your ultimate guide.

00:00 Productionizing Machine Learning: The Journey Begins 08:34 Real-World ML: Solving Practical Business Problems 10:19 Building a GenAI Chatbot for Efficient Data Retrieval 18:28 Embeddings and Chunking: Optimizing Retrieval-Augmented Generation 31:23 Mastering Prompt Engineering: Communicating with LLMs 33:38 Crafting Thoughtful Inputs for GenAI 36:06 How to Write Effective AI Prompts 38:26 Evaluating AI Responses: Metrics and Methods 39:46 Human vs.

Jump into the episode

  1. 0:00Productionizing Machine Learning: The Journey Begins
  2. 8:34Real-World ML: Solving Practical Business Problems
  3. 10:19Building a GenAI Chatbot for Efficient Data Retrieval
  4. 18:28Embeddings and Chunking: Optimizing Retrieval-Augmented Generation
  5. 31:23Mastering Prompt Engineering: Communicating with LLMs
  6. 33:38Crafting Thoughtful Inputs for GenAI
  7. 36:06How to Write Effective AI Prompts
  8. 38:26Evaluating AI Responses: Metrics and Methods
  9. 39:46Human vs. Automated Evaluation Strategies
  10. 44:05Defining Clear Metrics for AI Success
  11. 48:07Using LLMs for Model Evaluation
  12. 52:37AI Personalization: Hyper-Personalized GenAI Experiences
  13. 57:06When to Avoid Using LLMs: Common Mistakes
  14. 58:57Enhancing User Experience with GenAI Feedback Loops
  15. 1:02:43Closing Thoughts & Next Steps in GenAI Development

Product features and plans are discussed as they were at the time of recording.

Transcript

Automatic captions from the final YouTube video, formatted for reading. Names and technical terms may be misheard. Check the recording for exact wording.

0:01 How do we productionize ML? We want to go create this machine learning model. But genai related model like what is this machine learning process? Where do we start? Usually starts with an idea. Could be coming from an engineering team. That stage the requirements are pretty unclear. Everybody has a different idea of what and how things should work. First step would be trying to define what should the data look like. The next step is trying to identify the tech behind it. Just use something that’s already existing. Azure OpenAI claude. get all the tables and these related documents in a database together. Choose a chunk size and then each of these chunks is mapped to one embedding that is stored in a vector database with the prompt, the retrieved chunks and the user’s question. You pass all of that to an LLM have a very simple

0:45 front end that people can test with and put it in hands of people to test. When you have an answer, that’s where all the evaluation starts. That’s where the I mean the movie starts. Now up until this point where we had the answer that’s just the uh feature pipeline. After that we need to today’s guest is Suri Pava machine learning tech lead at Adobe. In this episode we’ll explore how to go from a vague Gen AI idea to a working prototype why evaluation is the real work in productionizing LLMs and what it takes to build rag systems at scale. Uh don’t forget to subscribe to Data Neighbor on your favorite podcast app and YouTube.

1:25 It’s the best way to stay updated. With that, let’s dive into our conversation with Suri Pragaba. Hello everyone, welcome to the data neighbors podcast with Hi Stravia and Sean. In in today’s podcast though you have me Ravia and hi chatting with Suri a machine learning tech lead at Adobe working on leading machine learning technologies and genai. Welcome to our podcast Suri. Really excited to have you here. Thank you so much. I’m really glad to be on the show today. Welcome welcome Suri. Thanks I awesome. So Suri we’ve had like so many different conversations in our podcast around machine learning like you know specific details about genai and like the overall industry trends. one specific detail is something that we’d love to speak with you about especially since you are the expert in that area. So can we talk about how do we productionalize ML like

2:19 what is this machine learning process where do we start let’s see if you have this idea one big idea about we want to go create this machine learning model how does that work and how things have changed with you wanting to do a genai related model and things like that yeah I think that’s a pretty interesting topic it will cover various aspects of the entire process what we can do today is that we can start with maybe how people can get started on a prototype based on some requirements or something that they want to uh go ahead with and then once we have the prototype ready then what are the next steps from taking it there to all the way to kind of in a product. I hope that sounds like a good plan. Sounds great. Let’s do it. Okay.

2:59 So, typically when it comes to uh creating uh a prototype or P as many people call it in the uh tech field usually starts with an idea. The idea could be coming from an engineering team or it could be coming from uh some product product managers that we typically work with. It usually starts with a set of very vague requirements like when it is in that stage the requirements are pretty unclear. Everybody has a different idea of what and how things should work. So at that stage it gets very ambiguous and people have to kind of iterate over multiple uh steps and see how things are going. So first step would be trying to define what should the data look like like what is the kind of data that we’re working with. So when it was before generative AI there would be actual data like text

3:45 or images or videos depending on what kind of problems people are working with and there would be a lot of uh annotated data with kind of the problem that you’re trying to solve. So if it’s object detection then there would be images with annotated bounding boxes and class labels and so on. So that would kind of be the first step of collecting that data or figuring out what it should be. And many times you can just use open source data sets available for the first P. But more so with generative AI still we need to figure out the uh input data.

4:14 But uh many times the outputs uh aren’t figured out by the time we start. It’s also kind of an iterative process. But once we have a data and we have a fair understanding of what we want to build, the next step is kind of trying to identify the tech behind it. And again here um for the first prototype I my recommendation is that we just use something that’s already existing. So uh it could be open it could be that you start with some of these APIs. There are so many in generative there’s so many people who offer that you can use Azure OpenAI cloud models and so start with some of the APIs and figure out what the text stack should look like. So if we take an example of a rag system in generative AI then figuring out what

4:55 kind of embeddings you’re using what database would you like to use what kind of pre-processing or chunking strategies are going to be good for the use case that’s kind of going to be important just try to build something really soon what I have personally uh found a good idea to do in this stage is to have a very simple front end that people can test with and put it in hands of people to test. So that could be me, my team or it could be the product managers that we work with and that way like I’ve always gotten feedback relatively fast. I personally am not a UI person so I don’t know how to build like good interfaces.

5:27 So I try to build something really simple. It could be streamllet or just a jupyter notebook and then I treatively build things forward as I get more feedback. But at the prototype stage, I think it’s just important to try out uh different combinations of technologies that can be used. And by the end of this prototyping stage, what would be good to know is what works, what doesn’t work, have a fairly good idea of what is a good output. In certain cases, it’s easier to define, but in generative A, it’s very hard to tell that this is a good output or this text is that’s the hot topic right now, right? So have some fair understanding of what’s good and what’s not good. have some level of good code in this prototyping phase. I think a lot of the iterations on improving

6:09 code quality and adding tests and all that happens when it moves to the productionizing stage. But that that’s kind of my goal when it comes to prototyping that start with a set of requirements, come up with something that is aligned with what we think is good quality, have a fairly good understanding of what technologies are going to work, what are not going to work, and just kind of, you know, hit the pedal on development cycle with having a prototype ready. And most importantly also is knowing what success looks like, right? What what what do we want? What this is this is great. The uh just just to clarify this would be for like a production like environment prototype. Uh right. Yeah. Right. It it actually could be any. Not all prototypes eventually go to production, but at the end of this prototyping

6:53 stage, when I say that knowing what’s good or bad, that’s kind of aligned with what success looks like. And then having a fairly good idea of what technology I want to use, when I’d want to take it to production, that’s kind of what my goals are when I do this prototyping step. And I think that that would be helpful for anyone who’s starting in the field as well to kind of know better about different uh types of things available like one kind of embedding is better for one kind of task and another kind is better for another one. It’s also good for people who are exploring to do this very frequently. Helps you learn about what are the different options available and thinking out more about how to like chalk out the problem and define the problem itself. Yeah, this is great

7:30 because you know like I I think especially right now uh vibe coding is all the vibes, right? So when you know when when when people like me that have never deployed a uh uh a machine learning model before I’m just I’m just prompting it to build stuff for me. So we never really think about all the intricacies all the system designs behind the scene. And then when you look at the discourse on LinkedIn probably people are kind of like you know hey uh the vibe coders don’t know what they’re doing. And then the the more certified folks is like you you just see all these different types of camps of people in how they think about prototyping. So I think hey the world exists in both places. At the end of the day the outcome is the same like you want to

8:14 build something you want to pro you want to prove out something but if that actually goes into uh into a usable production ready thing you still have to follow the same process. Yeah I’m totally a wipe coder when it comes to front end. I already kind of called out that that’s not my thing and I’ve actually found it pretty useful to get started and have a simple thing ready for me to use. So sur I know I’m asking you it on the fly right now but can we think of an example and get into the deep dive of it? How do you think of that as solution? I know one problem I deal with right since I’ve been like a data science I was an IC at some point and then a manager and later especially when as a leader when you don’t do like

8:54 coding dayto-day every single day you basically and there is like a problem you want to go look for it’s so hard to look through repo and find out what’s exact table you have to go after I know there’s going to be data catalogs and here and that that you could do but I’d love to chat with a chatbot and give it a problem and it tell me what’s a table you can go after and uh this is an example code I know uh data bricks and other uh like you know tools are currently trying to build something like that glean for example and stuff but let’s say we have a github repo right and entire data science code or even ML code or analytical engineering code is up there commented really nice let’s assume the best case scenario which is

9:36 not always or generally not practical and let’s say everything’s commented we just know what data tables exist what are the codes exist and let’s say we’re building the system for within the company can we talk about how do we start this do you think this something that we could talk about today sure I think that’s uh that’s a good uh problem statement I think many organizations would love to have a solution that exists like that and I think you rightly pointed out that lean is doing something like that for enterprises already but yeah we can definitely talk about that so do you want to maybe yeah let’s dive in let’s have let’s let’s have the problem statement hi what do you think do you think there’s something we could I Think I think that’s a great thing to to talk about. That’s a great great case

10:15 study. I would love to Yeah, I would love to know for myself, right? Yeah, that’s a good good problem. We could maybe uh make it a little bit more concrete. Sure. Let’s say that there are certain tables that are there and there are also some documents that describe what’s in those tables and we want to build a system for somebody who can talk to this chatbot and ask it to retrieve specific data based on table. Is that Yeah. Yeah. I mean to be honest even pointing out is enough we start to start with and then we can point out to vibe SQL coded or V python coded later but even getting information because there’s tons of variables and tons of different things that talk about it but all the information is available in the documents but we have invers going and

11:02 reading all of that how do you build a system that helps us answer it yeah so let’s start with the data base here um I think we would first need to find uh a database that can store all of this. So you’re saying that it already exists in GitHub, but that won’t completely work. We would have to store it somewhere to use it. Yes. So we first have to get all the tables and these related documents in a database together. So that would be kind of uh the first step of doing it.

11:28 Next, we would have to process them in some way that we can use them later. So this problem can be solved by using a typical rag approach where we uh first based on the user’s query retrieve what is relevant and then pass that on to large language model that tries to generate the final answer for the user. So this this problem generally fits well in that theme. Um so before we dive in so Ruby I can probably remind viewers what rag is. So rag is a retrieval augument augumentation like tool.

12:00 Basically instead of directly using large language models to give us what it knows based on the table names that it can search the entire web. We obviously don’t want it to search the entire web based on the little information you give them. You want it to get the context from the existing documentation of uh whatever we can provide them which in this particular example we have a bunch of documentation about the data tables of your company and stuff. So that is a typical rag like like you said a problem that rag could solve. So get the context from the existing data that we provide them and use that as one of the input variables with into LLM so that it helps uh like use the brain of LMS of some sort and with the this context and helps us solve the problem right yeah like uh

12:44 in if if we consider it as an exam and we are taking an exam of these LLM models and we can give them either the entire data which is all the chapters in a book or we can focus that down to certain chapters which would be only the specific data And so with read retrieval, we’re focusing that that down to just specific chapters or even things within those chapters so that uh there’s less thing to use to less context to use while answering the question and it makes things more ground less hallucinations.

13:13 It’s like like an open book exam in the library versus open book exam with one book. Yes. And then one book is rag versus the entire library which is the internet. Even certain pages from the one book even specific. Yes. even more specific chapter two that’s it don’t look anywhere else that’s true y so yeah so once we have the data ready and by by ready I think in in a form that we can programmatically consume so tables maybe uh could be either an excel format they could be SQL tables uh any any format that works and then the documents let’s just say that we decided to choose the format of markdown files for the for those documents and then we start consuming them you would have to pre-process them and pre-process processing is needed because we want to uh a remove anything that’s noisy and b

14:04 we want to chunk it to smaller pieces which are easier for us to convert to embeddings. For a for a rag pipeline we would have to convert both the incoming user query into an embedding and embedding is just a representation of the text that encodes the information in the text and everything that’s in the source documents also into an embedding. So to be able to do that we have to choose a chunk size. It should not be too big. It should not be too small. So there are some experiments that people usually conduct to decide this size.

14:35 Like how many chunks you basically divide this information into, right? Is that what you mean by chunk size? No, not not quite. So how many tokens are in one chunk? So like if I say only 50 tokens, then that’s too short. If I say like 5,000 tokens, then that’s pretty long. Mhm. 500 uh tokens is maybe a good starting point. There are techniques that do long rag as well where the chunk size are much bigger like 2,000 5,000 um tokens. But I think 250 to 500 is a good place to start when it comes to chunk. What are the pros pros and cons? Maybe like what does this mean if it’s a bigger chunk and smaller chunk? Yeah, if you think about chunk size in terms of tokens as very similar to the number of words. So if like if I have a long

15:21 sentence and I just decide to take the first few words of that long sentence then it’s not very coherent like you lose the context but if I try to keep it very long and I take like a full paragraph that has information about 10 different topics then it’s also not specific. So we want to keep that size so that it has enough context uh and uh is also pretty specific. That’s why like I think people want to uh keep the chunk sizes in a um range that has the benefits of both. Um but then there are certain benefits to keeping longer contexts also. It works better for certain kinds of documents, certain kinds of there isn’t much of a benefit in keeping it too short because you’re just losing. So you do provide all information but where do you cut it off?

16:05 Is that what a chunk exactly means or? Yeah, where do you cut it off? So you might want to keep like 20 words. Let’s let’s move from tokens to words. I think tokens are kind of analog analogous to words. So if you say that I want to keep a chunk size that has uh 200 words. So that is a decent amount of text that could have meaningful information, but it’s also not too big that it has information about too much context that it’s not specific enough. So what about other words in that paragraph or like in that page? Do we discard them or do they go into another chunk? They all go into another chunks. Um if you have uh thousand words and and each of your chunk sizes of 200 words then you end up creating five chunks like this makes

16:45 sense and um after you have these chunks then we have to select an embedding model and there are certain nuances and even selecting the embedding model first one is just this like what language is it in because now there’s so much all these language models they also work multilingually so like coher has a multilingual embedding openai has embeddings that work with even larger chunk sizes. So like we were discussing about 2,000 words or 5,000 words. So OpenAI has a text embedding large which you could use for these long larger chunk sizes. So certain ones that work better when it’s tabular data. So based on what kind of data we’re working with, we have to also select what embeddings we want to use. Um and then each of these chunks is mapped to one embedding that is stored in a vector database. So

17:30 vector database is the next choice that we will need to select like which one you want to use. And again there are various options like there’s uh VB8 there’s open search before we go ahead I am trying to understand the chunk size and like you know the type of words that go in it’s almost like when you are u giving some information to a person do you give in one one sentence each or do you give context together each because if they’re together it provides more information with the right context you give too much information they just get lost as well could you like like is it synonymous to that a bit yeah it is um like you don’t want to give too little information that they don’t really know what how to map together right which context because these chunks are going

18:11 to be apart like how does it know the relationship between these chunks. So if you put it in the same chunk probably the relation itself is is it’s coherent like it’s within that information versus if it’s prun across then there has to be a relation between the chunk sizes that also has to be conveyed to LLM right yeah um so the information is actually encoded in the embedding but the embedding is created by these chunks and um if that chunk has too many concepts in it which is it’s too large then that embedding may not be very good when someone asks a focused question. So we take an example of car brochures and uh in your the brochers that you have are about three companies. Let’s say you have Honda, Toyota and Mercedes and you created a chunk with all these documents

18:55 that has information about everything and the user just comes and asks uh I’m interested in knowing the price of Honda in 2025. Um and your brochures have 23, 24 and 25. So um if there was a chunk that was really big and had information uh for all these models for all the years then the LLM has so much data that it can give you the wrong information. it might give you the price of uh Toyota uh in 2025 instead of Honda if it’s getting confused but if your chunks were smaller if we would have one chunk uh for every car Honda and every year probably it’s easier and then we retrieve the it is more likely to retrieve the right chunk so Honda 2025 and more likely to not get confused and give the right answer so that’s kind of how um to look at

19:47 chunking um in general sie how do you at a high level how do you kind of determine the cutoff or chunk sizes? It’s usually through experimentation. So we have to start with the default value but then we have to build the full kind of system and then measure how changing these impact the answer quality. So we kind of have to like put together the embeddings the vector database the retrieval step generation and then with some metrics try to estimate how these are impacting the final answer quality or just the retrieval itself. Got it.

20:18 Got it. And then for embeddings, typically I would assume nobody trains their own embedding models. Is that is that right? Like just off the shelf. We used I think people used to before we had all these language models even when BERT was a thing. B Roberta all of those became a thing not even large language models. When language models became a thing I think people stopped training some sometimes you would still fine-tune and I think people still do finetuning but it’s just going down and down and down. how much people train and fine-tune to get better embeddings. So most just use reusing out of the box.

20:56 Yeah, it’s you almost get a like a packed very good product. So it’s all about like using it to for our own, you know, like problem rather than actually making the tool yourself. Yeah, I think with so many options available right now and everything working pretty well right out of the box for most use cases, people are uh trying to just reuse. I still think like in certain cases if there’s something very very specific to a domain there is benefit of uh fine-tuning. I don’t think anybody’s training from scratch that I mean that’s a business right there. If probably you’re listening and you think there is this specific domain or this area that you think LLMs are not still graded then that’s like an area you could just go solve for yourself right I mean when I said nobody is training I think I just

21:38 met people typically on the using of these things side like open still does career still does these companies are still doing it but it’s fairly less as compared to how much it used to be before it’s part of the reasons why like it’s uh a lot more accessible to uh to just build new Gen AI products, new ML models because like it would be crazy if uh if I were to build a website, the analogy here, if I were to build a website and then I also need to build the shopping cart feature, like if I were to build e-commerce website, that would take way too much time, but I’m not here to build a shopping cart. Um, and like I think uh that’s that’s something the audience can take away from this. Yeah, that’s true. Like completely true. shopping cart feature,

22:21 inventory management in your example, like those are things that you can just out of the box rely on other people who build that for you and uh create your website. And similar to that, if someone just wants to create a product and their product isn’t the embedding, then it’s just easier to use out of the box available embeddings and they’re pretty good. It’s not that they aren’t good for majority use cases. Yeah. Cool. Makes sense. So you have the embeddings, you put them in the vector database. What happens next? Right. This is like I love this. This is like a movie and there’s like you know trailers in between and we we just digress now come back a few branches then we come back.

22:59 Yes. Yeah. So they went into a vector database and again vector database itself uh is a choice that people may have to make. Um but uh the ones that are again available uh are pretty good. VBA is good. Open search is good. I have heard pine cone is good. So um there are a few available both paid and non-paid versions. But once that is decided and they are in a vector database then comes the user question. Um the user question itself has so many different problems associated with it. Uh people are lazy.

23:29 They don’t type the very well as a user of chat GBD. I think my queries as as a developer and a user on generative AI. I think my expectation when I am using a product is very different from when I’m developing a product because I would want people using my product to give me good queries. But as a user I don’t get tragically good queries. So they are incomplete. They can have a lot of mistakes, grammatical errors in them. They could also be coming in multiple turns. So like there’s a whole bunch of issues that could be with user problems with user queries. But what we need to do is take the user query possibly reformulate it so that it looks good in terms of retrieval because for a retrieval system to work well we need a good user query. What a retrieval system

24:14 tries to do it tries to retrieve the most relevant context to the user query and we do that by trying to match the embedding of the user query with all the um all the document context that we have put in the vector database. So um in that aspect the user query needs to be specific enough so that it is able to retrieve things well. So retrieval does not work very well when there’s a query like summarize because in our documents we’re not going to find the the things summarize across the context. But if we say again what is the price of Honda city in 2025 then that’s a a very specific query and um we can retrieve things for for that. So first step would be reformulation uh of the query. Then next step would be generating the embedding for the query and then finally

25:03 we will have to retrieve the relevant chunks from the documents and there like there are so many things that people can do. So many questions in this already. So another degression leave notes or something. So uh regarding um us reformulating the query how does it typically done? How is it typically done? Is it like a do you speak with a subject matter expert like someone’s asking this right? Do you uh how does like a genai ML tech lead work in this specific you know situation? Now we have a problem right? So do you speak with people like when people say this do they actually mean this? Is there something behind this you know just to understand the context or is it purely like a technical thing like what is the balance here? That’s a that’s a good point like I’ve not thought about it the

25:48 one that you said earlier which is the human aspect behind it. I have in my uh experience only tried to tackle this on the technical side. So I I have the chat history and I can reformulate the query using an LLM again. You can use Yeah, that’s that was my next question actually. So even for reformulation you probably use like LLMs, right? Yeah. Like LLM has a judge now LM has a reforming look for every part it’s almost like another human sitting there to help you resolve this. Yeah. And uh sometimes even under the hood some of these solutions for rag they already have that component inbuilt. So in such cases you can just directly pass user’s query to it and that decomposes uh or reformulates. So I didn’t mention decomposition earlier but like sometimes the queries are loaded. You can say I

26:38 want to do this and that and this and that and then there’s like five things in it and the full query does not work very well but if they are decomposed into multiple and executed in sequence that tends to work better. So there’s both reformulation and decomposition and many tools do that for that do that uh for you already. But if if like somebody wants to develop their own then it could be done using an LLM. I’m sure there’s uh some uh human research or like user experience research that could be done to your first point which is like the users really mean what they say. I’m not very sure but it’s a very interesting thing to like look into. But um from the technical aspect I think it can be done in a sufficiently good way to make it

27:20 work for retrieval at least using basically from technical perspective based on all the context you gathered through the documents and through the older chat history or the context or the chain of the commands that you’ve queries that you’ve gotten from this you can create a technical system that uses all this information to help reformulate and go further could like imagine definitely if you have a subject matter expert or something that could help build these systems in like even more specific way where if you have these particular type of queries, you definitely go around, you know, this is the actual thing that they’re looking for, right? Versus imagine if we open the system about going and coding with the existing data to a product manager to like a salesperson to customer supports person who does not even know anything about technical details. they

28:08 would probably ask a query in entirely different terms without like the specific technical details in it and that would probably need some sort of a way to tell LLM that this is what they actually meant. So some rules, curistics or whatever you might call. Yeah. Yeah. I think um now that uh you kind of mentioned that more in detail for fields that we’re not familiar with like if I am not familiar with healthcare and there are some the user of this LLM is a physician and they’re using the terminology that the LLM is not used to and we have to kind of make the system work in that setting then having a subject matter expert expert is going to be needed for us to be able to reformulate the query because if the LM is not familiar in that domain we need

28:52 other things also we need to fine tune the LLM in that domain. But in any case, we would need someone who’s familiar with that domain to help us create the system. So I think that’s a good point that until we probably have like an out ofthe-box system taking care of healthcare heads which probably are in work right now. Yeah, I think many people are doing that. Yes, many people are doing that. Yeah. Yeah. Uh it’s very high. I think I got you off. Yeah. No, no, no. I think uh I think I think we’re good. I I think this this uh just generally highlights you know how um like prompt engineering is so important right because if you give it like a paragraph of to your point like five different things that you want in one shot like it it’s going to get confused

29:33 whatever no matter what the LM is at the at the end of the day and you’re trying to help the model to get to the actual thing that you’re looking for as easily as possible that’s why people need to learn how to speak to AI like you know air quote speak so speak. Yeah, I know we’re talking about like productionalizing rags specific use case right now, but love your point. Hi, people who are listening to this could like use this to understand how LLMs work, right? Like what like the reformulation, why do we even need it?

30:04 So that use case is so beneficial for every person who is just chatting with LLMs today. I’ve seen myself high. Exactly. Like when I started off, I used to just dump all this information and it was so bad. I like just picked up one part of it and just gave me a big long answer. I’m like no that’s just for little context and why did you take it seriously? You know then I had to be specific around this is what it is 1 2 3 and then finally do this like as specific as I get in like be clear in explaining what I’m looking for and what’s the input what’s the variable here and what’s the output then I get like the best output ever. So this knowledge is going to help people to just get LLMs do what they want them to

30:48 do, right? Yeah. And I think doing things in iteration is the key with LM also. Um I think as you would do with the human being, start with something, refine it next, do it step by step and that’s kind of when I have had more success with it. Um but uh an interesting point on prompt engineering and then we haven’t really got to prompt engineering yet but when we do I think the point that you were mentioning was about how users structure their query but then there’s also a whole different thing on how each of these models has their own meta prompt that that developers create while creating these tools but yeah come back to uh user query. Yes reformulating that’s where we are coming back. So reformulating uh generating the embedding and then retrieving the most important content from the uh vector database uh that’s

31:34 relevant to the query and uh there’s just so many things even there like it could be a simple similarity based thing there could be uh reranking there just a lot of variance u available I think my recommendation would for that also for for people listening to this would be to choose whatever you think you need for your use case not everybody needs a danker but definitely danker helps in uh making retrieval work better. So in in terms of trying to look into how to create the rack system, I definitely recommend reading up a little bit more on u uh reanchers and different types of similarity search to choose which one works best for your use case. And so by the end of this step, we have retrieved the relevant context for us and now we have to pass that on to an LLM with the

32:18 system prompt. So that’s where the system prompt comes in. And there also I think there are lots of good uh practices when it comes to doing prompt engineering. Keeping it simple is one of my favorite ones because the more we complicate it, the more confusing it gets for the LLM. And it’s it’s very similar to like explaining it to a human being. If you can explain it in simple ways and you can define the expected inputs and outputs and give like step-by-step instruction on what to do, the will do it better. But if it’s all convoluted, then the response is also going to be convoluted. This is so funny. So people needed communication classes and how to communicate better and all of that in the previous world or before LM. They need it even now to talk to LLM. So communication is still very

33:01 important in the world of LLMs. Knowing how to ask for what you want is the most important thing. The art of questioning probably, right? That’s what engineering is. Yeah, totally. like what do you want, what format do you want, the more specific that the user is, the more likely they’re going to get a good response. But then also depends on which LLM you’re using and how much context window it has. Don’t uh for your audience, don’t don’t don’t take offense that the LM is not good enough for you. Think if you’re good enough for the LM first. Hey, I just invented a quote. I I think I think I was going to say that’s a that’s a t-shirt line right there. It is true. There we go. It is totally true. like so many times of kind and I’ve tried to do a slightly more

33:44 complicated task and maybe I would try it a few times and it would not work and then I would just go back to maybe I should just do it myself. I think they’re they’re pretty far enough in what they can do, but I think there’s still a long way to go for it’s just more patience for me. Suri, there was this complicated thing that I was trying to want it to do for me. I I was like, hell, Ben, I’m like, I’m not writing code for this. I better get, you know, Chad Enterprise to write this for me.

34:09 And then all it needed was like, okay, let’s just take a deep breath and give everything. And it was probably 10 seconds more 15 seconds more and actually thinking before you’re writing like what should I give it so that it gives me what I want right you need to pause think and then generally even though it’s maybe 10 20 minutes extra work it’s easier to not do that and just type because you know what to type so when we if we have the patience to pause think and actually give the right input you actually do get even for the complic licated queries you do get an answer because if we are in a hurry and try to get it we probably waste more time that way instead of pausing thinking and actually giving it the right question 100% um like the more information you

34:58 give it the better your instructions are going to be the better the response is going to be it’s almost like it’s almost like LLM’s uh forcing you to be more human or more like philosophical and like just pause guys just pause and think through and be thoughtful. Yeah, it’s it’s the same even though it’s like garbage in garbage out. So if you’re going to give it good instructions, you’re going to get good outputs. Uh so now we have the relevant context. We have a prompt that we have created that specifies what the input is. What outputs do we want it to be like? If you want any reasoning in our answers, which is useful for in certain cases like if it’s a calculation related thing that you’re trying to do or you want to add information about, oh, I got it from

35:40 this table. based on these documents. I think this is the answer. So then you might want to add a chain of thought component as well. And it could be something very simple as writing an instruction that says give reasoning uh step by step or outline the steps that you followed to arrive at this answer which makes it more explainable for for users. So I think that also is good for establishing like trust that users can go back and see that is it actually giving me the right information or not which is very crucial when it comes to like product applications because of like hallucinations and if it’s a very sensitive domain then you may want to do that more. So you have a prompt that has all these components that you want. It can also include things that you don’t

36:20 want it to do. So if it’s anything like prompt leakage, you don’t want it to leak your prompt. So you could just put in the prompt itself that if somebody asks you a question about your instructions then give a can response it could have things like that also or for like file language. So you could put it in the same prompt or it could be a different component but uh those are some of the instructions that people typically include and the simpler we keep it the more well definfined we keep it the better it’s going to work. Um, and I think what you mentioned earlier, like if we put 100 instructions in the prompt versus if we have 10 most critical ones, the one that has 10 most critical ones is going to have better instruction following uh than the one

36:59 that has 100 loaded instructions in it. And once we have a prompt with the prompt, the retrieved chunks and the user’s question, we pass all of that to an LLM. And then there are different ways of choosing which LLM based on what the context is. What kind of functionality do we want it to support do we need a reasoning model or we don’t uh go also goes to which um model gateway we are using if like we’re using anthropic models then we will not have access to open AAI but if you’re using Azure or um uh Amazon bedrock then then we have access to like a set of models and we can choose whichever and then after all of this is sent to the LM then we have our final answer. Hopefully that will include that based on your question. This is the table that I think

37:42 you should use. That’s because these documents mentioned that this table is about XY Z topic and it doesn’t leak the prompt if people ask it to leak the prompt or it doesn’t really engage in any harmful behavior. That’s kind of what you would expect from the system because once it once it’s out in the production like once it’s out in the prod environment then people can do all sorts of things with that like people really try to break it. So give me something to hack my computer database you know things like that but surviv one important thing did you end it’s not complete right because we need to understand if the answer was right or not right exactly yeah that’s when you have an answer but I think that’s where all the evaluation start to be honest that’s where the I mean the movie starts

38:25 now almost yeah I mean I think so up until this point where we had the answer that’s just the uh feature pipeline after that we need to have like a lot of productionizing is actually less of the feature development. There’s just so much of evaluations and making sure that it is performing well on the right kind of data sets that we are expecting users to be using. Um it’s not engaging in any kind of harmful behavior. There are no unexpected errors happening like error handling is a key part. Then that’s so much about balancing the load because we need to make sure that it’s it’s kind of distributed across different regions.

39:01 How is the service handling the load for each of these? So I feel like productionizing is starts after we have a prototype that works and then that’s just a completely different ball game where all these other components play a much bigger role. Um yeah can’t can’t wait for that uh for that movie to start. I know. So what’s like evaluation is now the biggest need of the hour right when it comes to LLM specifically. So let’s say in this case can we talk about like how do we think we’ll evaluate let’s say Si you built this for me right and you’re we both work in this fictional fictional company and I’m like Suri I need this for our team I’m like a you know head of data I have all these no data pipelines data engineering and I want I don’t want my data scientists to

39:51 do like this typical quick ad hoc questions and answers I want whoever it is a customer salesperson they should come they should ask this chatbot get a reply of the data table and they use those data tables and their question to get a SQL query themselves right so and now you started building this for me how do we approach once we get this answer for this you know customer salesperson how many users are there for this particular feature in this company let’s say that’s the question and they’re like use this table use that table and use this table that’s the answer yeah so I I would hope that by the time people are actually using it it has already been evaluated and then the ways to evaluate.

40:28 There are actually two main ones. In the beginning when we don’t have a system ready yet, it’s typically evaluated by a human being. It could be uh internal stakeholders, could be product managers, could be engineers, whoever. They would know what the expected answer is and they would try to compare what the LM has generated. We do this till we get to a point that we trust the system enough. Then the next step would be to try to automate this because you can’t keep doing this forever. It’s okay in like certain times either in the beginning or when there’s a major upgrade made to the system because human eval is kind of the most thorough way of doing it. But for smaller tweaks or minor updates, we don’t need to do a full cycle of human evaluation and in that case we want to

41:10 have some automated metrics. So first step would be to define what those metrics are. They could be accuracy like a most common one and then there are other things also. Accuracy is just one. You might have experienced in your own use of these LLMs that they have different answering styles. Some of them can be more uh descriptive. Some of them are very crisp and different people have different preferences. So it won’t apply so much to this specific case of generating SQL queries because there’s probably even in SQL queries I don’t think there’s one right answer. You could do the same thing in multiple different ways. Y but in natural language there can be so many human preferences that um and it varies so much from person to person. So we may need to define these other metrics also.

41:49 So accuracy is just one but then the how how much is the level of details in each of the answers that could be another what’s the tone how concise concise and level of details are kind of similar but that there could be other metrics that you define based on what is important for that use case and then we need to create the data that can help us measure that. So for accuracy it’s like answers and for the SQL query case there are two SQL queries that solve this problem. Then our set of gold answers need to have both those queries. And then a typical way like that there there are nine ways of doing this. You could be comparing answer similarity but that’s a slightly older way of doing it.

42:25 Everybody now uses LM as a judge. Use um if your model is built on GPD then you could use claude to evaluate it. uh it’s generally better if you use a different family of models but uh it’s funny how different family of models also give the wrong answer in the same way. So if you get a wrong answer with GPD you might get the same wrong answer with flawed although they’re trained differently but still kind of trained on similar data but still LLM as a judge is a very they’re probably lobbying into thinking that they are all great and helping each other out. I think they’re great for for easier tasks. For um something more complicated, I think there’s still a little bit more to go.

43:06 But yeah, LM is a judge is a very commonly used technique. There are also metrics that people use to measure retrieval. Um I think I’m talking one thing Seri before you go into that I wanted to uh like give slightly more detail on LLM as a judge. I think some of us know but for people who I mean the name itself is pretty descriptive like LLM as a judge. So basically here we use LLMs themselves to help understand if the output is good enough basically for evaluation right yes and how do we how do we quantify that like even this evaluation I had the question when you said humans as well like do we have any sort of quantification let’s say we try for I don’t know 10 queries 20 queries or like is it thousand queries like how do you go about when does a human stop

43:52 and when does automating start and in automating how do we think about like how long do we want to keep evaluating like until we get the high quality like what’s the measure probably all these are the metrics that you were talking about what is the goal right yeah I think there are a few questions that you asked there one is on data sets so how many samples do we want to evaluate before we say something is good or not there is no right or wrong answer I think the more the better but for human eval it’s not very feasible so you could start with 100 you could start with 200 that’s still a lot if somebody basically the constraint is human probably and human time right and that’s doable if you know we’re outsourcing it if we are getting someone on some of these

44:35 platforms to do it for us um externally but internally if it’s you or me or a product manager who’s trying to do something the time is even limited so it really varies based on what is the medium of doing it for auto eval it’s it’s it’s much easier it could be scaled to the level of hundreds to thousands to how much money you have to spend on uh the constraint is money. The first one the constraints of human time the second one’s constraints money. Yeah. Even with the second one I think there is a little bit constraint of human time because um we may still want to review what the LLM has done um specifically uh on um any sensitive domains but it’s it’s much better. It’s more scalable than human.

45:21 You do have to invest the time to like write out very specific instructions and very specific judging criteria though, right? Yes. So then you have to define the instructions and the metrics to use. Metrics could be uh like binary whether the uh answer that the LM has generated matches the source truth like ground truth answer or the cold answer. It could be a rating um that on a scale of one to five um does this match what was present in the goal answer. You could also try to model how humans have rated the answers through your metrics. You can use the data that has been provided by humans on a set of questions and try to model that through or without an LLM could be done either way and try to rate the generated ones based on that. So there are there are a few ways but uh I

46:14 think most commonly a liker scale rating is used or a binary matches or not is used and in LLM as a judge we use one or more LLMs to rate the answer generated by another system and that way like if if we have more LLMs and all of them agree that this is the right answer then hopefully it’s actually right. Uh but there’s just one and that says that the answer is right. It’s it’s it’s less you have less confidence over the like five LM say that it’s the same as the humans.

46:44 If five other humans say that yeah this is right it’s more likely to be right. It’s not guaranteed to be right more likely to be right because even these LLMs have their own biases and their own inherent data issues. So when you say what so this claude there’s what what are the typical like do you use all LLMs when you come to LLM as your like how many do you think is a good number there? I I would say I I don’t have a good number. I I I like using more than one and I like using uh something that I have um not like a different family of model from the one that I’m working with. If I’m working or or a different model. So if I’m working with GPD uh 40 mini then I would try to use a more

47:21 powerful model. I use 40 or claude uh 3.7 based on that. I would kind of choose what I’m using. Try to use two at least but it varies I think how much you have access to even one is fine if as long as it’s a more powerful one but the more you have the more confidence you can get on the design so you sorry so go ahead yeah no I just I was just saying there are like sufficiently large amount of families out there that we can without running into issues right like you’ve got gro you’ve got you’ve got gemini yeah you’ve got llama if you install some somehow locally mistrol all these things. It’s like they’re too many to kind of to use that then than then then most people would know what to do with all of them. Yeah. And um now like

48:09 so many of these metrics are LM based. So there’s there’s the accuracy and some of the others that I mentioned conciseness tone they they could be all LLM based. You could even build metrics that measure whether your output is biased or not using LLMs. There could be like different metrics that you can build for calculation based questions. It could still be the right or wrong kind of a thing, but uh you may want to also have something that measures whether proper reasoning was provided. So at this point, as much as LLMs are being used to create the feature, I feel like the same amount they’re being used for evaluating. That’s true. Is generally creating the feature, you could use a less powerful one and you need a more powerful for evaluating.

48:51 Yeah, at least that’s what I have observed because um right, it’s almost like a teacher, right? like you know someone solves a problem but there’s some expert coming and saying this is good versus not right yeah um and there’s just so much subjectivity that sometimes even though like you can have many metrics you just have to get things in front of a human being and tell which one’s better or not but still some of these auto evals have made it more scalable than before yeah makes sense do you eval the different steps in the kind of like in the in the in the system so for example like In the embedding stage, do you have evals there? In the reformulation stage, do you have evals there? Yeah. I um so yes and no. I think for uh embeddings, the kind of

49:37 evaluation it feels already done by people who have created those embeddings. When when we want to choose embeddings and we do any evaluations, it’s usually at the final output level. There’s no nothing specific for embeddings as such. Unless like if I was training and embedding for a certain use case and I would evaluate in that process but in this end to end system it’s kind of like with the answer but query formulation yes you can evaluate that step itself whether the query is being reformulated correctly or not and again it’s going to need either subjective eval or some ground truth for a given set of input questions. How does the reformulated query look like? You could even evaluate retrieval step and that’s what I was uh uh sharing earlier that there are some retrieval metrics like you may might have heard of uh

50:23 ragus metrics and they kind of try to measure context precision and recall like how important is this context like was all the context relevant to this query retrieved um that’s kind of context recall and whether what was retrieved is the right context to retrieve for this query that’s context precision and I think they have a bunch of more that also measure relevance and um I believe there’s something even that tries to say whether something completely unrelated was retrieved. So you can also measure things at the retrieval step but most frequently I think what people measure is the final output because that’s what users are going to see. But some of these intermediate steps help in debugging if something goes wrong where the helping yeah that was the the initial thinking of uh I think makes makes sense like everything has to be evaluated at the

51:10 end like what’s the output like is it substantial is it better but then it’s like hey if it’s not or if it’s worse then you get to debug diagnose what’s what’s happening in between. Yes, I think it’s it’s a it’s a very useful tool if people do it. Uh uh one I think one few times it’s done but eventually everybody just goes to the final output and if that looks good I think you’re okay for the good or the bad I don’t know. I mean it it’s crazy. It’s so um like the the way that I would describe it is like mentally taxing because mostly it’s not like a zero or one, right? Like binary is easiest but then most of the time these things are subjective. So it’s like is this good enough? How good enough is good enough?

51:51 You have to give it so explicit instructions or criteria that by the end of it like I was telling Shravia and Sean I was building a workflow uh with agents in between and then I was like it’s so taxing to even think about is this good. I I I can say it’s not good but I can’t define why it’s not good or what good we need to have a context of what’s good. Right. Yeah. So we need to know what’s good. We need to it’s like I would say going back they’re probably pushing us to be more philosophical like understand like what is the question why do we want it what what does success look like and what are the variations of success too right this is good what’s really good what’s not and I’m sure this is going to get even more even more

52:34 nuanced as we get into a really powerful models I think this um this whole thing about um uh subjectivity and what is good might mean different things to different people that has completely like led into personalization. You might have heard of hyper personalization with LLMs in the field of genai and that’s a completely in itself a full big area of focus that uh people are diving into because if like three different people are using the same LLM then they’re likely going to get the same response. How do we make it tailored to the person who’s using it? uh becomes equally important um to differentiate the product and also to actually make it useful for the um users themselves. So I think that’s a completely new field that uh I mean personalization used to exist anyway but now it’s becoming very

53:25 important um in genai space as well. That’s so meta but yeah that’s so cool. No, I’m trying to understand this. The other day I was trying to use Meta and I was like, it asked me to sign up and I thought for a second, sign up with my Instagram, Facebook, you know a ton about me to sign up with my Instagram. So, personalization gets so much more interesting when you know a lot about the person that’s beyond what’s spoken to you, the LLM itself, right? like all the biases like you know it it just is an entirely big field of study or you know products that we can think of chat today does not have a social I think they tried to do something with Gibli trend the photos trend but it’ll be a great world where LLMs and social

54:12 combine is where I’m going with it great or scary one of the two yeah I mean it is I mean everything we can look at it either side right to be honest there is a really scary side of this whole AI thing and there’s the other side of really exciting side. So if we want to be happy, we’d rather choose the exciting side and just be you know have a good sleep. It is very useful barring all the privacy concerns and um I think it’s very useful even with charge GPT the memory feature I found it pretty useful because I don’t have to tell it about myself every single time like I was working on one of my immigration related cases and where I have to kind of share more about work I’ve done and my profile and things like that use

54:57 tragedy frequently and I don’t have to tell it that same thing every single time because it kind of has it in its memory but it’s bad because it has its inner memory. It has it in its memory and I don’t know what it is doing with it. Um so it’s both kind of good and bad that way and you don’t know where it sits. Yeah. Even the memory part is like so interesting right? So both imagine you and your friend are in the same situation. you remember it differently and like 10 years down the line we both chat about hey how those days were and you know we went there we went there then she’s like she was like I don’t remember she probably remembers something that you don’t remember right so what exactly happens in the conversation with LLM for it to remember

55:38 imagine a world where we are chatting with LLMs every single day for almost all of our tasks how does it have this super memory like you know something that’s in RAM sort of like it definitely remembers versus it has to go and dig around and you know things like that. So that’s an entire different area. I feel I think NLM memories are more straightforward than human memories. There’s probably a prompt that extracts things from our interactions and puts them in a database and then doesn’t forget uh human memory. What about if you interact with them like for every single task and let’s say 5 years from now it has all these years of information. It’s just too much to search for, right? Or maybe the computing power is so good that it does search. But I just I was just thinking

56:18 about that scenario where you probably use LLMs for every damn task and what happens to memory then? Yeah. Uh yeah, they have to have some level of forgetting then also because it can’t. Exactly. It has to right. If not then it’s going to do a bad job for the good like you know if he has to give you something in a second it has to forget and then it’ll come off a prioritization like how does this whole and maybe in today’s world it’s not as much but I’m talking about like 5 10 years from now where LM are going to consume I’m kidding maybe it’s a personalized dynamic chunking strategy by then yeah oh my god it’s a different podcast alto together talking about five years from now yeah five years from now personaliz ization. What do these things do with

57:03 our data? I think we just probably a different topic. I think coming back to what we were talking about though, uh I think there are a few other things that I would definitely like to mention when it comes to gener applications and productionizing them. One is we don’t need LMS for everything. I I feel like right now everybody is using an LLM for anything that they want to do. And uh I think before they even start on that first P, it’s definitely worth making sure that you actually need an LLM.

57:30 People are doing classification with LLMs. It’s just completely unnecessary. Good old stats mortals. Yeah, they like to kill an ant with a nuclear bomb. That’s the Yeah, I mean the analogy. When I started it was all computer vision, natural language processing. Things were deter not exactly deterministic, but still more deterministic and more predictable and explainable. And I personally still like those models better than LLMs. So that is one piece that whoever is listening to this and that’s kind of just starting in this field please definitely keep that in mind. And I think the other thing that we did not touch upon is just resourcing even when we have the model ready and we have evaluated it on all these axis quality bias ethics fairness like I don’t know even even if we covered that but once we have kind of

58:17 evaluated that we need to have the right kind of resourcing so that the service is able to serve user queries. So that’s another piece that based on the expected load and how much input and output tokens we expect we need to kind of do the provisioning of these uh instances that would actually serve the requests. So that’s another important factor when we actually kind of take these to production and deploy them somewhere. And I think the final one is user experience. I mean I was going to ask that we’re almost at time but imagine people not liking the answer like how does we take the feedback in and iterate on it right and things like that that’s obviously another important chunk of work yeah like monitoring feedback AB testing that that’s kind of one very important piece to decide whether uh a

59:05 new feature is worth rolling out or not for feedback specifically I think most of these tools even charge GP has a thumbs up thumbs down thing most of these tools have a way of giving explicit with feedback. Many times feedback is implicit. Like how many times have you told GPD I don’t like this. Exactly. I never use thumbs down. I probably used it bunch of times for maybe thumbs up a bit but never because you basically a thumbs down is nothing but you ask it again, right? In a different way. Yeah, that’s close to a thumbs down, right? But even things like I don’t like it or saying things like make this more concise. Those are either direct feedback uh which is implicit or sharing my preferences and it becomes important to track them in a privacy preserving manner and that’s a little

59:49 tricky but I think having again LLM based models that kind of track these trends in user conversations in a way that developers don’t see the data but they only get the insights. So if I have something working that says whether the experience of the conversation is positive or negative, I can just keep track of positive or negative and nothing else on the background. But um doing it in a privacy preserving manner is I think the key here and having people kind of give consent when they’re using your product to send data to LLMs.

1:00:20 Uh I think that’s also a slightly overlooked part which most big companies do but I’m not sure about all the startups how much that’s kind of put into it but it’s an important thing to do as well. Very cool. I think this is the first uh first end to end deep dive into Yeah, it is how we build a Gen AI product from the beginning. We could definitely also have a part two of this, right? Like into the specifics of each of them or the end one because we kind of wrapped it up fast, but this is pretty cool. Yeah, we didn’t even talk about cost. So, you know, like that’s that’s another area that I know a lot of people think about. Yeah, we did not talk about cost or latency. I think we did fully dive into um bias, fairness,

1:01:03 ethics, evalu I I can go over a little bit, but uh if uh it’s a different one. No, I I think we we can definitely do a part two of this. Yeah, we’ll do a part two. Yeah. Okay, that that works for me as well. Cool. Awesome. Well, this has been such a wonderful episode. I think uh I think like it almost feels like as the podcast goes with more and more episodes, people could just listen to this podcast and and and they’re good. They’re good to go for their Genai career. So, thank you so much. I know this is pretty cool. Almost like every podcast is becoming a slight summary of overall and giving like a new way of you know diving into this topic. So, thank you so much Surviv this was great. I would love for anyone who’s listening to

1:01:55 this, you have any questions for what we’ve discussed so far, please, you know, have them comment and so we are here to help answer those questions and stuff and thank you so much Suri for coming in. Yeah, of course. I’m happy to help in answering any questions that people have and I had a great time like it was a very fun chat. Uh we digressed a little bit but I hope people who are listening are still going to find all those digressions useful and uh thanks again for having me on the show. Yeah, definitely definitely it will be very interesting sto side shoot stories. I think that makes this podcast human and uh approachable. So yeah, thanks again for everyone who’s listening. Please like and subscribe. Uh surprisingly those really help with the YouTube algorithm and uh because of that we can

1:02:37 bring more content like this to you in the future. Thank you so much. Thank you guys. Bye. Thank you.