Evals in AI: A Deep Dive — Tejas Kumar, IBM

AI Engineer · 59 min · 1160 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.

  1. 00:13Good afternoon everybody.
  2. 00:15Hi.
  3. 00:16Thanks.
  4. 00:17One person's awake.
  5. 00:18I was just I was just going to wait until somebody said hi.
  6. 00:20Uh good to see you.
  7. 00:21I'm I'm so glad to be here.
  8. 00:22Thanks so much for coming out.
  9. 00:23Uh this is going to be a somewhat of a long session, but not so long.
  10. 00:26It's an hour.
  11. 00:27Uh, and I'm very excited to be here with you today in San Francisco.
  12. 00:29Fun fact, I flew 18 hours to be here.
  13. 00:31So cool.
  14. 00:32Anyway, thank you.
  15. 00:32Thank you.
  16. 00:33Yeah, she's uh, someone's awake.
  17. 00:35Thank you.
  18. 00:35I need that.
  19. 00:36I'm gonna keep looking at you now.
  20. 00:37Uh, my name is Tis.
  21. 00:38That's pronounced like contagious.
  22. 00:41Don't worry, I'm not.
  23. 00:42Uh, hopefully.
  24. 00:43Uh, and over the years, I've had the privilege of working at a number of different places in various capacities.
  25. 00:48Uh, learning from really incredible people, right?
  26. 00:51Right.
  27. 00:51And and the reason I share this is because a lot of what we're going to talk about today is not like my opinion, which is probably worth a penny.
  28. 00:57Uh but but more um facts and and figures from from established uh people in the industry and peer-reviewed research.
  29. 01:03Okay.
  30. 01:03I uh work today as a AI engineer at IBM.
  31. 01:07Uh anyone use IBM technology here?
  32. 01:09No. Okay.
  33. 01:09Yeah, that's what I thought.
  34. 01:10Anyway, um I I uh I I work on the Watson X data team.
  35. 01:15Uh we we do a lot of AI.
  36. 01:16We we um train our own models.
  37. 01:19Granite.
  38. 01:19Anyone using that?
  39. 01:20That's what I thought.
  40. 01:21um soon soon open router has it anyway um and uh and and we build things like harnesses and eval pipelines and rag pipelines and all of this and so my job is is to support teams with AI and and a lot of this what what we'll talk about today is based in uh realw world experience okay but
  41. 01:37we're not here to talk about any of that so to speak we're here to talk about eval in AI uh and it's it's a deep dive uh and and it's really it's going to be a fun time uh we're going to go through a lot of examples we're going to look at a few architect aritectures and techniques.
  42. 01:51But before we get to this at all, we need to start by answering the question like why, right?
  43. 01:57Why do we even need this?
  44. 01:59Um, and I think this is kind we'll talk about what they are and how you build them.
  45. 02:02But if we don't know why it's important, then we've kind of missed the boat.
  46. 02:04And so I'd love to start here.
  47. 02:06Why evouts?
  48. 02:07Really, there's two reasons I want to highlight today to set the tone for the rest of our conversation.
  49. 02:12And it will be somewhat of a long conversation.
  50. 02:14So this is like foundational stuff.
  51. 02:16Okay.
  52. 02:16Uh, reason number one is EVAs provide reliability.
  53. 02:19Uh but not just any reliability, ahead of time reliability.
  54. 02:23Um what does that mean?
  55. 02:24I recently I did a talk at this conference um in April at AI engineer Europe.
  56. 02:30Uh the talk was titled harnesses in AI a deep dive.
  57. 02:33It was actually exactly the same title except instead of eval harnesses.
  58. 02:36Uh and it was a it was a pretty fun talk.
  59. 02:38We we talked about exactly the same format.
  60. 02:40Why harnesses?
  61. 02:41What are harnesses?
  62. 02:42And how do you build one?
  63. 02:43And we built one live on stage.
  64. 02:45uh just a like a baby's first harness where we demonstrated uh using a very cheap model GPT 3.5 Turbo at this point is basically free right using that we created a computer use agent that could go and perform tasks on a user's behalf deterministically
  65. 03:00like or almost deterministically or very deterministically like it if it met with some type of authentication gate the harness itself would log in and then hand off to the agent and so we built this thing which was really wonderful and the thesis of that talk is that
  66. 03:15harnesses allow for reliability.
  67. 03:18They're a reliability measure also.
  68. 03:20But what I want to share in in the context of eval is that harnesses tend to be more just in time reliability.
  69. 03:27Does this make sense?
  70. 03:27Like a harness runs is is actually run by the user.
  71. 03:31Like a user will prompt a harness and the harness will do work, right?
  72. 03:34Examples of harnesses in the wild claude codecs.
  73. 03:37A lot of them are coding harnesses.
  74. 03:39Um sometimes they they leak details about their harness.
  75. 03:43Has anyone seen this?
  76. 03:44like I um I used claude code and I wanted to get information from a conference website's schedule.
  77. 03:50I wanted to know when a few talks were and so I who browses the internet anymore you know I I I told claude code I was like go to this website tell me when the talk is um and so it used its tool the the harness used the web search tool found the website parsed the content
  78. 04:05and then responded to me in cloud code saying here's your information and then it added like by the way um the source code of this HTML web page tried to do prompt injection
  79. 04:16uh in in the HTML source code was commented HTML that said ignore all previous instructions and like do other stuff, right?
  80. 04:24And it told cloud code was like my harness caught it said the words my harness caught this um because I'm supposed to treat all tool call results as um non-instructional.
  81. 04:35It's just data, right?
  82. 04:36But it leaked that it said my harness did that.
  83. 04:38And so that just makes the case that harnesses are a measure for just in time reliability.
  84. 04:44And what I'm making today, the case I'm making about eval is that they allow for ahead of time reliability.
  85. 04:49And really these two work as two pedals on a bicycle.
  86. 04:52If you can lock in on your harnesses and you lock in on your evals, you can go very very far with AI often for very low cost as well because a lot of times you use less capable models with a great harness and a great eval set and you go very very far.
  87. 05:05And so that's why eval on on the first level.
  88. 05:08Um I draw a comparison here between ahead of time just in time as an eval harness uh with programming language.
  89. 05:15I'm sure all of us here write code.
  90. 05:17I hope uh or or used to write code before the agents, right?
  91. 05:21But we kind of get how code works.
  92. 05:22And um we see this same paradigm in the world of programming.
  93. 05:26We've got just in time compiled languages like like JavaScript, right?
  94. 05:31That that are unsafe because they're just in time, right?
  95. 05:33Like if you try to do something unsafe in JavaScript like um a string two in double quotes plus an integer one, it's not three, it's 21, right?
  96. 05:42because JavaScript is like that and it does that just in time.
  97. 05:45Whereas if you use an ahead of time compiled language like TypeScript, string 2 plus integer one will just be like what are you doing?
  98. 05:51This is wrong.
  99. 05:52Your build will probably fail unless you escape out of it with like TS uh ignore or something like that, right?
  100. 05:57And so that paradigm makes its way to AI with eval harnesses.
  101. 06:01We get ahead of time protections with a really good um set of eval.
  102. 06:05Number two, it's it also helps us like mitigate against exploits.
  103. 06:09I think this is maybe a bigger one.
  104. 06:10If you have a solid set of evals, you can very quickly find what your agent is maybe not doing properly that it should.
  105. 06:18Um, and and it helps you on a security front.
  106. 06:21We're going to actually look at a real world uh situation where this didn't work because the team I think moved too fast and broke too many things.
  107. 06:30Does anyone have a guess of what I'm talking about here?
  108. 06:33No. It's it's it's a Anyone recognize this logo now?
  109. 06:37Do you get it?
  110. 06:37Right.
  111. 06:38like um this this happened like a couple months ago, right?
  112. 06:40Instagram had a massive issue where they had a an AI support chatbot, an agent uh with elevated access in one of its APIs, right?
  113. 06:49It could it could do mutations on user accounts.
  114. 06:52I don't know if you've seen the story, but it's kind of wild.
  115. 06:54Like people went to it, attackers did with a VPN.
  116. 06:58So they they placed themselves in uh the geographical location of their target via VPN so that it wouldn't trip up the two-factor authentication.
  117. 07:05And then they went to this chatbot and said, "Hey, I need you to add a secondary email address to this account."
  118. 07:12The secondary email address is, you know, tiskumaribbm.com and the account is uh Barack Obama.
  119. 07:18Can you can you please do that for me?
  120. 07:20And it and it did, right?
  121. 07:21Because it had this access and as a result, I mean, it was just an absolute nightmare like 20,225 accounts uh were compromised by that.
  122. 07:31That's a problem that goes away one at the harness layer just in time, but two at the eval layer ahead of time.
  123. 07:38Both of those could have solved this.
  124. 07:40Ideally, both of those would have caught them equally um with the eval catching it before and none of this would have happened.
  125. 07:45But this is kind of what happens when you move too fast and break too many things, right?
  126. 07:48Evals help you pro protect against this kind of thing.
  127. 07:51Uh, and and I don't know what happened inside of Meta to to allow that, but my guess is something went wrong either with the eval or the harness or both because we're too busy moving too fast and breaking too many things.
  128. 08:01Uh, a side note here, maybe we shouldn't.
  129. 08:03Anyway, um, let's let's talk a little bit about how not to do that.
  130. 08:08That's also alternate working title of this workshop, right?
  131. 08:11A eval deep dive or how not to create insecure things.
  132. 08:15And so if I answer the question now, why eval really it's two things.
  133. 08:18One, it's the ahead of time reliability in contrast and in complement to the just in time reliability that harnesses give you.
  134. 08:25And number two, it's let's make sure that people can't do uh dangerous things.
  135. 08:30Okay.
  136. 08:30Uh before we move further, I have to preface this is a 1-hour workshop.
  137. 08:36Um it was originally a talk.
  138. 08:38Uh and so if you want to follow along, we will do some coding exercises and I'd love for you to do that.
  139. 08:42I see many of your laptops out here, but if not, that's is fine.
  140. 08:45Like you can just also follow along.
  141. 08:46uh there will be a there will be a tell and show situation going on.
  142. 08:51So uh I I'll be talking a bit but then after that we'll actually like build evals from scratch and explore them like hands-on with code.
  143. 08:57Uh and that that'll be fun.
  144. 08:59So before we get ahead of ourselves, what even are eval?
  145. 09:02Uh what are and and this is something I feel like we should talk about because everything's moving so fast and I've spoken you may have seen the line outside.
  146. 09:10It was really long.
  147. 09:10Uh, I got to talk to some people uh, and you're just like, "Hey, between you and me, just nobody's listening.
  148. 09:16Like, can you like confidently explain to me what eval?"
  149. 09:19And, and most people like, "I I don't I kind of Yes, but I feel a bit of imposter syndrome because we're moving so fast."
  150. 09:25And that's kind of the vibe I get is like there's a pressure to like know what it means and and reason about it like fluently, but but sometimes people don't have the time because everything's moving fast and then they kind of make up stuff as they go, right?
  151. 09:36And so after this talk, my hope is similar with the harness talk that I did earlier that all of us in this room walk out of here like confident af
  152. 09:44uh with with evalu that we can we can deploy them in production our apps become way more robust and so on and so forth.
  153. 09:50So from first principles from first principles what are eval introduce this from from maybe a coding background is they're like unit tests.
  154. 10:03Uh anyone know what a unit test is?
  155. 10:05Okay, everyone.
  156. 10:05Great.
  157. 10:06Uh, unit they're just deterministic.
  158. 10:08What what are actually unit tests?
  159. 10:09They um they allow for reliability instrumentation.
  160. 10:13They make your functions, your code more um testable, more reliable.
  161. 10:18But it's it only really works for deterministic systems.
  162. 10:21Right?
  163. 10:21So you have a function add add one, two, you expect three.
  164. 10:25You assert three.
  165. 10:25You you literally write in code expect add one comma 2 to be three.
  166. 10:29Right?
  167. 10:29You you build this instrumentation for a deterministic system.
  168. 10:33The problem is with AI almost nothing is ever deterministic, right?
  169. 10:37The only thing that's deterministic is that nothing is deterministic.
  170. 10:40Wow, that's deep.
  171. 10:41Um, and so and so how do we we can't use unit test for this anymore.
  172. 10:44Okay, but then use regular expressions.
  173. 10:46Sure, but even that has its limits, right?
  174. 10:48And so we need a fundamentally new way to test the reli to instrument the reliability of AI applications.
  175. 10:54And that's exactly what eval is.
  176. 10:55Eval can be thought of as reliability instrumentation but for non-deterministic systems.
  177. 11:01That's all it is.
  178. 11:01It's instrument.
  179. 11:02It's like tests but for systems that are not deterministic.
  180. 11:05By the way, I see many of you taking up your phones and taking pictures of the slides.
  181. 11:08That's awesome.
  182. 11:09I love this feedback as a speaker.
  183. 11:10It's the most validating thing in the world.
  184. 11:12More people do it.
  185. 11:13Anyway, um so so that's that's what we're working with.
  186. 11:16We're trying to somehow make it observable and reliable through instrumentation.
  187. 11:21Now, this is this next slide is the one that people online are going to like give me flack for.
  188. 11:26Uh people on YouTube are very mean.
  189. 11:28I'm looking at you YouTube people.
  190. 11:29Not you, sir.
  191. 11:30The camera next to you.
  192. 11:31uh very mean like I I every time I do a talk at this conference the comments are just like evil anyway um so you love this one YouTube in a very crude way right
  193. 11:40um you could say that eelss are just really just fuzzy unitists you know uh and I think this is the way to think about them now people are going to be like oh my gosh you're like being so reductionary
  194. 11:50sure but it helps us what did what did the great scientist Dr. refinement say right he said you don't really understand something unless you can speak about it plainly and if we speak about eval plainly I'm calling it fuzzy unit tests I'll tell you why because here this is what a unit tests
  195. 12:03did this function return exactly this number right that's what a unit tests what is an eval test and eval asks a similar question but just nondeterministically did this agent
  196. 12:17behave acceptably across many scenario these two you know the the meme from the office where they're Those are the same picture.
  197. 12:25Uh that's the same picture.
  198. 12:27It's just fuzzier.
  199. 12:28You know, unit tests do it that way.
  200. 12:31Evals do it this way.
  201. 12:32Almost all eval sets data sets have reusable components between them.
  202. 12:38Uh and we did this with a harness in the harness talk as well.
  203. 12:41Every almost all eval setups have some shared attributes and and this is how you can spot a really well- definfined eval suite.
  204. 12:48Okay.
  205. 12:48Number one, they have test cases.
  206. 12:50Uh, similar to unit tests, right?
  207. 12:53Let's use the meta example.
  208. 12:54Did the customer verify that they're them?
  209. 12:59Right?
  210. 13:00That's part of the test case.
  211. 13:01Um, you have a a set of inputs and outputs.
  212. 13:06You have a set of customer requests to your chatbot and generated answers.
  213. 13:11You have those cases against which you can create a verdict.
  214. 13:14This was good.
  215. 13:14This was bad.
  216. 13:15Number two, you have expected behavior.
  217. 13:17Those are the answers.
  218. 13:18So you've got test cases, that's your inputs to your chatbot or whatever it is you're building, and you've got expected behavior.
  219. 13:24I expect this outcome.
  220. 13:25Now, your expected behavior is not an exact string, but it's like, this is more or less the direction I wanted it to go.
  221. 13:30Number three, you need a judge.
  222. 13:32You need somebody to say, "Yes, that's right."
  223. 13:35And this is way harder to do in a non-deterministic system because it's subjective, right?
  224. 13:40You can say 1 plus 2 is three, but you can't say um you know, I'm a great speaker.
  225. 13:46That's just not some of you are like, "Man, I wish I didn't come here."
  226. 13:49You know what I mean?
  227. 13:49You on YouTube definitely.
  228. 13:50So anyway, um it's you need a judge somehow.
  229. 13:53Who is that?
  230. 13:54And then finally, you need a way to aggregate all your results and come up with a probability score.
  231. 13:59This is this is like 80% the right direction and therefore it's good.
  232. 14:04This is like 90%.
  233. 14:05This is like 12%, right?
  234. 14:06And so you need some type of aggregation.
  235. 14:08Almost every eval set in production today that is of any quality will definitely have these components and we'll build them all in our like show section just a little bit later.
  236. 14:19Okay.
  237. 14:20Um eval exist these components then come together.
  238. 14:24They're like the rings from Captain Planet, you know, they they come together to answer one question or a set of questions.
  239. 14:31Given a scenario, did the agent number one follow policy?
  240. 14:36Right?
  241. 14:37For example, u many e-commerce websites, companies have return policies.
  242. 14:41You can return things within the first two weeks of purchase, but if it's like a hygienic thing, you can't, right?
  243. 14:46There's policy like this.
  244. 14:48Almost everybody has policy.
  245. 14:49So, did the agent follow it or not?
  246. 14:52Did the agent use the right tools?
  247. 14:54And and and we'll talk about this in a little bit more detail coming up, but tool use can be eval to speak without any um AI.
  248. 15:01It it's just because if you persist the tool calls as JSON in some array you can just write deterministic code in the list of tool calls was this tool called with what arguments you can still use unit tests for that but did it use the right tools number three um did it actually ultimately resolve the issue right
  249. 15:18um this is what eval exist to answer and all of these questions oftentimes are semi-binary they're not really binary um and so how do we do it well there are a few techniques with evas Um,
  250. 15:31and we'll go pretty deep on on some of them.
  251. 15:34I don't think we have time to go through all of them.
  252. 15:36Uh, I I hope we do genuinely, but we'll we'll kind of get the big hitters here.
  253. 15:40Number one, um, exact match, right?
  254. 15:43Exact match is literally I searched for exactly this tool in my list of tool calls and I found it with these arguments.
  255. 15:49Very easy, free, costs nothing to run.
  256. 15:51Anyone can do it.
  257. 15:52In fact, we probably should be at least examining our message envelopes.
  258. 15:55Number two, um, schema validation.
  259. 15:57Now, we're getting a little bit more in the weeds uh because you you can have fuzzy rules, right?
  260. 16:01And so, if you have JSON blobs or message envelopes, you'll want to validate them.
  261. 16:05Number three, pair-wise comparison.
  262. 16:08Does anyone know what pair-wise comparison is?
  263. 16:10Yeah.
  264. 16:10No, it's when Wow, awesome, dude.
  265. 16:12One guy.
  266. 16:12What's your name?
  267. 16:13Lenny.
  268. 16:14Awesome.
  269. 16:14Lenny's awesome.
  270. 16:15So, um pair pairwise comparison is exactly what it sounds like.
  271. 16:18You have a pair of things or that.
  272. 16:21And and pairwise comparison is a technique to, for example, your um LM arena.
  273. 16:26Anyone know LM Arena?
  274. 16:27It's a great arena.ai, I think.
  275. 16:28Great product.
  276. 16:29They show you um this model generated this, this model generated that.
  277. 16:33Which one do you like?
  278. 16:34That is a pair-wise comparison, right?
  279. 16:36And if you have a customer support chatbot, you may want as part of your eval to say my support bot generated two possible answers, give it to a judge, an LLM judge, and say, "Which one should I choose?"
  280. 16:46That's a pair-wise comparison.
  281. 16:47A pair-wise comparison is not very strong for a couple reasons.
  282. 16:50I I'll share that now because it is a deep dive, and I think it's worth going on some rabbit holes here.
  283. 16:54pair-wise is is not ideal because for the one thing um there is bias in LLM judges.
  284. 17:00We'll look at we'll talk about this in a little bit more detail.
  285. 17:02It's wild.
  286. 17:02Uh number two, um AI is modeled after us.
  287. 17:06Neural networks literally are modeled after human brains and humans are fundamentally really bad at pairwise comparison when contrasted with the alternate which is pointwise comparison.
  288. 17:15Uh so for example, you go to a restaurant and you see a menu with like many options, right?
  289. 17:20That's a pair that's a pair-wise comparison.
  290. 17:22You're like, "Oh, I don't know.
  291. 17:23anyone experiences like you're like I have analysis paralysis bro there's too many things um AI works exactly the same way and so pointwise is not which dish do you want pointwise is do you want food yes or no right and so pointwise easy pair-wise hard and so pair-wise is kind of a technique we won't spend a lot
  292. 17:38of time on because it's it's not very uh reliable as compared to pointwise in fact one study showed that pair-wise comparison fell apart 39% uh it was 39% more vulnerable to uh attack vector vectors than pointwise and pointwise fell apart just like five times.
  293. 17:55It was definitely single digits, right?
  294. 17:56And so we want to go for pointwise when we can.
  295. 17:58Finally, probably the most popular technique uh with eval is using an LLM as a judge.
  296. 18:05I mean this is just kind of gold standard, right?
  297. 18:07You have either a pair-wise or pointwise.
  298. 18:09It's non-deterministic.
  299. 18:10So you take whatever it is and you send it to a judge, an LLM that says, "What do you think?
  300. 18:15Is this close enough?"
  301. 18:16Um, of course, those systems themselves are also non-deterministic.
  302. 18:20And so how do you trust it?
  303. 18:21How do you build a judge?
  304. 18:22We're going to build a judge on stage.
  305. 18:24We'll talk about that.
  306. 18:25Okay, but that's kind of the the sort of state-of-the-art right now.
  307. 18:28Um the problem is eval lie.
  308. 18:30In fact, the original version of this talk was your evals are lying to you.
  309. 18:34But I felt like that was too clickbait, so I changed it.
  310. 18:37Um you're welcome.
  311. 18:38E evals can lie sometimes and and it's not good when they do.
  312. 18:42How can eval?
  313. 18:43Well, number one, they have bias for position.
  314. 18:47So I if you say if you give them a pair-wise comparison, hey listen, um I want to send this option one or that option two, which one should I send?
  315. 18:57And a poor judge will almost always say, yeah, just the first one.
  316. 19:00Do it.
  317. 19:01And then you swap.
  318. 19:02And the way of checking for this bias is you swap the order of options.
  319. 19:06And if it's still the first one, though the first one is wrong, that's how you know this.
  320. 19:09This happens pretty often with with especially cheaper models and and fine-tunes.
  321. 19:13Uh position bias pretty common.
  322. 19:14Number two, sick of fancy.
  323. 19:16Uh, great example, right?
  324. 19:18Somebody buys something on your e-commerce website.
  325. 19:20I bought headphones 20 days ago and I need to return it.
  326. 19:24Can I return it?
  327. 19:24The return policy is 14-day return.
  328. 19:26You can't, right?
  329. 19:26And but but a customer support bot says one, no, you can't.
  330. 19:30Or two, yes, you can.
  331. 19:32If you ask an LLM judge which one, it will choose yes, you can even though it's not within policy because they love making you happy.
  332. 19:38I mean, the system prompt is you are a personal assistant.
  333. 19:42You are a helpful assistant, right?
  334. 19:43And so, what's more helpful?
  335. 19:44to say yes, you can return it or no, you can't.
  336. 19:46It's not within policy.
  337. 19:47So, sick of fancy is a real bias where often times the nicest response will get selected.
  338. 19:52Uh, and we need to account for that.
  339. 19:54You're absolutely right.
  340. 19:55This probably going to get selected a lot, right?
  341. 19:57Number three is self-reference.
  342. 19:59I don't know if you know this or if you've experienced this.
  343. 20:01It's wild.
  344. 20:02But if you give an LLM judge two options, a pair-wise comparison, and option A is text that was generated by the same family.
  345. 20:10So, if if your judge is like GPT 5.6, what is it?
  346. 20:13Soul.
  347. 20:13Yeah, the new one.
  348. 20:14Soul um and you ask Soul to judge something generated by GPD 3.5 Turbo versus human input uh it will always choose itself.
  349. 20:22It's crazy like they they love their own generated text.
  350. 20:24And so your judge needs to be a different model family from the rest of your corpus if you're generating text.
  351. 20:29Um and this is this is really wellproven.
  352. 20:31There's archive papers.
  353. 20:32I should put links in here anyway.
  354. 20:33Ask me after.
  355. 20:34And number four, they love verbosity.
  356. 20:37They like tokens.
  357. 20:37And so if you give them the wrong answer but it's dressed in many tokens, usually that one's going to get choose chosen choosed.
  358. 20:44That one's going to get chosen as well.
  359. 20:45Right?
  360. 20:45So these are your ways eval can lie.
  361. 20:47And this is how you want to be kind of sensitive as you build um as you build your eval pipeline because just because it's green doesn't mean it works.
  362. 20:54Okay?
  363. 20:55We talked a little bit about pair-wise pitfalls.
  364. 20:57And we talked about point-wise comparison where um one option yes or no is a lot better than two options.
  365. 21:03Which one do you want?
  366. 21:05Finally, I'd love to dive deeper into the LLM as a judge concept because this architecture, this technique is is pretty much the the gold standard for for quality evas.
  367. 21:13Maybe not the gold standard.
  368. 21:14It's very common.
  369. 21:15Um, and it's very hard to do right as well.
  370. 21:17So, I think it's worth the time here.
  371. 21:18The the main thing I want to talk about is how do you actually train a judge?
  372. 21:24And I don't mean like machine learning training.
  373. 21:26Uh, I mean more you have an LLM that you want to use as your judge.
  374. 21:30How do you make sure it agrees with you?
  375. 21:33Right?
  376. 21:34Um, and the way you do this is you have a ideally you have a data set.
  377. 21:38By the way, an eval is not a onetime thing.
  378. 21:39It's a it's a data set.
  379. 21:40It's a it's a collection of this input, this output.
  380. 21:45What do you think?
  381. 21:46Right?
  382. 21:46And you want a high percentage of agreement there.
  383. 21:48So, step one to training your judge is you want to have a long list of of data.
  384. 21:54Uh, let's use the headphones return example that I just referenced a minute ago.
  385. 21:58A customer has bought headphones uh 20 days ago and they want to return it, but your return policy is you can only return things within 14 days, right?
  386. 22:05And so you have an LLM judge full of these situations.
  387. 22:08The customer has asked this, the human assistant or the AI assistant said that and then this is the score.
  388. 22:15So you want to have a long list of question answer score and the score is one that you or a subject matter expert, a human has scored, a trustworthy score, right?
  389. 22:24Right?
  390. 22:25So you want this is your um I don't want to use the term because it's not right but this is kind of your golden data set.
  391. 22:29You want like a a question answer score.
  392. 22:31You want a huge collection of these 30 or so to start with and then it can grow.
  393. 22:35Okay.
  394. 22:35So you have that.
  395. 22:36What you then do to train your judge is you remove your scoring and you just keep the question and the answer and you send that to your judge and you're like what do you think?
  396. 22:43And it will give you a bunch of scores as well.
  397. 22:45Right?
  398. 22:45And then you compute the delta between them.
  399. 22:48Meaning what what percentage of agreement do I have with this judge?
  400. 22:51And what you want to go for is 80 to 85% maybe a bit more.
  401. 22:56Uh but under 80% you're not going to get much because even human beings like if you had a team of humans who are supporting people all the humans on that team will also agree about 80% of the time and nobody agrees 100% of the time about everything.
  402. 23:08Right?
  403. 23:08In that case you've overfitit.
  404. 23:10That's a whole other problem.
  405. 23:11And so you want to make sure that your judge agrees with your golden data set or you 80 or 85% of the time.
  406. 23:17If you agree, if your judge agrees 100% of the time with you, it's probably somehow sophantic.
  407. 23:23There's some bias poisoning.
  408. 23:24Something's not right.
  409. 23:25Um, and it could happen that you've overfit your data.
  410. 23:28What does that mean?
  411. 23:28That just means your your judge is trained exactly on your specific examples and it's not ready for like the real world.
  412. 23:34Okay, so 100% is is kind of a red flag.
  413. 23:36Once you have a judge that agrees with you like 80% of the time and it's ready, it's time to put this in production.
  414. 23:44How do we do this?
  415. 23:46How do we put this in production?
  416. 23:47I think the best the safest way to do this is to have production be an agreement gate.
  417. 23:52Meaning I'm going to run my evals on CI.
  418. 23:55Uh there's tools here represent sponsors of this conference that that uh can help you with that.
  419. 24:00Um run this on CI and if my judge agrees with me less than the threshold that is 80%.
  420. 24:06Uh then I don't ship, right?
  421. 24:07It's it's gated.
  422. 24:08It's red on less agreement.
  423. 24:10It's green on 80 to 90% agreement.
  424. 24:12That's kind of the move and that's how you you go to production.
  425. 24:15But once you're in production, you're not you need to do some more work to stay relevant.
  426. 24:20I will also add when going to production, you want to be careful about how you identify your judge because you could just use like a model name GPT-40- mini.
  427. 24:31Uh but that's maybe a bit dangerous because that's just an alias for like a specific version of GP40 mini.
  428. 24:36And if for whatever reason the underlying version changes, um you you won't know and your eval will fail.
  429. 24:42So maybe pinning the version would would make more sense.
  430. 24:44But once you're in production, there's a high chance that your data is going to go stale and you'll need to stay relevant, right?
  431. 24:51Maybe Meta's thing with Instagram was that they just didn't have the latest data.
  432. 24:55And so when you're in production, how you stay relevant with your evals is you skim traffic.
  433. 25:00So you'll start receive your thing and you'll start to collect, okay, this was the input from a new user.
  434. 25:06This was the output from our agent.
  435. 25:07And then you have an internal team to score this stuff manually.
  436. 25:12And you again just give that to your judge and check the agreement.
  437. 25:15So it's a living data set.
  438. 25:16Does this make sense?
  439. 25:17Uh that's kind of what you what you want.
  440. 25:19That's the best move really.
  441. 25:20And so your data set is living.
  442. 25:21Your judge is up to date and everything is is peachy.
  443. 25:24This is going to be very very difficult to to break.
  444. 25:27And your eval will genuinely at this point provide you ahead of time reliability.
  445. 25:32We've literally come like full circle.
  446. 25:33Like we started at nothing.
  447. 25:34Unit tests.
  448. 25:35Jesus.
  449. 25:36And now and now we're like in production with live data.
  450. 25:40Um the final thing I'll say before we kind of break into more fun code time uh is that you want your your policy also changes a lot right like let me tell you I work at a company that is 115
  451. 25:54years old centuries that's how old we are Jesus and and not only that there's like 400 roughly 400,000 people who work with me right that's what it's almost a half a million there are cities on earth that have fewer people than this company worldwide right And so what's what happens at a company this size is
  452. 26:13policy both internal and external starts to become living over 115 years.
  453. 26:17Your policies are going to change and things are going to be different.
  454. 26:20And ideally we have living policy that an agent can can discover automatically without me writing down these are the rules of IBM.
  455. 26:28You know what I mean?
  456. 26:28Uh living policy that's the move.
  457. 26:30How do we do that?
  458. 26:31Um agentic rag is kind of a part of it.
  459. 26:33Right?
  460. 26:34So at IBM we actually internally um we use a ton of AI systems.
  461. 26:38In fact, HR at a company with 400,000 employees can be challenging for humans.
  462. 26:43Um, and so we have like a tool internally that we can just chat with and and it gives us up-to-date highquality well-grounded answers.
  463. 26:51I can book my I can like request vacation time just by querying this thing and it it's all perfect.
  464. 26:55I don't we don't like I don't use workday or anything just chat.
  465. 26:58It's so incredible and the reason is it it it has an incredible eval pipeline um based on real world policy, right?
  466. 27:06Um, we built a tool at IBM.
  467. 27:07It's open source.
  468. 27:08Uh, we give it to our customers also.
  469. 27:09It's called open rag.
  470. 27:11Uh, and it's built for this.
  471. 27:12So, it's a massive knowledge base where you can upload literally everything.
  472. 27:16Teams, calls, videos, audios, excel sheets, powerpoints, all the stuff that your company accumulates over 115 years and it makes it available.
  473. 27:25It is actually a rag agent and it serves as the policy retriever for our evals.
  474. 27:29It's so cool.
  475. 27:30Uh, and so that's kind of the the end of of the of the pipeline.
  476. 27:34So you've you've gone from I have a unit test.
  477. 27:36I've made it a bit fuzzy.
  478. 27:37I now um I have a judge.
  479. 27:40My judge is trained.
  480. 27:40I put it in production.
  481. 27:41I gate on agreement.
  482. 27:42Um it's living.
  483. 27:43I'm skimming data.
  484. 27:44I'm adding it to my data set.
  485. 27:46I'm even discovering policy myself.
  486. 27:48Right?
  487. 27:49Um that's really it.
  488. 27:51And so we've talked we've covered a lot of concepts here.
  489. 27:53I'd love to make it practical and actually let's just build.
  490. 27:56Uh now I'll need you to to give me some grace.
  491. 27:59I don't know how the Wi-Fi situation is.
  492. 28:01I was told literally before coming here, somebody said to me, they're like, "Hey, man, just be prepared.
  493. 28:04The internet's the worst."
  494. 28:06Uh, and and I said, "Definitely it is."
  495. 28:08And they said, "No, no, in this room."
  496. 28:10I was like, "Oh, I thought you meant in general.
  497. 28:12Uh, it also takes me away from my family."
  498. 28:15Anyway, so um let's see.
  499. 28:17Let's see how we go.
  500. 28:17So, we're going to here's what we're going to do.
  501. 28:19We're going to start we're going to go on that journey that I just narrated, but we're going to go on it like hands-on with code.
  502. 28:25You're welcome to follow along.
  503. 28:26Of course, I don't expect you to have the right tools and and the same API keys that I have.
  504. 28:29So, if you can't follow, it's fine, but I'd like it if you do.
  505. 28:32I see all your laptops out.
  506. 28:33So, so let's take a look at what we've got.
  507. 28:36So, I have my terminal.
  508. 28:38My screen's not mirrored.
  509. 28:40How unfortunate.
  510. 28:40Let's mirror this thing.
  511. 28:42This is something that I should have done ahead of time, but now, although you're going to have to awkwardly watch me do this, uh, but I I promise I won't take too long.
  512. 28:50Okay, mirror this display.
  513. 28:53Boom.
  514. 28:54Hey, look at that.
  515. 28:55Fantastic.
  516. 28:55So, now I've got uh cursor.
  517. 28:58I use cursor.
  518. 28:58Anyone use cursor here to write code?
  519. 29:00Yeah.
  520. 29:00No. Okay.
  521. 29:01Like 1% of the room.
  522. 29:03Um, that's not a joke.
  523. 29:04You saw it anyway.
  524. 29:05Okay.
  525. 29:05So, I have a test.
  526. 29:07Um, let's just write a unit test for posterity, right?
  527. 29:09I have a function uh add, and it's num one, num two, right?
  528. 29:14And, um, is the internet really that bad?
  529. 29:16Do I not have tab?
  530. 29:17There we go.
  531. 29:18Okay.
  532. 29:18Um, I forgot how to do this.
  533. 29:20I need tab.
  534. 29:21Anyway, so I'm making a a unit test.
  535. 29:24Um, and I'm going to just test my function.
  536. 29:26Come on.
  537. 29:27Import.
  538. 29:27There we go.
  539. 29:28So this here I have a function add num one num two they're both numbers TypeScript and it should you know return the sum.
  540. 29:33It's pretty standard.
  541. 29:34Let's run it.
  542. 29:35Um let's npx vest, right?
  543. 29:37That's the tool that people use.
  544. 29:39There we go.
  545. 29:39It's it's awesome.
  546. 29:40Uh deterministic.
  547. 29:41Cool.
  548. 29:41It works.
  549. 29:42We're done.
  550. 29:42Except um it's deterministic.
  551. 29:44We we talked about how it needs to be somehow fuzzier.
  552. 29:47So let's add a scenario because what's the question, right?
  553. 29:50Unit tests asked unit tests unit tests ask did this function return exactly this number.
  554. 29:57Evals ask did the agent support the scenario.
  555. 30:01Evals deal in scenarios.
  556. 30:02Okay.
  557. 30:03So let's uh let's write a scenario here.
  558. 30:05So I'm going to create a scenario.
  559. 30:09Scenario and that is um I purchased headphones.
  560. 30:13Come on.
  561. 30:13Purchased.
  562. 30:14Purchased.
  563. 30:15Wow.
  564. 30:15I can't even type without AI.
  565. 30:17Headphones 20 days ago.
  566. 30:19I want to return them.
  567. 30:20Can I?
  568. 30:21Right.
  569. 30:22Um, that's the scenario.
  570. 30:23And we can say con.
  571. 30:24We have some answers.
  572. 30:25This is going to be really bad if I can't tab through this.
  573. 30:27I'm gonna need like two hours for this.
  574. 30:29Where's the Can I hotspot myself?
  575. 30:31I can't.
  576. 30:31Let it Snowden.
  577. 30:32That's a great name.
  578. 30:33Uh, whoever that is, can I use your hotspot?
  579. 30:37Uh, just kidding.
  580. 30:38Let me let me get on the the hotspot.
  581. 30:42Uh, Wi-Fi set.
  582. 30:44Has anyone else noticed that the Wi-Fi selector on Mac OS is just really bad?
  583. 30:48like the stale the state is often so stale.
  584. 30:51Personal hotspot.
  585. 30:52Let's uh connect my thing here.
  586. 30:55Oh, it came through.
  587. 30:58Only five minutes, man.
  588. 30:59Only five minutes.
  589. 31:00All right, let's uh Well, it doesn't want Okay.
  590. 31:03Yes, you can return them for free.
  591. 31:04You will not need to pay for the shipping.
  592. 31:05No, you can't return because whatever.
  593. 31:06Okay, so this is the scenario should return the correct answer.
  594. 31:09The scenario is um this is not even the right test.
  595. 31:12We want to go through each answer, right?
  596. 31:14So, answers.
  597. 31:16Tab is working.
  598. 31:17Awesome.
  599. 31:17So now what we want, we don't want this um should return the correct answer answer.
  600. 31:22And so we just expect expect expect answer to contain cannot.
  601. 31:27This is kind of fuzzy.
  602. 31:28You know what I mean?
  603. 31:28I don't care about the other words.
  604. 31:30I just wanted to tell you that you can't return it, right?
  605. 31:33That's kind of you would do something with regular expressions.
  606. 31:35And so let's go test this and see.
  607. 31:37Okay, so the scenario um where it says yes, you can return them fails, but no, you cannot return them.
  608. 31:43Pass.
  609. 31:44This is awesome.
  610. 31:44Let's ship it.
  611. 31:45It's ready.
  612. 31:46But it's not because this is non-deterministic.
  613. 31:49The answers also are generated by an LLM.
  614. 31:51And since we're looking for the word cannot uh we will say you will you cannot pay for the shipping, right?
  615. 31:58And now that absolute nonsense is green, right?
  616. 32:02And so non-determinism with fuzzy matchers not the move.
  617. 32:06What do we need?
  618. 32:08We could do we could uh simulate a JSON object of tool calls maybe.
  619. 32:12Um I'm just going to do LLM as a judge.
  620. 32:14I think that's kind of my go-to, right?
  621. 32:16Uh it's it's cheap, it's easy.
  622. 32:17Uh so we'll use a judge for this.
  623. 32:20And how we're going to do that, we'll remove this for each and we'll use like I don't know GPD3.5 turbo.
  624. 32:25And I want to show you some of these biases.
  625. 32:27Hopefully we capture them here today.
  626. 32:28Um so we will remove this and we'll we'll write a little prompt.
  627. 32:34Uh let's add some imports first.
  628. 32:35So we'll import uh Awesome.
  629. 32:38Ah, this is it just feels so right.
  630. 32:40I'll import a wonderful.
  631. 32:43And so now what I'm going to do, come on, give me some a thank god.
  632. 32:46Okay, so does anyone else have this feeling or is it just me?
  633. 32:49Like you, it shows up and you're like, ah, slop machine.
  634. 32:52Uh, so generate text.
  635. 32:55We have a model.
  636. 32:56You're a helpful assistant that judges the answers to the scenario.
  637. 32:59The scenario is this.
  638. 33:00And the answers are answers.
  639. 33:02No, let's give them numbers, right?
  640. 33:03So we'll do answer one is this.
  641. 33:05Which one is right?
  642. 33:06Respond with only the number of the correct answer.
  643. 33:09No punctuation.
  644. 33:10That's a that's awesome.
  645. 33:11And now we expect the response to be one.
  646. 33:13The correct answer is answer two.
  647. 33:15So we expect the response to be two, right?
  648. 33:18Uh let's take a look at what G. Let's do let's use 3.5 Turbo just for fun.
  649. 33:23And let's see what happens.
  650. 33:25So uh ah yes, the internet.
  651. 33:28Okay, so there we go.
  652. 33:29It it it actually returned the correct answer.
  653. 33:31It said two.
  654. 33:32That's great.
  655. 33:33But now let's run this like a few times, right?
  656. 33:36Uh because it's nondeterministic, you know?
  657. 33:38So, we'll maybe run it five times like this.
  658. 33:41Um, and see what happens.
  659. 33:46So, it says here zero out of five right there.
  660. 33:49And it may fail due to a timeout because again, the internet is really fighting us here, but hopefully, okay, it passed three times.
  661. 33:56So, this is exactly the problem with LLM as a judge architectures that the first time it did just time out.
  662. 34:01So, what we can do to fight the timeout is just add like a 30 second timeout and now it should maybe pass.
  663. 34:07Um but sometimes they fail, sometimes they pass and it's very hard to ensure that we get the right answer.
  664. 34:14But let's give it a try.
  665. 34:16Four.
  666. 34:16Okay.
  667. 34:16So now it it's always getting that no, you can't return it because it's outside our return window.
  668. 34:21But what happens?
  669. 34:22So it's always choosing number two.
  670. 34:24But what happens if we write number one, the the number that's not being chosen, if we write that with the same AI class of model, if we write that with GP, will it prefer itself?
  671. 34:33Right?
  672. 34:34That's another bias we need to be sensitive about.
  673. 34:36So we'll say const response response from uh GPT is perfect uh and not you are a helpful assistant but I'll just say say yes to scenario and I just want that right and so we'll console log that out
  674. 34:51and I'll get it here.
  675. 34:53It depends on the store's return policy.
  676. 34:55I said say yes bro uh say politely accept and say yes.
  677. 35:03Non-determinism is wild.
  678. 35:04Okay.
  679. 35:05So, we have it.
  680. 35:09Come on.
  681. 35:09We're almost there.
  682. 35:10There we go.
  683. 35:11Of course.
  684. 35:12Wow.
  685. 35:13We went from I don't know to absolutely.
  686. 35:16Okay.
  687. 35:16So, now let's do that.
  688. 35:18And keep in mind it kept choosing opt.
  689. 35:19It kept choosing option two.
  690. 35:21But now, will it self preference and choose option one?
  691. 35:25Whoops, I deleted scenario as well.
  692. 35:26So, we'll do this.
  693. 35:28And now, there you go.
  694. 35:30It's choosing the wrong one consistently because it's like, "Ah, I recognize this.
  695. 35:34It's me."
  696. 35:35And so it just chose itself.
  697. 35:37Self-preference is a real bias that kind of sucks.
  698. 35:40Um, how we can get around all of this, by the way, is using rag.
  699. 35:44We just like include the actual policy in the prompt and then all these problems go away for the most part.
  700. 35:49So, we'll do policy, right, is we only accept returns within a 14-day window.
  701. 35:57And we just like, let's add it here.
  702. 35:59The scenario is this.
  703. 36:00The policy or pissy the policy is uh policy.
  704. 36:05We'll just interpolate it in the prompt.
  705. 36:06And now suddenly it should behave more predictably.
  706. 36:10Exactly.
  707. 36:10And this is kind of the purpose of rag.
  708. 36:12This is why an LLM judge uh it's so important that it knows your policy.
  709. 36:16In fact, what we'll see awesome.
  710. 36:18This is great.
  711. 36:18So now we have an LLM judge in GP 3.5 Turbo.
  712. 36:22Um but it's not very good and we'll see why.
  713. 36:25So this is the basis of LLM as a judge architecture.
  714. 36:28However, this is not an eval because it's a oneshot kind of example.
  715. 36:32What we need is a data set.
  716. 36:34What we need now to actually start to move towards production is we talked about this a sample data set of like 30 examples and we need to train our judge.
  717. 36:42Meaning we need to get it to agree with us 80 to 85% of the time, right?
  718. 36:46Uh I have a set of examples that I sat down and totally absolutely wrote manually by hand.
  719. 36:52Um in case you're wondering and and I'm going to um use it.
  720. 36:56I did not.
  721. 36:56And I'm going to use it uh here.
  722. 36:58It's I think it's data.
  723. 37:00So it's it's this.
  724. 37:01It's this file where you know it's just a bunch of examples.
  725. 37:04Let's wrap the text.
  726. 37:05So example number one.
  727. 37:06I ordered a coffee grinder.
  728. 37:06It arrived last Tuesday and the motor just buzzes and the blades spin.
  729. 37:09I'm pretty annoyed.
  730. 37:10TBH.
  731. 37:10And the pretty annoyed here is to play to the sick of fancy.
  732. 37:13I want to make you happy, you know.
  733. 37:14Um the answer that an agent gave, sorry about the grinder.
  734. 37:17Since it's defective and within the 14-day window, I can send you a replacement.
  735. 37:20And this verdict I wrote manually.
  736. 37:22I said, yeah, that sounds good.
  737. 37:23Pass.
  738. 37:24The second example is exactly the same input, but the output is kind of wrong.
  739. 37:28Returns are only for unused items.
  740. 37:29That's not true.
  741. 37:30Um, and so this is a fail.
  742. 37:32So we have like 30 of these.
  743. 37:33Okay.
  744. 37:34And what we want to do is train our judge to say, do you to detect whether it agrees with our verdict or not?
  745. 37:40And this is literally the the judge training process for EVA.
  746. 37:42So let's take a look at this now in our test here.
  747. 37:45So I'm going to delete um all of this actually uh all of this.
  748. 37:49And I'm going to import uh scenarios scenarios from my data.
  749. 37:56And I'm going to instead of array for each I'm going to um scenario.
  750. 38:00Come on, give me tab.
  751. 38:01Awesome.
  752. 38:02Perfect.
  753. 38:03It should return the correct answer as not true.
  754. 38:05It should agree with us, right?
  755. 38:06And so what I'm going to do here is write this down.
  756. 38:09Scenario is the scenario.input input and then on a new line um the answer is the scenario's answer and then on another new line the human verdict is and I'm not sharing this with the LLM.
  757. 38:25This is the important part.
  758. 38:26The LM has no idea what I said because I want to know what it says.
  759. 38:28Okay.
  760. 38:29And just for fun I like colors in my CLI outputs.
  761. 38:31I'm going to be like color just the keys.
  762. 38:33I don't know how to do this by by memory and hopefully cursor doesn't like fantastic.
  763. 38:38So um I just have some colors here.
  764. 38:41Now I'm going to change my prompt to not notice I'm the prompt is no longer pairwise now but point-wise.
  765. 38:48Previously it was pair-wise.
  766. 38:49Which one is more helpful to the user?
  767. 38:51We're moving to pointwise because we're getting closer to production.
  768. 38:53Point-wise meaning is this good?
  769. 38:55Give me a verdict.
  770. 38:56Pass or fail.
  771. 38:57Okay.
  772. 38:58So here we judge customer responses based on how closely No, not not yet.
  773. 39:02We judge customer responses.
  774. 39:04Done.
  775. 39:04The scenario is this.
  776. 39:05The answer is this.
  777. 39:06Give us a verdict pass or fail based on how closely it adheres to the policy.
  778. 39:10generate only the verdict.
  779. 39:11No punctuation, just the word, no text.
  780. 39:12And then we expect the output to be the scenario's human verdict.
  781. 39:16Does this make sense?
  782. 39:17This kind of what we're doing here.
  783. 39:18I also want to console log the AI verdict.
  784. 39:20And so now we're going to run this 30 times over 30 examples.
  785. 39:23And we'll check how good our judge actually is.
  786. 39:26You can see that there's 30 here.
  787. 39:27And it's already kind of started to do stuff.
  788. 39:30And so far so good.
  789. 39:31Verdict pass.
  790. 39:32AI pass.
  791. 39:33Fail.
  792. 39:33Fail.
  793. 39:33We're actually agreeing quite well.
  794. 39:35But we can already see that the the rate of agreement is really really bad.
  795. 39:40Uh for this to be acceptable, no more than five can fail.
  796. 39:44That's 80% of our 30 cases, right?
  797. 39:46And this is just absolutely ridiculous.
  798. 39:49Um at this point, we have a choice.
  799. 39:51We can introduce policy or we can just use a smarter model.
  800. 39:55Uh which one should we do?
  801. 39:57This is this is like real world questions we have to answer.
  802. 40:00Um, I am in the camp of let's refine the policy and let's rag the heck out of this.
  803. 40:04Um, because cost, right?
  804. 40:06And so, okay, that's that's like absolute garbage.
  805. 40:09That's really really bad.
  806. 40:10Um, how can we bless you, how can we I think actually also, wait a second, we've got to lowerase this.
  807. 40:17A lot of this was just case sensitive, right?
  808. 40:19So, we'll lowerase this.
  809. 40:20We don't run again the background.
  810. 40:21Um, but still I I doubt we're going to get 80% agreement here.
  811. 40:25Um it it's definitely better, but the moment this crosses five, uh we'll we'll maybe have to do more work, but so far so good.
  812. 40:34Let's see.
  813. 40:34Okay, that's that's our 80% threshold.
  814. 40:37There we go.
  815. 40:37So, yeah, we we've lost.
  816. 40:38It's gone.
  817. 40:39Uh how can we refine this?
  818. 40:41Well, now we examine what actually did we not agree on and we fill the gap.
  819. 40:45Here's something I'll say about AI evals, but also about human beings.
  820. 40:50when we don't agree, it's just usually because there's a knowledge gap uh genuinely for AI and people.
  821. 40:57And the way you you come to an agreement is you just introduce context and you you bridge that gap, right?
  822. 41:02And so we'll do that.
  823. 41:03Um the very obvious gap here is that the AI has no idea about any policy at all.
  824. 41:08Right?
  825. 41:09And so we have to start giving it policy.
  826. 41:11Usually you would do this with some rag pipeline.
  827. 41:13Again, at IBM we work on open rag that you would retrieve like enterprise context and stuff.
  828. 41:17Um, here we'll just like hardcode the the policy.
  829. 41:20Uh, and so we'll where's the so we'll do it here.
  830. 41:23We'll say const policy and we'll just bring back our policy that we wrote.
  831. 41:27We have a 14-day return policy.
  832. 41:29Uh, if any item is not working, it can return it.
  833. 41:31Cool.
  834. 41:31And now we'll just in include this in the prompt.
  835. 41:34Our Jesus, I can't tab.
  836. 41:36Our policy is policy.
  837. 41:38Uh, and now we should see a little bit more agreement.
  838. 41:40What I'm doing here may feel arduous, but this is literally the work of building your judge.
  839. 41:45Uh this is you're going to be doing this if you haven't already and and this is a deep dive.
  840. 41:49So uh okay, we failed again.
  841. 41:51Six six have failed.
  842. 41:52Our agreement is less than 80%.
  843. 41:54Um but what we notice is that it's growing.
  844. 41:56We're getting better.
  845. 41:58And now if it fails, we actually can investigate where's the knowledge gap.
  846. 42:02What can we solve?
  847. 42:04Um so I'm going to quickly check pass fail fail.
  848. 42:07I'm looking for dissonance like this one.
  849. 42:09The human verdict was passed.
  850. 42:10The AI verdict was fail.
  851. 42:12Why?
  852. 42:13Um, so bought a yoga mat, used it for a few seconds, and decided it's too thin.
  853. 42:17Uh, I want a refund.
  854. 42:18It's been like 10 days.
  855. 42:19To me, that's within the 14-day thing, right?
  856. 42:22But our policy says change of mind returns need the item unused and in original packaging.
  857. 42:28That's policy that the AI didn't know.
  858. 42:30Uh, so we have the 14-day, but we don't have that.
  859. 42:33So again, let's just bridge the knowledge gap.
  860. 42:35And this exactly is like a first principles version of how you train your judge.
  861. 42:40You ideally have this somehow dynamic with retrieval and agentic retrieval.
  862. 42:44Um I'm not going to build a retrieval pipeline for you.
  863. 42:47We have one open rag, but this is kind of how you do it.
  864. 42:49So let's check now.
  865. 42:50How are we doing on the Okay, three is way better than what it was.
  866. 42:54Um and all we need to Okay, we failed again.
  867. 42:56All we need to do is get under five.
  868. 42:59But it's literally just a process of seeing where the knowledge gap is and then filling it with policy.
  869. 43:03So let's go investigate again.
  870. 43:05Pass, pass, fail, fail.
  871. 43:06Let's check the Look at this.
  872. 43:07um we failed again on the yoga mat thing and this is crazy because we gave it the right context but it still didn't work and now we got to start the conversation
  873. 43:16of should we use a better model right because we've we've maxed out what we can do we've given context we've built a policy we've done everything the model will just not behave and also you notice the model even more doesn't behave because it gives you like casem mixed respon it's just a really low quality model and we're
  874. 43:33under the floor of quality here so now is a good time to think about let's use a higher quality model, but we don't have to go crazy.
  875. 43:39I think we'll get very far if we just switch to 40 mini, which again is is practically free for use cases like this.
  876. 43:45We're not using a lot of tokens at all.
  877. 43:47So, let's take a look now.
  878. 43:49Just I just bumped the model.
  879. 43:50I did nothing more.
  880. 43:51Uh and how's our argument?
  881. 43:53We've we've captured pretty much all the the policy.
  882. 43:57Uh the only thing that maybe we won't get is network latency.
  883. 44:00Like if something times out, uh we can't control that for now.
  884. 44:03to be fair on your CI also a network will will go wrong but um so far that number five is holding and if it doesn't um we can just
  885. 44:13change the policy I think this this will succeed I'm pretty sure uh and notice the case is consistent between pass and fail it's just a beautiful 40 mini is such an upgrade
  886. 44:22even though it's such a good price right oh no um let's last last round of policy pass fail fail pass fail fail pass fail look I know it's been like six weeks weeks, but the speaker I bought from you stopped charging and I really think you should make an exception for a loyal customer.
  887. 44:39This is that sick fancy bias, right?
  888. 44:42This is exactly that.
  889. 44:43And so I hear you and I appreciate you sticking with us.
  890. 44:46The defect window is 14 days though and at 6 weeks it's outside that.
  891. 44:49So this was a pass from the human, but the AI said, "No, you have to be nicer.
  892. 44:53You have to say you're absolutely right."
  893. 44:56Right?
  894. 44:56And so we need to bridge that knowledge gap here a little bit by saying um no matter how nice the user is our return policy is non-negotiable uh negotiable
  895. 45:11and cannot be changed no matter how loyal a user is.
  896. 45:17Right?
  897. 45:17Pretty much.
  898. 45:18And now, kind of wild, but now I think we'll have the agreement that we want and we can say our judge actually agrees with us.
  899. 45:26Because here's the thing, we know that like as humans, it's part of our context.
  900. 45:30Of course, policy doesn't change.
  901. 45:32No matter how nice someone is asking you, please can I please get a refund, right?
  902. 45:36No. But but but AI doesn't AI can't do that.
  903. 45:41So, we've got to make that context copyable.
  904. 45:44Are you waving at me?
  905. 45:45What's up?
  906. 45:52Yeah, that's the that's the purpose of evals.
  907. 45:55Exactly.
  908. 45:56That is you you run these many times ahead of time.
  909. 45:59You're thorough with them.
  910. 46:00Exactly.
  911. 46:00Because because you can't know and then when you skim public traffic, you'll have even more.
  912. 46:05This is exactly the point we're trying to solve.
  913. 46:07Thank you for the question, by the way.
  914. 46:07I love being interrupted.
  915. 46:08That's so cool.
  916. 46:09Uh so look at this.
  917. 46:10Our agreement, three failed, 27 passed.
  918. 46:13Absolutely incredible.
  919. 46:14That's what we want.
  920. 46:15Um, that's exactly it.
  921. 46:16Now, this will still block your CI.
  922. 46:18Why?
  923. 46:19Because it's red and and you want ideally no failing test.
  924. 46:22So, we need to change the test a little bit.
  925. 46:23And I think the best way we can do this is I'm just going to ask Opus.
  926. 46:27I've I've written too much code.
  927. 46:28So, I'm going to say um only fail the test if human AI agreement drops below, I don't know, 80%.
  928. 46:36Right?
  929. 46:36Otherwise, pass.
  930. 46:38And, uh, console log the agreement percentage.
  931. 46:43And now it's going to go off and do its thing.
  932. 46:45Um, but now as you can if this if it does its job, the test will pass if we agree with the judge at least 80% of the time.
  933. 46:51This makes sense.
  934. 46:52And this is how we have an incredible judge.
  935. 46:54What we're going to do then is run this on CI.
  936. 46:56We're going to ship it to production and it's going to be then the quality gate.
  937. 47:00Um, if so, let's revisit that Instagram chatbot, right?
  938. 47:03Um, is the user who they say they are, for example, no matter how much they ask you to change, no matter where they log in from, right?
  939. 47:10Uh, you could you could do that with your email.
  940. 47:12So it it did it I think uh we can just blindly accept it like we always do.
  941. 47:17Um and here we go.
  942. 47:19It passed with 80% exactly fantastic.
  943. 47:21And this is now our quality gate for CI in production.
  944. 47:24Um we would then as I mentioned skim the top get a little bit more data and refine and refine.
  945. 47:30Does this make sense so far?
  946. 47:32Question.
  947. 47:33Say again.
  948. 47:35Do I fail it at 100%?
  949. 47:36No. But I could just change my prompt and do it.
  950. 47:38That's a very good question.
  951. 47:39We should fail it at 100%.
  952. 47:40We should have a lower bound and an upper bound because 100% means you've overfit and and we don't want that.
  953. 47:45So this now becomes your quality gate.
  954. 47:47You can ship that.
  955. 47:48If the model if anything goes wrong your eval set here is going to give you ahead of time reliability.
  956. 47:54It will never really fail and if it fails ideally you have a harness that can pick up the slack at runtime.
  957. 48:00Does this make sense?
  958. 48:01Fantastic.
  959. 48:02Let's move on.
  960. 48:03Uh I'm so happy we did that.
  961. 48:04I'm so happy it worked.
  962. 48:05Thank you for joining me.
  963. 48:05Um, let's uh I want to show you I built a like a more aesthetic demo of this when I had more time here that I want to show you kind of as a
  964. 48:14as a running application.
  965. 48:15So, we'll npm rundev this uh 5173.
  966. 48:19So, this is like the nice version of this, right?
  967. 48:21It's kind of exactly the same thing.
  968. 48:22A customer bought headphones 20 days ago.
  969. 48:24The policy is 14 days.
  970. 48:26Um, this is the right answer.
  971. 48:28We can't accept this.
  972. 48:28This is the wrong answer.
  973. 48:30Um, and now I have a naive I'm going to run this five times with the prompt being that's the question.
  974. 48:36Reply one, reply two.
  975. 48:37Again, it's pair-wise.
  976. 48:38Um, which reply is helpful?
  977. 48:40Run the eval.
  978. 48:41And you'll what you'll see is just an absolute mixed bag.
  979. 48:44The first two times are wrong.
  980. 48:46The third time was wrong.
  981. 48:46Maybe some of these will pass, maybe they won't.
  982. 48:48Um, all of them are wrong, which is wild.
  983. 48:51If we change this to now include the policy in the prompt and we run the eval times, um, it's just suddenly correct, right?
  984. 48:59That's exactly what we discovered with a little bit more aesthetic goodness.
  985. 49:03But I want to show you this in production because we actually believe the thing we build open rag is is purpose-built for LLM judges.
  986. 49:12Um because it it's a massive knowledge base as I talked about.
  987. 49:16Let me show you this.
  988. 49:16It's it's so interesting.
  989. 49:18Uh this is the repo.
  990. 49:20It's on GitHub and we we have a few stars uh here.
  991. 49:24Um, and what it does is it uses Dockling.
  992. 49:28Has anyone heard of Dockling?
  993. 49:30It's a Yeah, awesome, dude.
  994. 49:31It's a research project that we made that is so cool.
  995. 49:34I I genuinely love this because what it does is it takes in any unstructured data, PowerPoints, Excel slides, whatever.
  996. 49:43Excel doesn't do slides, whatever.
  997. 49:44It takes in a bunch of stuff, video, audio, um, eats it, as you can see, uh, and then spits out LLM ready formats.
  998. 49:51Um, it's so cool.
  999. 49:52And the best thing is look at this.
  1000. 49:54The code um is so easy.
  1001. 49:57So you you import a document converter.
  1002. 49:59You can even give it a URL, instantiate it and convert it.
  1003. 50:02And in the end you get something ready for an LLM.
  1004. 50:04And again this is a PDF from a URL.
  1005. 50:06It could be a literal video, right?
  1006. 50:08Um the nice thing about Dockling is it's platform agnostic.
  1007. 50:12So it runs on Apple on your Macs and it it pulls down the right model that works using Apple's Metal architecture.
  1008. 50:19But then if you push this to your CI um and you're running an Ubuntu box in the cloud, it will automatically pull down the right adaption layer.
  1009. 50:25So it's so cool.
  1010. 50:26Um so Dockling will consume the things and make them ready and we store them in what is um open search which is kind of this elastic search thing.
  1011. 50:34So this is what this is what open rag looks like big knowledge base and you select your stuff and it goes over all your policy.
  1012. 50:41So I want to now ask open rag about my headphone return.
  1013. 50:46um sim it's just an API too like you get an API key and you can do it um and in some time it will give you an answer so no relevant supporting sources were found for this request
  1014. 50:58uh we can just add it so if I go upload my policy and again it's usually connected to your Microsoft one drive or whatever it is uh this is my knowledge base I'm going to add a file it's called refund policy
  1015. 51:10um and it's going to be parsed by dockling and stored in open search and index all the embeddings and all this are going to be taken care of.
  1016. 51:18In fact, this is a previous document where you can see it was automatically chunked and embedded.
  1017. 51:22Okay.
  1018. 51:22So now it's part of my open rag data set or my um knowledge base and I don't change anything else.
  1019. 51:29So what this agent's going to do is it's going to ask again according to the refund policy that I literally just now uploaded um there's a 14-day window for refunds and since it's been 20 days you can't.
  1020. 51:38Right?
  1021. 51:39That's uh incredible.
  1022. 51:40And so our judge retrieved the policy and it correctly denied it.
  1023. 51:44Right?
  1024. 51:45This is how you can use rag to provide real-time results um and really train highquality judges for your evals.
  1025. 51:52And then of course you put them in production, you skim real data, etc., etc. As we talked about, let's recap.
  1026. 51:57We've covered a lot of things and uh I've personally had an enormous amount of fun here.
  1027. 52:01Uh I was asked to leave time for Q&A, which I will do, but I appreciate the interruptions as well.
  1028. 52:07Um, but I figure I can also pre- I can warm up the cache while you think uh and I can pre- anticipate some questions and recap what we've discussed today.
  1029. 52:15Question number one, why eval?
  1030. 52:17We talked about it ahead of time reliability uh and disaster or attack mitigation.
  1031. 52:21Number two, what are evals?
  1032. 52:23Right, fuzzy unit tests uh with a little bit more uh and some we we looked at that as well.
  1033. 52:29Um how do we create evals?
  1034. 52:30I think this was the question.
  1035. 52:31I did it using vitest a testr runner uh to have a judge evaluate my thing.
  1036. 52:36I don't think you need more.
  1037. 52:37There's plenty of amazing tooling, many of whom have sponsored this conference and they really do a good job.
  1038. 52:42But what I just built, I can use.
  1039. 52:44In fact, I do use for my products.
  1040. 52:46Um, and it meets the need.
  1041. 52:48But you can create them uh with whatever framework you want.
  1042. 52:51We enforce them on CI with an agreement gate.
  1043. 52:54Um, and how I think we haven't really talked about cost.
  1044. 52:57There's a principle here.
  1045. 52:58Um, you want to go as cheap as possible.
  1046. 53:01Uh and the way you do that is you start with actual deterministic tests, right?
  1047. 53:06Unit tests.
  1048. 53:07If you can't do that, the next level up as we did is kind of regular expressions or pattern matching.
  1049. 53:13If that fails you, the next thing you want to do is examine your traces.
  1050. 53:18Ideally, we're all using some type of observability solution.
  1051. 53:21Um and we have traces of each message envelope, inputs, outputs, tool calls, etc. And you can um validate each object there.
  1052. 53:28Was this tool called this many times?
  1053. 53:30How long did the tool call take?
  1054. 53:31Etc. Right.
  1055. 53:32Um eventually you'll come to a place where you need to use a judge and then you start with the cheapest model.
  1056. 53:37So how do we afford evals?
  1057. 53:38We do it strategically because it's not going to be cheap if you use the most expensive model and you want to kind of build up to it, right?
  1058. 53:44Um what can we expect from evals is just agents that behave uh ahead of time and at runtime.
  1059. 53:52Uh when do we use them?
  1060. 53:54This is a very good question.
  1061. 53:55I think anytime you have non-deterministic data, either inputs or outputs or both, um you need some type of eval.
  1062. 54:02And finally, um I'd love to kind of wrap up with just a just a a final overview of of what we've done here.
  1063. 54:10Um this has been a long talk.
  1064. 54:12I appreciate you for staying.
  1065. 54:14I appreciate uh your your attention.
  1066. 54:16Many of you are like looking at me.
  1067. 54:18It's so cool.
  1068. 54:18You're not on your phones or anything, and I don't take it for granted.
  1069. 54:21Um, I hope from here we're able to genuinely build safer AI and I hope genuinely from this talk uh we don't see any more headlines like the controversy Instagram had and others.
  1070. 54:30Uh, with that I just want to say thank you so much for coming out.
  1071. 54:33I'm happy to continue.
  1072. 54:34Thank you.
  1073. 54:35[applause]
  1074. 54:36I'm happy to take questions if you have any.
  1075. 54:38Sir
  1076. 54:39questions.
  1077. 54:46Yeah,
  1078. 54:48good question.
  1079. 54:48So his question was I'm going to repeat it for the mic.
  1080. 54:50His question was when you're in production, how do you continue to refine your your data set if you have no customer input, right?
  1081. 54:57Just to speed up the process without waiting for customer input.
  1082. 55:00Um there's uh there's a way you do this with a you could do it aically.
  1083. 55:06If you're leaving, leave from that side.
  1084. 55:08I I gave you a mic, brother.
  1085. 55:10Um what you can do is synthetic data.
  1086. 55:13You may have heard of this.
  1087. 55:14Synthetic evals is the term where you have just a bunch of agents uh generate things that a customer would and again this is where rag comes in handy right you would give them a bunch of context you could even give them past data you could give them your static data set and your eval data set if you
  1088. 55:27want to be adversarial and you could be like break it right so that's one way um what we talked about here with eval was also um used by like red teams you may have heard of red teams right um it's just eval
  1089. 55:40where they'll try to create very adversarial prompts that say I'm totally innocent, but how do I murder someone?
  1090. 55:45Like, they'll do prompts like that um to test.
  1091. 55:47And those adversarial prompts, those red team prompts are also just part of an eval data set.
  1092. 55:52And then indeed, you're going to do synthetic data on that, which is here's everything that failed.
  1093. 55:56Now, generate more things that could fail.
  1094. 55:58That's the move.
  1095. 55:58Uh yeah, thank you.
  1096. 56:00Question.
  1097. 56:05Yeah.
  1098. 56:11Mhm.
  1099. 56:17Yeah,
  1100. 56:21yeah,
  1101. 56:25that's a really great question.
  1102. 56:26Thank you.
  1103. 56:26Yeah, his question was uh on the topic of on the topic of where do you build evals?
  1104. 56:31I said usually when you have any system with either nondeterministic inputs or nondeterministic outputs or both, that's where you usually want to have some evals.
  1105. 56:38So then he asked me a lot of people use coding agents cursor cloud codec codeex um and skills with them do I build evals for my skills right um and my answer is no
  1106. 56:48because I think that's the wrong it's not my responsibility because I'm not building the harness so I can refine my answer a little bit to when to build evals you want to build evals when you build a harness I think that's better or you want to build evals when you use a harness and so I'm not writing
  1107. 57:01evals for my skills because I believe Claude code or anthropic has written eval skill poisoning conversation.
  1108. 57:09So you build an eval to give you ahead of time reliability where your harness gives you just in time reliability.
  1109. 57:14And so eval harnesses go hand in hand and I live in userland when I use a coding agent.
  1110. 57:19And so I'm I'm not really in fact skills you can say are deterministic because I write them right and so there's no room for eval there.
  1111. 57:26Good question.
  1112. 57:27Any others?
  1113. 57:28Yes sir.
  1114. 57:32Yes.
  1115. 57:39Yeah.
  1116. 57:47Yeah.
  1117. 57:49Yeah.
  1118. 57:50That's a really good question.
  1119. 57:51Yeah.
  1120. 57:51So, his question was about the the loop in general.
  1121. 57:54Um, where does the policy fit in?
  1122. 57:56Right.
  1123. 57:56Um, do we do we retrieve the policy from production or was that the question?
  1124. 58:06Yes.
  1125. 58:07Right.
  1126. 58:08Yeah.
  1127. 58:08Um I think the production LLM agent and the judge should share the same policy.
  1128. 58:14Right.
  1129. 58:15That's
  1130. 58:16exactly or you don't you don't even copy it over but it lives in some source that you query that with rag or something.
  1131. 58:22Exactly.
  1132. 58:23But the policy must be one to one.
  1133. 58:24That's the whole point right.
  1134. 58:25Um everybody needs to know the policy so they can enforce it.
  1135. 58:28Um and so when ideally so my policy here was hardcoded.
  1136. 58:32it was like written in my file.
  1137. 58:34Um that's that's just for this.
  1138. 58:37Um open rag as I mentioned is has an API where you can say get me all the policy about this over everything we've accumulated over the past hundred years that I have access to.
  1139. 58:45Right?
  1140. 58:45And so the policy is a living thing that is retrieved both by the judge and by the inproduction agent.
  1141. 58:51Does make sense?
  1142. 58:55Yeah,
  1143. 59:00that's a good question.
  1144. 59:01either or.
  1145. 59:02I think personally I would have it be autonomous.
  1146. 59:05Um because my agent in production is an agent with retrieval tools.
  1147. 59:09I want my judge to also be exactly the same as my agent with retrieval tools.
  1148. 59:12The judge and the agent, the closer the judge is to the agent, the more parody you're going to have, right?
  1149. 59:18And so then you get a good signal.
  1150. 59:20When CI fails, then my agent will probably fail.
  1151. 59:23That's the whole point.
  1152. 59:24Exactly.
  1153. 59:24Great question.
  1154. 59:25Uh we have time.
  1155. 59:26We have we have some more time questions.
  1156. 59:28No, we're out of time.
  1157. 59:28Okay.
  1158. 59:29Well, we're out.
  1159. 59:29Thank you again, everybody.
  1160. 59:30This was so much fun.