Effective AI auto-improvement loops require high-signal feedback mechanisms derived from domain expertise rather than generic metrics; teams should collaborate with domain experts to create concrete examples, identify failure modes, and define clear quality criteria that enable reliable evaluation, as demonstrated by a paper classification task where systematic error analysis and targeted prompt updates achieved 15% accuracy improvement through a structured self-optimization loop.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Stop Burning Tokens: Why self-improvement needs domain expertise first - Annabell Schäfer, Langfuse
Added:Hi everyone, my name is Annabelle. I'm a growth engineer at Lenfuse and we're the largest open source observability and evaluation platform for your AI system.
And today I'm going to share about how you should stop burning your tokens and why you should start building in domain expertise early in into your loop design, but also into your overall um application design to make sure you're continuously improving and updating your application.
It is June 2026 and the whole internet is about uh loops right now. So we have Boris Journey saying he doesn't write any prompts anymore. He has loops and Peter Steinberger being like you should be designing loops and not prompt your agents. And I mean the whole Kapathy auto research and auto improvement topic blew up earlier this year already. But all of them are coming a little bit from this de developer perspective. And um coding is one for for a good reason. One of the cases where this whole um automatically reaching a goal uh worked quite well because they've always had a at least one um target function that wasite quite clear. And this was uh does the code compile or not. And of course just because code compiles doesn't mean it's great and doesn't mean um that all the features are exactly how you wanted them. But you at least know that you shipped something that worked. And of course this was then expanded over time to to expand this target function. But essentially it's a does it work or does it not in all other fields and especially if you're building AI applications for some kind of domains like medicinal compliance or healthcare or all kinds of chatbots these target functions are uh not nearly as clear and a target that you give an agent is actually also always incomplete. So um you might initially think that you're trying to head down here uh but actually your optimal destination is up there and to get there and to understand this it takes quite some time and to figure this out and it's yeah it's just inherently a difficult problem especially if you are in a field where a clear yes or no like does the code compile um doesn't really uh cut it. So it is very difficult but at the same time we at length you see that the teams who are investing heavily here in the middle so uh making sure they capture what they actually want to work so the target function and build this out and make sure they have good evaluators that are evaluating this are the ones who manage to continuously upgrade and improve their application over time and also ship with confidence because if you know um it's working as you intended to h then you can also sleep um well at night in case you push a code change. Okay, so now we know it's super important and you should be doing it, but at the same kind it's time it's almost impossible to actually h get it right. Uh so we were setting out and wondering what's the clearest cut target function we can find um for an agent to use and also if you run an auto optimization on it h what can we learn about the role of target functions from from running it on it and the clearest cut target function we could find was a single label classification task that has has a very clearcut yes or no. So for example, let's say we have an item to categorize. There's a true label. For example, oh, it's an order. And then we have a set of available labels, order, complaint, inquiry. And our classifier then assigns um one label. And you can very clearly say is the true label equal to the predicted label. And if yes, um then this one is right and the next one might be wrong. And overall you can calculate an accuracy value and get a very clear signal from here.
So we put this target function together with an agent and also with an optimizer. And how this minimal loop looked like I'm going to share with you now. So here's our minimal self-optimization loop. Up there in the first two rows we can see our target function. In our case we opted for classified um archive papers. So it's a set of papers that based on their primary um based on their title and abstract h got a primary label from the author um to categorize it for the other people in research. And um yeah, we're going to uh we have the the ground truth here and we have it in 200 um items in a fit data set, 100 in a validate data set, and 300 in a test data set. Um just to also make sure we're not overfitting.
Then we have our agent, which is more or less just a a simple prompt. um uh based on GPD5 for nano because we wanted to see how a very small and cheap model performs on the auto improvement because the good ones actually got really really good but also very expensive um over time and we have this flash list of labels and then we have our optimization process that runs through uh cloud code leveraging cloud us 4.8 eight. So one of the frontier models and it proposes the prompt updates and has this context reference the GPT54 prompting guide as well as a task MD that is describing the loop. Looking a little bit closer on how this looks like. Here we can see our target function in this case especially our fit data set uh within length view.
So we see an input column where the title and the abstracts are inside as well as an expected output column. So what kind of uh label should be applied and um on the those three different data sets the the idea is on the fit data set you run it you look for the errors and especially error clusters and um opus should then formulate hypothesis for prompt updates in the validation set we then check if those prompt updates actually also generalize to unseen data and then finally when we're like reaching a plateau or our stopping criteria um then we're running it on a test set to see how well we actually um generalize for untouched data that was not part of the training process. Our base prompt is a very flat list of labels and just a simple task classify this paper with a label. Um of course if uh if we would write the prompt we would probably add some pros how to think about it and all of this. But we just wanted to see what happens if we use the very base version um of this prompt and how the the system is dealing with it.
And our leap loop is a step-by-step instructed uh loop um done through a task markdown file. Uh so the overall idea of the loop is first you run the base prompt on the fit and in the validate set to get like a baseline accuracy. You score it per item and overall then on the fit data set you do this error analysis. So you really look into what kind of categories frequently are done right? what kind of um item pairs are maybe often confused and also what's then the uh underlying abstract and title um belonging to it. So we can maybe find patterns there. Then the uh then float um proposes an update uh for the biggest error category and publishes a new prompt change and then reruns and only um accepts if this uh also improves on the validation set. And we have two stopping criteria. Either it's 15 runs uh completed or we have 92% accuracy reached. And as soon as this is happening or um it stops for some other reason, then we perform a final uh run on a test data set to see it. So yeah, here on the right you can see all of this is described in a markdown. We point at the data sets and we not even give it the test data set link. Um so it will not look into it before we wanted to.
So what happened? Um yeah, I mean overall we can see here that there's a a tendency to increase uh but also we can see that um yeah we reached a 15% uptake uh from our baseline which is actually quite solid. Um the first run ended at uh 68% accuracy and on our third fourth iteration um we went all the way to 83% which then also afterwards um plateaued a bit. Overall it kept this level around 80% and we wondering okay actually we wanted the perfect clearcut target function. Uh but then looking deeper into the data and how those labels are chosen we realize okay there's um some creative freedom for the authors to choose what kind of label they want. Uh so even though description might make sense uh they might have chosen in that moment that they actually want to go for a different label and that's then also of course not recorded in here. And we also saw this uh improvement then generalized to the um test data set on yeah to 80.2%.
Um so the generalization was also on the 300 item unseen data um quite good and uh in a way that you could say okay this actually worked and um the most interesting thing uh we thought is that the first iteration immediately gained 10% and then it was only a little bit movement. So uh it somehow got a lot of information from this very first run already and made a made a big uptick uh that we can can see here um up until the yeah very close to the final result also and we um wanted to look closer into what it actually did here. So here we can see on the left side the um flat label list prompt. So here on the left again a screenshot from our platform where we managed the prompts and on the right side we can see what happened. So the very first thing it um added is a general classification approach. So how should the model think about um the behavior of uh choosing one of these labels? So when what's what's the main goal of doing so? Then there's some information on how to decide between two very similar classes and then also some um related confused patterns. So it's uh basically telling it um when to choose which and under which conditions and how to go about it and to rather go for the more specific label than for the more broad label because there's some implicit testing in the label structure as well. And then it also added some um examples for the the item pairs that it um yeah frequently missed or frequently mclassified. So this is what uh we can see here. Uh so overall the approach was um improvement loop added rules and examples and I would have probably I was surprised I would have probably um spontaneously added descriptions to the labels. Uh but the prompting guide or the model together with prompting guide um decided that actually the right approach is here and I mean it worked.
So uh I'm not going to going to interfere here.
Um yeah what we wanted to dive deeper a bit more then is what actually happened in this one 10% uptick uh that we have.
So let me remove myself a little bit because we need the bottom right corner.
So this is the um the reasoning step that clude oppus 4.8 took uh in this one jump from 68% to 78%. And what we can see here is that it has a very clear okay we have 64 errors. These are the dominating patterns. These are the number one answer sync and this is the biggest confusion. So also what are the two labels that are most frequently confused and where there's like um issues coming up. And then it's forming a hypothesis and saying okay this loop will extract ex exactly address this pattern. So it got a very clearcut um clearly quantifiable and reliable failure mode because they were just wrong on a yes no right wrong basis. Um they also had it had a lot of data to look at. we had a 200 item um fit data set which probably in most real cases um yeah it takes some time to get there and to also like make sure that it was only 10 labels so each of them got covered like um enough times that that it can get a signal from it um yeah and like this it could form a datab hypothesis and ended up uh returning a 10% gain on the first uh run and then I mean it was a bit of movement and we also found a better version then uh but the biggest jump was uh just the very first one from a very clear-cut signal, we could have probably stopped there and already have very good baseline.
So um given this right wrong high signal feedback works really really well on this classification test but also knowing that this is not um the case for all others like there's barely any deterministic yes no target functions in most cases you will run it this time and next time you get a different um next time you run the same evaluator you get a different answer from the same kind of evaluation you ran um just because yeah LLM as a judge is also the nondeterministic we were wondering how can we translate this right wrong high signal feedback into other applications.
So how can we try to shape this in a way it also works for your um vertical domain expert AI agent or for your uh automation of requirements extraction in medicine device um compliance or whatever your use case might be.
[snorts] And um for this um we overall see the approach working that um while the market for for a good reason likes those um evaluators like correctness or helpfulness or hallucination which like early in the days um were were a good um thing to go for. Um this is actually if you're trying to um autoimprove against this a rather low signal especially also because it's put on a often on a scale out of like between zero and one and 10 one and five and for this to really work properly you need to define each of those numbers. What does it mean in which context would you need which number? Uh which kind of criteria need to be met. Uh but this is most of the time also not done. So it's just choosing a number between zero and one and um depending on the uh context it might just uh totally change perspective and is therefore rather low signal and also probably inconsistent um across runs. What we see uh working instead is uh really looking into um what are the quality criteria that you want to work uh for your application. So what does good mean? Uh so for example instead of correctness the answer is based on the knowledge base yes no. So for example, if there's a snippet about internal information in the answer and you can check is it actually also in the ret retrieved context we did in the previous step or also if you're frequently struggling with cor using your correct brand voice you could look into okay um is it this time correct? Did we make sure that our name was written correctly? I've also seen companies that have English names that are checking for did we not accidentally translate our name to Spanish? things like this. And also um uh one thing that works well because it's also this categorization yes no is maybe some known failure modes. So which out of these five types of failures uh happened here and um can you categorize it? And these are only a few examples. Um we usually see that these are created by looking into the data, understanding what good means, what are things that are important to you and especially to your domain experts and creating these high signal um feedback loops. Um because if you can't do code compiles, you need to wrap your head a little bit differently around um what is good and what is not.
So um this is the one side. The other part is of course um the volume that you need. We had a like luckily we could have used thousands of examples. there's so many papers out there. We opted for like 200 train 100 validate um 300 test um just because we wanted to see that it properly generalizes um but we made the experience that this already got gave back a lot of um high signal feedback um so depending on the complexity of your application and the steps in there of course it might differ um but having the volume there and having the high signal feedback um oops are the foundation. So how do you get there? So the most important thing we see is working with your experts and this is like repeated advice and everyone's saying it and everyone's saying talk to your customers. Um but here it's something you can actually start to encode the domain expertise into very concrete examples. So use them to create examples what should come out of it. Look at those samples run sample runs together with them and also ask okay but why is it like this here and here um the other way? Uh because like this you can often also get information out of them that they implicitly think is clear and also um really understand um how the decisions are taken there and like this identify failure modes of your application and also define what good means because you probably need both and then use them to find these high signal evaluators. Then um as soon as you have this baseline and um you might hit production um review this data and don't review it only with your coding agents but review it as a human. look through it, understand like what is the the scope initially and um uh what is then being done with this application. This can shift over time. The failure modes can change. Um people might try to do other things and it's potential for feature um expansion and to really understand how the system works and fails in production um is necessary to to cover the typical failure modes and catch them uh before your customers do.
And then um finally um think about the whole thing as a system that generalizes. So you're trying to build up examples that are representative of what you might want to hit uh in production at some point. And um for this to properly generalize, you need to uh bake in mechanisms for validation. Uh so like in traditional machine learning context, um the validation approach is actually quite typical. So people um all the time make sure that they're actually validating if uh things don't overfitit.
And um this combined with like a real mechanism combined with like the instructions in your loop and giving the system an escape hatch instead of having it work for hours and hours uh hitting a wall and uh burning tokens. Um yeah are very important divas um to actually uh make sure that you're not um just burning tokens but actually looping towards um a system where a human and your agent together collaborate on an improving system.
Perfect. Thank you so much for uh listening to me. Um very excited that you took the time. And if you want to know more about Lenfuse and also how we think about these topics, you can find more on length.com. And I'm super excited to meet some of you at some point in person.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23