Your LLM App Returned 200 OK. It Was Still Wrong. — Marina Petzel, Datadog
AI Engineer · 18 min · 143 sentences · from YouTube's caption track
Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.
- 00:01[music]
- 00:12Hello everyone.
- 00:13Thank you for joining me today.
- 00:16It's time to begin.
- 00:18And for years, many of us monitored our applications with the golden signals, which is was latency, error, traffic, and saturation.
- 00:30And shortly we call them lads.
- 00:32And they were and still they are and will be remain sufficient and critical for determine the health of our applications.
- 00:41However, today when we enter the new era era of generative AI, it's becoming not enough.
- 00:47And today we going to talk about what are the new metrics we need to look if we want to build the healthy gen AI application.
- 00:57Very shortly, my name is Marina Petzel.
- 01:00I am gen AI advocate here in DataDog.
- 01:03And today I will walk you through the metrics that we need to look for.
- 01:08So, when we talk about traditional applications, the main specific of them is that the same input always yield the same output, right?
- 01:18It's predictable.
- 01:19But with generative AI applications, we all know that the same prompt can generate different responses every time we run it.
- 01:28And which means we cannot rely on the standard regression testing alone.
- 01:33And you must constantly evaluate quality in the live environment.
- 01:38The second difference between traditional applications and gen AI applications, it's variable cost structure.
- 01:46Traditional compute cost are predictable, right?
- 01:50We pay for machine that is running our code.
- 01:53But for gen AI, this this is dynamic variable here.
- 01:58They might They vary from the number of tokens, the model that we are using, or the size of the context window that you have.
- 02:06And it's become essential to do the real-time granular course cost to prevent the spending out of control.
- 02:16The third problem is that we face the new attack vectors.
- 02:21We used to worry about SQL injection or cross-site scripting before, but today we must defend against the prompt injection, jailbreaking, or PII outage in our output.
- 02:34And that's becoming a big problem, and this are security issue, not a simple 500 error code can will never catch, and demanded entirely new forms of security monitoring.
- 02:48And finally, quality is very subjective for GenAI applications.
- 02:52The traditional systems either work or do not work, right?
- 02:57But generative AI output is judged on the spectrum.
- 03:01Is it relevant?
- 03:02Is it accurate?
- 03:03Is it complete or not?
- 03:05And the problem is that 200 okay response from your server doesn't necessarily mean that the answer was helpful or correct for your final user.
- 03:16And we must now integrate the continuous quality evaluation directly in your monitoring stack.
- 03:25And at the beginning we all were thinking that these golden signals will be enough for our systems, but unfortunately they are not.
- 03:34Traditional metrics will tell you if your system is up and running, but it won't tell you how well it's running.
- 03:43And established metrics lets will be still essential, but we going to talk about what else on addition to that we need to implement into our systems?
- 03:55And first I want to start with the cost monitoring.
- 03:58How we can track the spending before it uh spirals out of control?
- 04:04And I think we all know the financial implications of GenAI, and a lot of companies are facing the huge outage of the uh cost per their monthly usage.
- 04:17And while the same is true as for traditional applications, there were more linear scale between the throughput and the uh the cost.
- 04:26If the user loads um load goes up, our resources uh usage goes up, and sequentially the cost goes up.
- 04:35But the cost structure for LLM is highly dynamic and unpredictable, which means we can we don't have this visibility, and we need to really pay attention how we track that.
- 04:49And what are the problems you might encounter with the cost?
- 04:52And here we talk about the three major way for cost tracking, uh and so you can track them um to prevent the cost outage.
- 05:03So, the first is a token creep.
- 05:06Uh this happens when engineers or product managers trying to improve the quality quietly increasing the context window.
- 05:15And let's say the context window was 4,000 tokens, and then it's like blow to 132 without any financial review.
- 05:24And what it can cost like the the cost is depends very uh significantly to the context count, and that might result up to eight x cost increased.
- 05:35And and a month it might cost you thousands of dollars.
- 05:40Second is the model drift.
- 05:41Uh that is also the pretty typical problem when the team switches from cheaper and faster model, like let's say Hi Cool 4.5, to the more powerful and more expensive
- 05:52model, like Opus 4.8. And which promise you obviously the better quality.
- 05:59But at the same time, Opus, for example, uh can be higher 15 times higher uh per the cost request.
- 06:07And this change in model, even with the same usage volume, might blow your cost significantly within a month, too.
- 06:17And finally, it's on hash code.
- 06:20In generative AI, the same query can hit the API repeatedly if you haven't implemented the effective caching layer.
- 06:29And what you will see from um our uh own research that 70% of the spend sometimes are redundant because the system is paying for exactly the same expensive model
- 06:43completion uh over and over again.
- 06:46And with this granular visibility into these three layers, you would be able to escalate your cost rapidly.
- 06:54And now, let's talk about how you can prevent that and get more granular data.
- 07:01And when we um talk about that, we uh try to think about the implementation of cost attribution strategy, which is you must tag absolutely everything.
- 07:15For example, uh tagging uh can help you to uh Why it's important, right?
- 07:21You receive a lot of uh interactions with your agents, and but all of these uh interactions are undifferentiated.
- 07:28You don't know what's blow your actual cost.
- 07:31That is why first layer what you can implement is the feature level level.
- 07:36By tagging the intention of the feature, like it was a chat or summarization, you can attribute the cost for the specific product areas.
- 07:46And this data is crucial not only for engineering your cost management, but also for the product road map decisions, like knowing which features are actually the budget hawks.
- 07:58The second level is the use user level.
- 08:01Using the tags like the user ID or your org name is essential for chargebacks, accurate billing, but also quickly identify by the patterns of abusive usage before they drain your budget.
- 08:16Third is the model level.
- 08:18Also tag your models like GPT-5.5 or the provider, OpenAI or Tropic.
- 08:26It will give you visibility into the high-level areas of cost optimization.
- 08:33And you can benchmark the true expenses of using one model versus another.
- 08:39And the finally, endpoint level tagging.
- 08:42Attributing cost to regions or to your production or like to your environment like production or staging helps your infrastructure planning.
- 08:52And you can see how regional distribution or staging versus production environment can impact your total spend.
- 09:00And by making this tagging mandatory practice, you gain the essential visibility to understand exactly where your money is going and how important to control it.
- 09:15Well, but now let's talk if like let's let's imagine that we handle all the cost issues, right?
- 09:22We took that under control.
- 09:24And your finance team is obviously get very happy, but the next one problem is the safety.
- 09:33And your AI can be cheap, but still leak some of the sensitive or personal information, which is not great.
- 09:41And even though like your let scores can be perfect, it cannot tell you if there are some metrics went wrong.
- 09:51So, what we can track here in the safety metrics to First is the prompt injection rate, which has become the very crucial problem.
- 10:00This metrics detects the manipulation attempts into your user prompts.
- 10:05There are It's infrastructure If the infrastructure design doesn't have any guardrails.
- 10:12And this can be um prevent by using some advanced techniques like a pattern matching or specialized classifier models.
- 10:23And for this, we usually need to target for very aggressive thresholds.
- 10:29The second is PII detection rate.
- 10:32Um PII So, which is a crucial and zero tolerance issue here.
- 10:39We can scan all the model outputs for sensitive data like social security, like credit cards, or personal information.
- 10:46And you can use some um methods like regex or named entity recognition here.
- 10:55And only acceptable target should be 0% of your production outputs.
- 11:02The third is the content moderation score.
- 11:05How you can determine if your content is toxic, harmful, or biased uh towards some of the topics.
- 11:14And by running all outputs through toxicity classifier can give give you a scores uh how what is the risk of your output for being exposed to this uh toxic
- 11:26uh output.
- 11:29And this allows you to set some clear thresholds, and we always target to uh minimize that as much as we can.
- 11:38And then finally, the jailbreak attempts.
- 11:41And there are persistent attempts by users to bypass the safety guardrails and often um through the elaborate scenarios.
- 11:52And tracking tracking patterns to indicate the system prompt overrides, you should design and become so it become the absolute blocker for you.
- 12:02So, ideally, we should block all the 100% of the attempts of that.
- 12:10Now, let's imagine that cost is checked, security is checked, but now you arrive to arguably the most crucial dimension and the quality monitor that at least the most crucial for our final users.
- 12:25And even though your let's metrics showing that your service is up and running and running, your cost and safety tells you that your service is budget compliant and also secure,
- 12:41but ultimately for any application, but more for generative application, it's whenever output is good.
- 12:49But we all know that 200 okay response from your server sometimes can be a lie if the answer is hallucination.
- 12:58And I'm sure many of you got some response from modern AI applications, right?
- 13:04But like we know that it's can confidently by like but lie to you.
- 13:10And now let's understand what type of metrics you can apply implement to your application right now to prevent it from being unsafe for your final user.
- 13:22We recommend to focus on these five metrics.
- 13:25One of them is hallucination rate.
- 13:27Um, this measures the percentage of respondent contain claims unsupported by the grounded data.
- 13:35Um, we need to mix that with the manual review as well as with automated fact checks to achieve the aggressive targets here, too.
- 13:45The final The next one is the relevance scores, which helps you to understand if the response actually address the user question.
- 13:56Um, that techniques like that you can use here is similarity using bird or embedding similarity that can score you um, how relevant is the final answer was to the user.
- 14:10The next one is user satisfaction, which directly falls into your end user.
- 14:16Uh, you must implement You can implement some mechanisms like thumbs up, thumbs down, or some of the stars ranking, and also NPS scores um, to capture the subjective data,
- 14:29but also you should target that you get more than 80 85% of the positive feedback, at least.
- 14:38Next one is the answer completeness, and this metric is often evaluated by LLM as a judge, answering whenever the response was fully or holistically addressed um, the user intent.
- 14:53Um, and final one, the fifth one, um, if you are using rag, retrieval augmented generation system, you should always track the quality of your rag.
- 15:05What's if all the documents that were fetched were relevant to the user query?
- 15:10And here you have a lot of metrics and mechanisms how you can calculate that.
- 15:14For example, top K accuracy or normalized discounted gains, and that is uh, essential to track because whenever like you contacts is explode is getting harder and harder to pick the most relevant one.
- 15:29And by implementing this metrics, you can gain some understanding of like more dimensional view of the quality that necessary you need to optimize to improve your journey application.
- 15:44Well, and now let's summarize um what we need to implement to make sure that our journey application is healthy, right?
- 15:53We are not saying that we need to get rid of traditional understanding.
- 15:58We always need to look into our metrics, lay let's latency error traffic and saturation, but also on top of that, we need to put another layer.
- 16:09Layer of which is more relevant to generative applications.
- 16:13And in this case, we talked about the cost, safety, and also quality.
- 16:18And I know that for us as an engineer is becoming more and more critical right now to track it all not be don't need just build application and make sure that it's running in production,
- 16:31but now we also need to care about additional layer of complexity.
- 16:36And thankfully, Datadog has your back here since we are working in observability and monitoring space for for really long time.
- 16:44So, we do have our agent observability uh product which allows you to quickly and easy understand if your AI application is healthy, if it's running, or there is any problem that you need to fix.
- 17:00And we do have a lot of different way things that you can track inside of that.
- 17:06And um if you want to hear more about that, please feel free to see me afterwards.
- 17:12We also do have the booth here uh which you can check it out.
- 17:16We do have a really good um offers for you if you want to just try it out and see how agent observability can help your application.
- 17:26We have some QR codes for the free trials.
- 17:29And with that, I want to thank everyone.
- 17:32Again, my name is Marina Betzel.
- 17:34If you want to contact me, please feel free to use this QR code.
- 17:39And yeah, thank you for being here today.
- 17:57[music]