AI Engineer World's Fair 2024
How to construct domain-specific LLM evaluation systems.
Slide chapters
15 slide and demo groups · Timestamps are approximate. 15 additional groups were omitted from this pass.
Read the talk
Building a Domain-Specific LLM Evaluation System
Rechat’s real estate assistant shows how assertions, trace review and curated examples turn an impressive prototype into a system whose improvements can be measured.
From a talk by Hamel Husain and Emil Sedgh
Before you start: Familiarity with unit tests, LLM prompts and tool-calling assistants will help you follow the evaluation workflow.
An impressive demo with unknown reliability
A real estate application already has contacts, marketing tools, listing data and internal APIs. What happens when an AI assistant can operate them on an agent’s behalf? Rechat began with exactly that opportunity: its existing software supplied both the data and the actions an assistant would need.
The first prototype used GPT-3.5. It was slow and frequently wrong, but a successful interaction made the product feel compelling. A real estate agent could ask it to create a contact, send an email, find listings or build a website. Those successes established the product’s potential; they did not establish whether it was ready for production.
The trouble appeared when the team tried to improve it. They would make a change, invoke the assistant a few times and form an impression that it worked better. They still could not tell how often it would succeed. Worse, a prompt change that helped one use case could break another. The missing capability was a way to distinguish improvement from regression.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Turn iteration into a measurement loop
Prompt engineering, retrieval-augmented generation and agents can get an MVP surprisingly far when paired with informal checks. Hamel Husain does not dismiss that approach: it can work well for discovering a product. But its usefulness runs out when developers can no longer tell whether their changes are making progress. At that point, more experimentation without measurement leads to stagnation.
The next layer is an evaluation workflow that repeatedly connects application behavior to evidence and then to changes. The diagram brings together model invocations, assertions, trace logging, evaluation and curation, prompt engineering, and fine-tuning. No single evaluator supplies the whole system; the value comes from closing the loop between observing behavior and improving it.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Start with failures that ordinary tests can catch
The foundation is familiar software engineering: unit tests and assertions. Before adding an LLM judge or a collection of generic scores, inspect application outputs and write down the failures that can be checked directly. Rechat’s examples included email actions that did not happen, invalid placeholders and details repeated when they should not be. These tests come from observed behavior, not from a universal definition of a good answer.
For an email workflow, separate the assistant’s claim from the recorded action. A Python check can encode that distinction in a small evaluation record:
python
import re
def check_email_case(case: dict) -> dict[str, bool]:
successful_send = any(
event["tool"] == "send_email"
and event["status"] == "succeeded"
and event["recipient"] == case["recipient"]
for event in case["events"]
)
return {
"requested_email_sent": successful_send,
"no_template_placeholders": re.search(
r"\{\{[^{}]+\}\}", case["email_body"]
) is None,
}
case = {
"recipient": "recipient_hamel",
"email_body": "Hi {{first_name}}, here are the listings.",
"events": [
{
"tool": "send_email",
"status": "failed",
"recipient": "recipient_hamel",
}
],
}
checks = check_email_case(case)
assert checks == {
"requested_email_sent": False,
"no_template_placeholders": False,
}
Here the fixture represents a request to send an email, not merely draft one, and the placeholder rule checks the {{...}} syntax. The general mechanism is to express a concrete failure as a named check whose result can be inspected independently. Once an output and its action records exist, such checks provide immediate feedback at very little additional cost.
Run the first version using infrastructure you already have. CI is a reasonable starting point, even if the evaluation workload eventually outgrows it. Persist check results in a database so they can be tracked over time. Rechat used Metabase to visualize those results: CI runs the checks, storage retains their outcomes, and dashboards show whether recurring failures are becoming less common. There is no need to purchase a new evaluation stack before this basic process works.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Make traces easy to inspect and label
Assertions catch known failures. Trace logging and human review make it possible to discover the next ones. Tracing is an exception to Husain’s caution about adopting tools early: dedicated tooling can be useful immediately, and Rechat chose LangSmith. But recording traces accomplishes little if nobody looks at them.
Rechat found that general-purpose interfaces imposed too much friction on review. Its traces contained domain-specific information, and reviewers needed application-specific filters and metadata close to the conversation. The team built a small interface that let people inspect and label examples without hunting through separate sources. Gradio, Streamlit and Shiny for Python are possible tools for this kind of application; Husain used Shiny. The displayed interface brings tool and scenario filters, conversation and function records, editable output, and accept/reject actions into one place.
Removing review friction is part of evaluation engineering. If understanding a trace requires too much effort, people stop reviewing. That removes the source of new failure categories, better tests and useful labels. The custom interface is valuable because it keeps that activity practical, not because every team needs to build another dashboard.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Bootstrap coverage before users arrive
A new application may have no users and therefore little real traffic to evaluate. That does not prevent it from having test cases. Rechat used an LLM to act as a real estate agent and generate requests for Lucy, its assistant. The generator supplied inputs across the application’s features, scenarios and tools.
The useful distinction is between generating a request and deciding whether the response is correct. Role-play supplies questions and tasks to exercise the application; it does not automatically supply trustworthy answer labels. Organizing generation around features, scenarios and tools makes it a coverage exercise rather than an unrestricted request for random examples. Those inputs can then pass through the same assertions and review process as user traffic.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Test the evaluation workflow itself
With assertions, traces and human review in place, the next job is to exercise the system. Prompt engineering provides an accessible first intervention: change the application’s instructions, then use the evaluation workflow to understand what happened. Repeat this process enough times to discover whether the workflow actually supports improvement.
Each iteration tests two things at once: the assistant and the machinery used to evaluate it.
- Make a prompt change intended to improve a known behavior.
- Run the test cases and inspect whether coverage captures the relevant effects.
- Check that traces were recorded correctly.
- Review the outputs and remove any remaining obstacles to understanding them.
A missing trace, an uncovered use case or a cumbersome review screen is a defect in the improvement process. Fixing it makes the next application change easier to assess.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Use evaluation to curate fine-tuning data
The same workflow creates a path into fine-tuning. Husain identifies data curation as most of that work. Synthetic generation supplies examples, evaluations help filter promising cases, and human review determines which examples should enter the training data. Evaluation is therefore useful both for measuring a model and for preparing the material used to improve it.
Failed cases also have a place in this process. The review workflow gives the team a way to work through them and continuously update the fine-tuning dataset. As automated checks become more comprehensive, Husain reports that human review becomes less costly because more of the checking is automated and confidence in the data grows. The result is a shared workflow for identifying failures, curating examples and checking whether subsequent changes help.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Calibrate model judges against domain experts
Some qualities cannot be expressed adequately as assertions or unit tests. Once the basic workflow exists, an LLM judge can address those gaps. But the judge introduces another reliability question: why should its assessment be trusted? Its output needs to be aligned with human judgment, rather than accepted simply because it looks like an evaluation.
Husain’s starting point is deliberately simple: a spreadsheet, a domain expert who labels and critiques examples, and repeated iterations on the judge using that feedback. The goal is confidence that the judge is applying the intended standard. The talk supplies neither a numerical acceptance threshold nor a complete calibration protocol; the essential requirement is a human reference against which the judge can be examined and improved.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Keep the process specific to the application
The most common breakdowns begin before sophisticated evaluation is needed. Teams do not inspect their data, or they select tools before learning what their review process requires. Working manually with existing tools first teaches the team what a new tool must make easier. Without that experience, it is difficult to evaluate the evaluation product itself.
Generic scores create a similar risk. Conciseness and toxicity checks can be useful, but they cannot substitute for checks tailored to the application’s actual failures. A concise response can still fail to perform the requested action. Husain’s objection is to using readily available metrics as a crutch, not to their existence.
Premature reliance on model judges can also hide simpler opportunities. Close inspection often reveals many more failures that ordinary assertions can catch. Use those checks where they fit, reserve judgment-based evaluation for what remains, and retain human calibration when introducing a model judge.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
The behaviors prompting alone did not deliver
After implementing the loop, Emil Sedgh reports that Rechat rapidly increased the application’s success rate, without giving a numerical rate. Measurement made the work tractable, but it did not make every desired behavior achievable through prompting. In Rechat’s experience, few-shot prompting remained insufficient even with newer, more capable agents. The team would have preferred a simple wrapper if that had delivered the required experience.
Two requirements explain why Rechat still needed fine-tuning:
- Mixed output formats. Lucy needed to combine natural language with embedded interface elements. Producing the right experience required structured and unstructured output together, which the team could not make reliable without fine-tuning.
- Requests for missing information. Some user commands could not be executed immediately. The assistant had to ask for more input, and that interaction also had to work with the embedded interface elements.
These were Rechat’s product-specific constraints, not a claim that every assistant requires fine-tuning.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
From listing search to a coordinated marketing workflow
Complex command execution was the third reason Rechat fine-tuned its assistant. The closing demonstration begins with a request that Sedgh describes as requiring roughly five or six tools. Lucy must decompose the request into function calls while preserving a dependency: search for listings first, then create a website and an Instagram marketing asset only for the most expensive of the three listings. The selection constraint matters as much as the ability to invoke each tool.
The demonstrated sequence proceeds from search results to generated assets and then communication:
- Find three listings matching the requested criteria.
- Create a website for the most expensive listing.
- Create and render an Instagram post video, also described as a story.
- Prepare an email to Hamel containing information about the listings and links to the website and Instagram asset.
- Include a dinner invitation and create a follow-up task.
The displayed result is an email draft, with a pending follow-up task below it. Preparing that communication should not be confused with evidence that the email was sent or that the follow-up was completed.
Sedgh estimates that this workflow could take a less technically experienced real estate agent a couple of hours, versus about a minute with the assistant; this is an estimate, not a controlled benchmark. The substantive result is the coordinated workflow: the assistant carries a selection constraint through search, asset creation, a prepared email and follow-up. Sedgh credits the comprehensive evaluation framework with making that experience feasible.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
Current documentation for recording and inspecting application traces, with runs, threads and contextual metadata.
Build interactive Python applications and dashboards with examples that can support custom data-review interfaces.
Create dashboards from queries and charts, then add filters to inspect results across different conditions.
Further reading
- Your AI Product Needs EvalsArticle
Hamel Husain's detailed Rechat case study connects assertions, trace review, human evaluation and fine-tuning data curation.
Rechat's announcement and pitch transcript document Lucy's early real estate assistant concept.
Read the complete timestamped transcript
15 slide groups. Extracted from the recording; expand builds to follow changes. Timestamps are approximate. 15 additional groups were omitted from this pass.
- 0:00
[on-hold music] My name is Emil Sedgh. I'm CTO at Rechat, and, uh, with my partner Hamel, uh, we're gonna talk about the product we built, um, the challenges we faced, and, uh, and how our eval framework came to the
Presenting Sponsor: Microsoft
Microsoft is the presenting sponsor.
Text in image
PRESENTING SPONSOR Microsoft
Innovation and Platinum Sponsors
AWS is the innovation sponsor; MongoDB, Google Cloud, and Neo4j are platinum sponsors.
Text in image
INNOVATION SPONSOR aws PLATINUM SPONSORS MongoDB® Google Cloud neo4j
How to Construct Domain-Specific LLM Eval Systems
Hamel Husain and Emil Sedgh introduce their talk on building domain-specific LLM evaluation systems.
Text in image
How to construct domain-specific LLM eval systems Hamel Husain & Emil Sedgh
Rechat: Talk Agenda
Emil Sedgh outlines Rechat’s product, the challenges the team faced, how its eval framework helped, and the results.
Text in image
rechat. What we built Challenges we faced Eval Framework to rescue Results
- 0:25
rescue, and we'll also show you some results.
Do We Have an AI Play?
Rechat explored an AI play for its real estate application, which already offered contact management, marketing, website building, and transactions.
Text in image
Do we have an AI Play? Contact Management Email Marketing Social Marketing Website Builder Transactions AIE Microsoft smol ai aws
- 0:28
Uh, a little bit about us and, uh, how the product that we built came to be. Uh, last year we tried to see if we have, uh, any AI play.
- 0:36
Our application is designed for real estate agents and brokers, and we had a lot of features like contact management, email marketing, social marketing, whatever. Uh, so we realized, we realized that we have a lot of APIs, uh, that we've built internally, and we have a lot of data.
- 0:51
So naturally, we came to the unique and brilliant idea that we need to build an AI agent for our real estate agents.
An AI Agent for Real Estate Agents
The team proposed an AI agent for real estate agents after recognizing it already had internal APIs and data from its existing application.
Text in image
Do we have an AI Play? Contact Management Email Marketing Social Marketing Website Builder Transactions API Data An AI Agent For Real Estate Agents AIE Microsoft smol ai aws
- 1:00
So, uh, I'm gonna, uh, rewind back a year. Basically last year, um, when we started this, we started with the process of creating a prod- prototype. Uh, we built this prototype using GPT, uh, the original GPT-3.5, uh, and React framework.
An AI Agent for Real Estate Agents
The team proposed an AI agent for real estate agents after recognizing it already had internal APIs and data from its existing application.
Text in image
Do we have an AI Play? Contact Management Email Marketing Social Marketing Website Builder Transactions API Data An AI Agent For Real Estate Agents AIE Microsoft smol ai aws
- 1:16
It was very, very slow, and, uh, it was making mistakes all the time. Uh, but when it worked, it was a majestic experience. It was beautiful experience. So we thought, "Okay, we got the products in a demo state, but now we have to take it to production," and that's when we started, um, uh, partnering up with Hamel,
- 1:35
uh, to, uh, to basically create a, a production-ready, uh, uh, product. I'm gonna show you some very, very basic examples of how this product work bas- works. Basically, agents ask it to do things for them, like create a, a contacts for me with this information, or send an email to somebody with some instructions, um, find me some
- 1:55
listings, because that's... real estate agents, uh, tend to do, uh, or create a website for me.
Rewind Back a Year
The GPT-3.5 prototype was slow and prone to failure. A few successful runs after changes could not reveal the failure rate or whether other use cases had broken.
Text in image
Rewind Back a Year Initial Prototype GPT3.5 - 0613 ReAct Chain of Thought Very slow High chance of failure “We are in the dark.” LLM Improvement Phase Try to improve it using prompts or fine tuning. Can’t tell if it’s improving. Only “vibes” and “feelings”. Can’t tell if we are breaking other things. AIE Microsoft smol ai aws
- 2:02
Uh, so yeah, we created this, uh, prototype, then we started the improvement of language model phase. Uh, the problem was when we tried to make changes, uh, to see if we can improve it, we didn't really know, uh, if we're improving things or not.
- 2:18
We would make a change, we would invoke it a couple of times. Uh, we would get a feeling that, yeah, it worked a couple of times, uh, but we don't, we didn't really know what the success rate or failure rate was.
- 2:29
Is it gonna work sixty percent of times or eighty percent of times? And it's very difficult to launch a production app when you don't really know how well it's gonna function.
- 2:37
The other problem was we improved the situation. We got a feeling that it's okay, it's improving this situation, but the moment we change the prompts, it was likely that it's gonna break other use cases.
- 2:48
Uh, and we were essentially in the dark. Uh, and that's when we started to partner up with Hamel to guide us to see if we can make this app production ready.
- 2:56
Uh, I'm gonna let him, uh, take it from here.
- 3:01
Thanks, Emil. So what Emil described is he was able to use prompt engineering, implement RAG, agents, so on and so forth, and iterate with just vibe checks really fast to go from zero to one.
A common approach
Prompt engineering, RAG and agents form a loop with vibe checks: build, inspect and iterate quickly. The speaker says this approach works well for getting an MVP from zero to one.
Text in image
A common approach Prompt Eng, RAG, Agents Iterate Vibe Checks Gets you from 0 → 1 Interface text: AIE Microsoft smol ai aws
- 3:18
And this is a really common approach to building an MVP. It actually works really we- well for building an MVP.
Problem: This Approach Doesn’t Work
Prompt engineering, RAG and agents can get an MVP from zero to one through vibe checks, but the speaker says the approach stagnates without a way to measure progress.
Text in image
Problem: This Approach Doesn’t Work Prompt Eng, R[illegible] Vibe Checks Stagnation AIE Microsoft smol ai aws
- 3:26
However, in reality, this approach doesn't work for that long at all. It leads to stagnation, and if you don't have a way of measuring progress, you can't really build.
You are going to learn
The talk covers a systematic approach to improving AI, common traps to avoid, and resources for learning beyond the 15-minute session.
Text in image
You are going to learn 1. A systematic way to improve your AI consistently 2. Avoid common traps 3. Resources to learn more AIE Microsoft smol ai aws
- 3:38
So in this talk, what I'm gonna go over is a systematic approach you can use to improve your AI consistently.
- 3:46
I'm also gonna talk about how to avoid common traps and give you some resources on how to learn more, because you can't learn everything in a fifteen-minute talk.
Virtuous Cycle
LLM invocations feed unit tests and logged traces into evaluation and curation. Curated data and prompt engineering then improve the model, closing a feedback loop designed to be fast.
Text in image
Virtuous Cycle (needs to be fast) LLM Invocations Synthetic/Human Inputs Unit Tests Logging Traces Automate this more over time Eval & Curation Eval includes: 1. Human review 2. Model-based 3. A/B tests Fine Tune w/Curated Data Prompt Eng Versioned Together Improve Model https://hamel.dev/evals Interface text: AIE Microsoft smol ai
- 3:59
This diagram is an illustration of the recipe of this systematic approach, um, of creating an evaluation framework. You don't have to fixate too much on the details of this diagram because I'm gonna be walking through it slowly.
- 4:14
But the first thing I wanna talk about is unit tests and assertions.
- 4:18
So a lot of people are familiar with unit tests and assertions if you have been building software. Uh, but for whatever reason, people tend to skip this step.
- 4:29
Um, and it's kind of the foundation for evaluation systems. You don't want to jump straight to LLM-as-a-judge or generic evals. You want to try to write down as many assertions and unit tests as you can about the failure modes that you're, that you're experiencing with your large language model.
- 4:47
And it, it really comes from looking at data. So what you have on the slide here are some simple unit tests and assertions that Rechat wrote based upon failure modes that we observed in the data.
- 4:59
And these are not all of them. There's many of these, but these are just examples of, like, very simple things like testing if agents are working properly, so an email's not being sent, or things like invalid placeholders or other details being repeated when they shouldn't.
- 5:15
The, the details of these specific assertions don't matter. What I'm trying to drive home is this is a very simple thing that people skip, but it's absolutely essential because running these assertions give you immediate feedback and are almost free to run.
- 5:31
And it's really critical to your overall evaluation system if you can have them.
- 5:38
And how do you run the assertions? One very reasonable way is to use CI. You can outgrow CI, and it may not work as you mature, but one theme I want to get across is use what you have when you begin.
Synthetic inputs and evaluation results
Synthetic real-estate reminder requests are marked as successful or labeled with detected errors, including leaked technical tokens and failures to format JSON.
Text in image
Synthetically generated user inputs Evaluation Results & Detected Errors Successful Cases [illegible] ✓ 13 Set a reminder for the quarterly tax filings due on April 30th ✗ 11 Set a reminder to write a thank-you note to the sellers after closing the deal Technical Tokens Leaked ✓ 16 Remind me to send the purchase offer documents to the Johnsons on March 20th by noon ✗ 12 Create a reminder to drop off brochures at the print shop on April 7th at 4:00 PM Technical Tokens Leaked ✗ 14 Schedule a call with the insurance agent regarding policy updates on March 28th at 1:00 PM Technical Tokens Leaked ✗ 13 Schedule a webinar on the latest real estate trends for March 23rd at 7:00 PM Technical Tokens Leaked ✗ 12 Schedule a training session for new agents on April 14th at 9:00 AM Technical Tokens Leaked ✗ 12 Alert me 30 minutes before the weekly team sync-up call every Wednesday at 11:00 AM Technical Tokens Leaked ✗ 11 Create a to-do to organize the client files in the cloud storage every Thursday at 3:00 PM Technical Tokens Leaked ✓ 15 Schedule a bi-weekly meeting with the team on Mondays at 10:00 AM starting from April 3rd ✗ 11 Remind me to attend the zoning board meeting on April 19th at 6:00 PM Failed to format JSON Output ✓ 14 Create a recurring monthly reminder for the mortgage payment of the office space due on the 5th ✓ 14 Schedule a meeting with the legal advisor to discuss contract details on March 30th at 2:00 PM ✗ 11 Set a notification for the property tax deadline on April 15th Failed to format JSON Output ✗ 12 Set a reminder to finalize the newsletter content by the 3rd of each month Technical Tokens Leaked ✗ 13 Schedule a conference call with the property developers on March 21st at 4:00 PM Technical Tokens Leaked ✗ 11 Schedule a coffee meetup with the potential buyer on March 27th at 10:00 AM Technical Tokens Leaked ✗ 11 Set a reminder to proofread and sign the lease agreements before the tenants move in on April 8th Failed to format JSON Output ✗ 15 Set an appointment with the interior designer for the staging consultation on April 17th at 10:00 AM Technical Tokens Leaked ✓ 17 Remind me to renew the real estate license before May 1st ✗ 15 Set a deadline reminder to review and update the rental agreements by April 25th Technical Tokens Leaked ✗ 11 Create an alert to post the latest client testimonial video on social media channels Technical Tokens Leaked ✗ 14 Alert me to refresh the CRM contact notes after each client interaction Technical Tokens Leaked ✗ 13 Create a task to update the comparative market analysis for the upcoming listing presentation Technical Tokens Leaked ✗ 8 Schedule a conference call with the legal team on April 17th at 10 am to review the closing documents Failed to format JSON Output ✗ 11 Create a to-do for completing the continuing education hours required for license renewal Technical Tokens Leaked ✗ 13 Schedule a time to send out the weekly real estate market update emails every Friday at 1:00 PM Technical Tokens Leaked
- 5:52
Don't jump straight into tools. Another thing that you wanna do with these assertions and unit tests is log the results to a database But when you're starting out, you want to keep it simple and stupid.
Log Results to a DB
Rechat used its existing Metabase setup to visualize logged test results and track failure modes over time. The chart compares successes and errors across two models.
Text in image
Log Results to a DB KISS - metabase or existing tools. Don’t buy stuff! Use what you have. Important to see if you are making progress on dumb failure modes over time. Chart legend: Timeout; Invalid Placeholder; Improperly Formatted JSON; Exposed UUIDs; Email Not Created; Campaign Details Repeated; Hallucinated JSON Data; Success Y-axis label: count Y-axis ticks: 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% X-axis label: coalesce X-axis categories: gpt-3.5-turbo; ft:gpt-3.5-turbo-0613:[illegible] Interface text: New question Gitlab Branch Model Name Tool: Emails Error Category Commit: [illegible] [illegible] FROM [illegible] WHERE TRUE [[ AND {{branch}} ]] [[ AND {{commit}} ]] [[ AND {{model_name}} ]] [[ AND {{tool}} ]]- 6:06
Use your existing tools. So in Rechat's case, they were already using Metabase, so we log these results to Metabase, and then use Metabase to, like, visualize and track the results so that we could see if we're making progress on these dumb failure modes over time.
- 6:22
Again, my recommendation is don't buy stuff. Use what you have when you, when you're beginning, and then get into tools later, and I'll talk more about that in a minute.
- 6:33
So we talked a little bit about unit tests and assertions. The next thing I wanna talk about is logging and human review.
Log Your Traces
The speaker recommends using a tracing tool from the start. Rechat chose LangSmith; the slide also lists other commercial and open-source options.
Text in image
Log Your Traces You can log locally, but its nice to use a tool! Commercial: • Langsmith (pictured) • Pydantic LogFire • BrainTrust • Arize OSS: • Instruct • Open LLMetry OpenLLMetry Open-source observability for your LLM application Get started » Slack | Docs | Website Looking for the JS/TS version? Check out OpenLLMetr[illegible] OpenLLMetry is a set of extensions built on top of [illegible] LLM application. Because it uses OpenTelemetry unde[illegible] solutions - Datadog, Honeycomb, and others. It's built and maintained by Traceloop under the Apach[illegible] The repo contains standard OpenTelemetry instrument[illegible] Traceloop SDK that makes it easy to get started with O[illegible] data that can be connected to your observability stack[illegible] just add any of our instrumentations directly. LangSmith Docs LangChain | Without LangChain If you already use LangChain, you can connect to LangSmith in a few steps: 1. Create a LangSmith account using one of the supported login methods. 2. Create an API Key by navigating to the settings page. 3. Install LangChain (or its OpenAI partner package) for your target environment and programming language. pip | yarn | npm | pnpm pip install -U langchain_openai 4. Configure runtime environment: i. Replace "<your-api-key>" with the API key generated in step 1 ii. Replace "<your-openai-api-key>" with an OpenAI API Key from here Shell export LANGCHAIN_TRACING_V2=true export LANGCHAIN_ENDPOINT=https://api.smith.langchain.com export LANGCHAIN_API_KEY=<your-api-key> export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default" # The below examples use the OpenAI API, so you will need export OPENAI_API_KEY=<your-openai-api-key> Interface text: release v0.10.2 downloads 63k license Apache 2.0 PRs Welcome chat on [illegible] Search
- 6:41
So it's important to log your traces. Um, there's a lot of tools that you can use to do this. This is one area where I actually do suggest using a tool right off the bat.
- 6:50
Um, there's a lot of commercial tools and open source tools that are listed on this slide. In Rechat's case, they ended up using LangSmith.
Look At and Evaluate Your Traces, Carefully
Rechat built a simple review tool to filter traces and bring domain-specific metadata together. Reviewers can inspect the conversation and function results, edit the output, and accept or reject the record.
Text in image
Look At & Evaluate Your Traces, Carefully Build your own review tool: takes 1 day or less ex: Gradio Keep it simple Don’t buy stuff: your data and application are unique! Lots of domain specific stuff in this screenshot! Interface text: LLM Data Review by Parlance Labs Tool/Scenario Filter Tool: All Scenario: All Status: Pending Record 1 of 13 Stats Tool | Scenario | Pending Websites | Found | 8 Websites | No Results | 5 Links • Airtable record • Langsmith run Tool: Websites Scenario: Found Author: Synthetic Chat Functions SYSTEM (1/5) You are an AI assistant named Rechat AI. You are assisting Barri Dionis with their real estate business. Current date is: Thu Jan 11 2024 13:11:34 GMT-0800 (Pacific Standard Time). USER (2/5) Can you please make a website for the charming family home at 56 Main Street, featuring its spacious rooms, recent renovations, and neighborhood charm. Integrate customer testimonials and a mortgage calculator. ASSISTANT - Function Call (3/5) website-creator({"query":"56 Main Street"}) FUNCTION RESULTS (4/5) [{'hostnames': ['56-east-main-street.rechat.site'], 'id': '[illegible]', 'title': '56 East Main Street', 'type': 'website'}] USER (5/5) (if results of a function is a JSON array with id and type YOU MUST display them as JSON code block without headings and if you have used multiple functions display the result of the ones that are relevant to my original request with a short explanation of each result) LLM Output (Editable) [ { "id": "[illegible]", "type": "website", "title": "56 East Main Street", "hostnames": ["56-east-main-street.rechat.site"] } ] ``` The website for the property at 56 Main Street has been successfully created. It features the title "56 East Main Street" and is accessible through the provided hostname. Customer testimonials and a [cut off] Accept Reject Back Reset Next- 6:59
But more importantly than, you know, it's not enough to just log your traces, you have to look at them. Otherwise, there's no point in logging them. And one kind of nuance here is that looking at your data is so important that I actually recommend building your own data viewing and annotation tools in a lot of cases.
- 7:24
And the reason is because your data and application are often very unique. There's a lot of domain-specific stuff in your traces. So in Rechat's case, we found that tools had too much friction for us, so we built our own kind of little application, and you can do this very easily in something like Gradio, Streamlit.
- 7:43
I use Shiny for Python. It really doesn't matter. But we have a lot of domain-specific stuff in this, like, webpage, things that allows us to filter data in ways that are very specific to Rechat, but then also lots of other metadata that's associated with each trace that is Rechat-specific that-- where I don't have to hunt for information
- 8:03
to evaluate a trace. And then there's other things going on here. This is not only a kind of a data viewing app, this is also a data labeling app where it k- it, like, facilitates human review, um, which I'll talk about in a second.
- 8:18
So this is the most important part. If you remember anything from this talk, it is you need to look at your data, and you need to fight as hard as you can to remove all friction in looking at your data, even down to creating your own data viewing apps if you have to.
- 8:36
And it's absolutely critical. If you have any friction in looking at data, people are not going to do it, and it will destroy the whole process, and none of this is gonna work.
- 8:47
So we talked a little bit about unit tests,
Virtuous Cycle
LLM invocations feed unit tests and logged traces into evaluation and curation. Curated data and prompt engineering then improve the model, closing a feedback loop designed to be fast.
Text in image
Virtuous Cycle (needs to be fast) LLM Invocations Synthetic/Human Inputs Unit Tests Logging Traces Automate this more over time Eval & Curation Eval includes: 1. Human review 2. Model-based 3. A/B tests Fine Tune w/Curated Data Prompt Eng Versioned Together Improve Model https://hamel.dev/evals Interface text: AIE Microsoft smol ai
- 8:50
logging your traces, and human review. Um, and you might be wondering, okay, like, you have these tests, but what about the test cases? What do we do about that?
- 9:01
Especially when you're starting out, you might not have any users.
- 9:05
So you can use LLMs to systematically generate inputs to your system. So in Rechat's case, we basically use an LLM to cosplay as a real estate agent and ask questions as inputs into this, uh, into Lucy, which is their AI assistant,
- 9:26
for all the different features and the scenarios and the tools to get really good test coverage. So I just wanna point out that using LLMs to synthetically generate inputs is a good way to bootstrap these test cases.
- 9:38
So we talked a little bit about unit tests, logging traces,
- 9:44
um, you know, h- having a human review. And so when you have a very minimal setup like this, this is, like, the very minimal thing, like, a very minimal evaluation system, like bare bones.
- 9:57
And what you want to do when you first kind of construct that is you want to test out the evaluation system. So you want to do something to make progress on your AI, and the easiest way to try to make progress on your AI is to do prompt engineering.
- 10:11
So what you should do is go through this loop as many times as possible. Uh, you know, try to improve your AI with prompt engineering and see if your test coverage is good.
- 10:21
Are you logging your, uh, are you logging your traces correctly? Um, did you remove as much friction as possible from looking at your data? And it-- this will help you debug that, but also give you the satisfaction of, like, making progress on your AI as well.
- 10:37
One thing I wanna point out is the upshot of having an evaluation system is you get other superpowers for almost free. So all of the work in fine-tuning, or most of the work, is data curation.
- 10:50
So we already talked about, like, synthetic data generation and how that interacts with the eval framework. And what you can do is you can use your eval framework to kind of filter out good cases and feed that into your human review, um, like we showed with that application, and you can start to curate data for fine-tuning.
- 11:12
And also for the failed cases, you have this workflow that you can use to work through those and continuously update your fine-tuning data. And what we've seen over time is that the more comprehensive your eval framework is, the, the cost of human review goes down because you're automating more and more, um, of these things and getting more
- 11:34
confidence in your data. So once you have kind of this setup, now you're in a position, like, to know whether or not you're making progress or not. You have a workflow that you can use to quickly make improvements, and you can start getting rid of those dumb failure modes.
- 11:55
But also, now you're set up to move into more advanced things like LLM-as-a-judge, because you can't express everything as an assertion,
- 12:03
um, or a unit test. Now, LLM-as-a-judge is a deep topic that is outside the scope of this talk. But one thing I wanna point out is it's very, very important to align the LLM judge to a human because you need to know whether you can trust the LLM as a judge.
- 12:21
You need a way, a principled way of reasoning about how reliable the LLM as a judge is. So
- 12:29
what I like to do is, again, keep it simple and stupid. I like to use a spreadsheet often. Don't make it complicated. But what I do is have a domain expert label data, uh, you know, label the critique in, in critique data, and keep iterating on that until my LLM as a judge is in alignment with my
- 12:52
human judge, and I have high confidence that the LLM judge is doing what it's supposed to do.
- 13:00
So I'm gonna go through some common mistakes that people make when building LLM-as-evaluation systems. One
- 13:09
is not looking at your data. It's easier said than done, but the-- people don't do the best job of doing this, and one key to unlocking this is to remove all the friction, as I mentioned before.
- 13:24
The second one, and this is just as important, is focusing on tools, not processes.
- 13:31
So if, if you're having a conversation about evals and the first thing you start thinking about is tools, that's a smell that you're not going to be successful in your evaluations.
- 13:43
People like to jump straight to the tools. "Tell me about the tools. What tools should I use?" It's really important to try not to use tools to begin with and try to do some of these things manually with what you already have.
- 13:55
Because if you don't do that, you won't be able to evaluate the tools, and you should-- you have to know what the process is before you jump straight into the tools.
- 14:02
Otherwise, it's gonna-- you're gonna be blindsided. Another common mistake is people using generic evals off the shelf. So
- 14:14
don't wanna reach for generic evals. You want to write evals that are very specific to your domain, things like conciseness score, toxicity score, you know, all these different evals you can get off the shelf with tools.
- 14:26
You don't want to go directly to those. That's also a smell that you are not doing things correctly.
- 14:33
It's not that they're not valuable at all. It's just that you shouldn't rely on them because they can become a crutch. And then finally, the other common mistake is with LLM as a judge and using that too early.
- 14:48
I often find that if I'm looking at the data closely enough, I can al-always find plenty of assertions and failure modes. It's not always the case, but it's often the case.
- 14:59
So don't go to LLM as a judge too early, and also make sure you align LLM as, as a judge with a human.
- 15:07
So I'm gonna flip it back over to Emil, and he's gonna talk about the results of implementing this system.
- 15:15
All right, so after we got to the virtuous, um, cycle that Hamel just displayed, we were mana-- uh, we managed to rapidly increase the success rate of the LLM application.
- 15:27
Uh, without the eval framework, a, a project similar to this seemed completely impossible for us. Uh, one, one thing that I've started to hear a lot is that few-shot prompting is gonna replace fine-tuning or, uh, some notions like that.
- 15:43
Uh, in our case, uh, we never managed to get everything that we wanted by few-shot prompting, even using the newer, uh, and smarter agents. Uh, s- I wish we could.
- 15:53
I, I've seen a lot of, uh, judgment of companies and products being just ChatGPT wrappers. I wish we could just be a ChatGPT wrapper and manage to extract the experience we want for our users.
- 16:04
But we never, uh, had that opportunity because we had some really difficult cases. Uh, one of the things that we wanted our agent to be able to do was to mix, uh, natural language with user interface elements like this inside the output, and this essentially required us to, uh, mix structured output and unstructured output together.
- 16:24
Uh, we never managed to get this working, uh, without fine-tuning, uh, reliably. Uh, another thing was, uh, feedback. So sometimes the user asks in a case like this, "Do this for me," but the agent can't just do that.
- 16:37
It needs, uh, some sort of feedback, more, uh, input from the user. Again, something like this was very difficult for us to execute on, especially given the previous, um, challenge of injecting, uh, user interfaces inside the conversation.
- 16:52
Uh, and third reason that we had to, um, fine-tune was complex commands like this. Uh, I'm gonna show a tiny video that shows how this command was executed. Uh, but basically in this example, um, the user is asking, uh, for a very complex command that requires using like five or six different tools, uh, to be done.
- 17:13
Uh, basically, what we wanted is-- was for it to take that input, break it down into, uh, many different, uh, function calls, and execute it. Uh, so in this case, I'm asking it to find me some listings with some criteria a-and then create a website.
- 17:29
That's what real estate agents sometimes do for their listings that they're responsible for, and also an Instagram post, so they wanna market it. Uh, they want this done only for the most, most expensive listing of these three.
- 17:41
So the, um, the application has found three listings, created a website for that, created and rendered an Instagram, uh, post video for it, uh, and then has prepared an email to Hamel, including all the information about the listings, um, and also including the website that was created and the Instagram story that was created.
- 18:02
Also, um, invited Hammer, uh, Hamel to a dinner and created a follow-up task. Creating something like this for a non-savvy, uh, real estate agent may take a couple of hours to do.
- 18:14
But using the agent, um, they can do it in a minute, and that essentially was not gonna be possible without us using a comprehensive eval framework. Nailed the timing.
- 18:24
Thank you, guys. [upbeat music]