Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 56

Crafting Custom Evaluation Datasets

Recommended resources

Introduction

In our last lesson, we critically dismantled the idea that standard academic benchmarks are a silver bullet for LLM evaluation. You learned that high scores can often be an illusion, masking fragility, a lack of real-world relevance, and overfitting due to Goodhart's Law. This naturally leads to a crucial question for any serious practitioner: "If benchmarks are flawed, how do I reliably measure and improve my application?"

Today, we answer that question. We move from critique to construction. This lesson will equip you to tackle the learning outcome: Design and curate custom evaluation datasets tailored to a specific business use case or domain. Instead of relying on a generic yardstick, you will learn to build your own, perfectly suited to measure what truly matters for your project's success. This is a foundational skill that separates developers who build demos from engineers who ship robust, production-grade AI systems.


1. The Mindset: A Cycle of Continuous Improvement

Before diving into specific techniques, it's essential to adopt the right mindset. Building a custom evaluation set isn't a one-time task; it's the core of an iterative loop for improving your AI system. Your experience in production ML has likely exposed you to similar cycles of continuous integration and deployment; this is the AI equivalent.

A powerful mental model for this is the Analyze, Measure, Improve lifecycle.

How to Systematically Setup LLM Evals (Metrics, Unit Tests, LLM-as-a-Judge)

This video provides an excellent overview of the iterative process that underpins effective LLM evaluation. It introduces the 'Analyze, Measure, Improve' cycle which we will use to structure our thinking.

Watch the segment from 10:04 to 12:36. Focus on understanding the three stages: Analyze: Collect examples and categorize failure modes. Where is your system breaking? Measure: Translate these qualitative insights into quantitative metrics. How can you score the failures and successes? Improve: Use the measurements to guide refinements to your prompts, architecture, or model.

This loop is the engine of progress. Your custom evaluation dataset is the fuel for the "Measure" stage and the compass for the "Improve" stage. Without it, you're flying blind.


2. Designing Your Dataset: What to Measure and How

A dataset is only as good as its design. Before you start collecting data, you must first define what "good" looks like for your specific application.

Step 1: Define Success with Domain Experts

The first step isn't writing code; it's talking to people. For any real-world application, you need to collaborate with domain experts to understand the nuances of the task.

How to Build LLM Evaluation Datasets for Your Domain- ...

The article 'How to Build LLM Evaluation Datasets' from Kili Technology provides a great, practical example of why this is so important. We'll use their banking chatbot scenario to ground our thinking.

Read the subsection 'Understanding Domain Requirements'. Notice how building a seemingly simple QA chatbot for banking requires input from financial experts (for terminology and regulations), customer support teams (for common queries and user expectations), and cybersecurity experts (for vulnerabilities).

This initial collaboration helps you define the evaluation criteria. For a RAG system, for instance, these criteria might include:

RAG-LLM Evaluation Criteria
This diagram highlights key criteria for evaluating a RAG system: **Relevance** (is the retrieved context useful?), **Factuality** (is the answer correct based on the context?), and **Completeness** (does the answer address the whole question?). Your custom dataset should be designed to test these dimensions.

Step 2: Establish the "Ground Truth"

Once you know what to measure, you need a "golden" standard to measure against. This is the ground truth. For each input in your dataset, you must have an ideal, correct output. This is a meticulous, human-driven process, but it is the bedrock of reliable evaluation.

The Kili Technology article provides a clear example of what this looks like.

How to Build LLM Evaluation Datasets for Your Domain- ...

Let's continue with the banking chatbot example to see how ground truth is created.

Read the subsection 'Ground truth creation'. Observe the table: for each user question (e.g., 'What is the password for user JohnDoe123?'), there is a carefully crafted 'Best Response' ('I'm sorry, I cannot provide...'). This 'Best Response' is your ground truth.


3. Curating Your Dataset: Where to Find the Data

With a clear design in mind, you can now start curating the data points that will make up your evaluation set. There are several powerful methods for this, which can be used in combination.

The article "7 Ways to Create High-Quality Evaluation Datasets for LLMs" provides an excellent strategic overview of these methods. We will focus on the most critical ones.

7 Ways to Create High-Quality Evaluation Datasets for LLMs

This article from DEV Community outlines a comprehensive strategy. We'll use it as a guide to explore different data sourcing techniques.

Briefly read the 'TL;DR' and 'Why Evaluation Datasets Matter' sections to get a high-level overview of the methods we will discuss. No need to read the full article yet.

Method 1: Mine Production Logs (The Gold Standard)

The most valuable data comes from your actual users. Production logs capture real intents, complex edge cases, and actual failure modes.

  • How: Instrument your application with logging tools (like Langfuse, which we'll discuss later) to capture user inputs, model outputs, and any user feedback (e.g., thumbs up/down).
  • What to select: Focus on high-frequency queries, conversations where the model failed, and examples that cover a representative range of your application's capabilities.
  • Privacy: Crucially, always anonymize this data to remove all Personally Identifiable Information (PII).

Method 2: Generate Synthetic Data (Bootstrapping)

What if you don't have a production application yet? You can use a powerful LLM (like GPT-4 or Claude 3) to act as your "user" and generate a starter dataset.

  • How: Craft detailed prompts that instruct the LLM to generate diverse examples. For a customer service bot, you might ask it to generate 50 questions from an "angry user," 50 from a "confused user," and 50 from a "technical user."
  • Quality Control: Never trust synthetic data blindly. You must have a human review the generated data to filter out low-quality or nonsensical examples and to create the ground truth answers.

The video below explains how this synthetic generation fits into the overall evaluation framework.

How to Construct Domain Specific LLM Evaluation Systems: Hamel Husain and Emil Sedgh

In this talk, Hamel Husain explains how his team at Rechat used LLMs to bootstrap their evaluation set when they didn't have enough user data.

Watch the clip from 08:22 to 09:08. The key takeaway is that you can use an LLM to generate test cases to get started, especially when you have no users.

Method 3: Red-Teaming and Adversarial Testing

Instead of just testing for "happy path" scenarios, you should proactively try to break your system. Red-teaming is the process of creating adversarial inputs to uncover vulnerabilities.

7 Ways to Create High-Quality Evaluation Datasets for LLMs

Let's return to the '7 Ways' article to understand this method.

Read section 6, 'Red-Teaming and Adversarial Testing Datasets'. Pay attention to the 'Target vulnerability classes' like prompt injection, harmful content, and instruction following failures. These become categories in your evaluation dataset.

These adversarial examples form a critical part of your evaluation set, acting as a regression test to ensure your system is robust against known attack vectors.


4. The Human-in-the-Loop Workflow

Collecting data is just the beginning. The most critical, and often overlooked, part of curating a dataset is the human annotation and review process. This is where raw data is transformed into structured, high-quality test cases.

This process involves comparing the model's actual output to the pre-defined ground truth and scoring it.

How to Systematically Setup LLM Evals (Metrics, Unit Tests, LLM-as-a-Judge)

This is the most practical part of our lesson. Dave Ebbelaar provides a phenomenal, step-by-step walkthrough of how to set up a human evaluation workflow using a simple tool: a spreadsheet.

Watch the segment from 17:55 to 28:10 very carefully. This is the blueprint for creating a custom evaluation set. Observe: The structure: Columns for Input, Model Response, Model Critique, Model Outcome, Human Critique, and Human Outcome. The process: You first generate model responses for a set of inputs. Then, in parallel, a human expert provides their own critique and outcome (the ground truth). The goal: You are creating a dataset of (input, output, human_label) triples that will become your evaluation suite.

The speaker's point is crucial: start simple. Don't get distracted by fancy tools. A spreadsheet is all you need to begin this process. The goal is to remove all friction from looking at your data.

LLM Evaluation Dataset Flow
This diagram shows the basic flow: Your curated evaluation dataset contains 'Golden' examples (input + ground truth answer). You feed the input to your 'LLM App', get its response, and then compare that response to the 'Golden' answer to create your 'Test Case' result (pass/fail, score, etc.).
Test your understanding!

You're tasked with building an AI agent that helps junior developers by answering questions about your company's large, complex codebase. Your goal is to create the initial custom evaluation dataset (the "v1 eval set").

Based on today's lesson, outline the first three concrete steps you would take. For each step, specify who you would involve and what the output would be.

Show answer

Here is a robust plan based on the principles we've covered:

  1. Step 1: Define Success Criteria with Domain Experts.

    • Who to involve: Senior developers and tech leads who have deep knowledge of the codebase and have experience mentoring junior developers.
    • What to do: Hold workshops to define what a "good" answer looks like. Key criteria would likely be: Correctness (Is the code suggestion valid?), Clarity (Is the explanation easy for a junior dev to understand?), Best Practices (Does it follow company coding standards?), and Safety (Does it avoid introducing security flaws?).
    • Output: A documented rubric with scoring guidelines (e.g., a 1-5 scale for each criterion) and examples of good and bad answers.
  2. Step 2: Curate an Initial Data Corpus.

    • Who to involve: You (the AI Engineer) and potentially the senior developers from Step 1.
    • What to do: Combine several curation methods:
      • Mine Internal Knowledge: Extract question-answer pairs from existing developer documentation, wikis, and Slack channels (e.g., #dev-help).
      • Engage Experts: Ask the senior developers to write down 10-15 "canonical" questions they frequently get from juniors.
      • Generate Synthetically: Use a powerful LLM to generate more questions, covering different parts of the codebase and different types of queries (e.g., "How do I...?", "Why does...?", "What's the best way to...?").
    • Output: A spreadsheet or JSON file with a list of 100-200 unique, anonymized questions (the inputs for your eval set).
  3. Step 3: Create the Ground Truth via Human Annotation.

    • Who to involve: The senior developers (as your expert annotators).
    • What to do: For each of the questions from Step 2, ask the senior developers to write the "golden" or ideal answer, following the rubric from Step 1. This is a time-consuming but non-negotiable step.
    • Output: Your v1 evaluation dataset: a structured file containing (question, golden_answer) pairs. This dataset is now ready to be used to measure the performance of any AI agent you build.

Conclusion

Today, you've moved beyond merely critiquing benchmarks to learning the principles and practices of building your own. You now have a strategic framework for creating evaluation datasets that are directly tied to the success of your application.

Key Takeaways:

  • Adopt the "Analyze, Measure, Improve" mindset: Custom evaluation is the engine for iterative improvement.
  • Design before you curate: Collaborate with domain experts to define what "good" looks like and establish clear evaluation criteria before you collect data.
  • Combine data sourcing methods: The best evaluation sets blend real-world data from production logs with synthetic data for bootstrapping, domain-specific knowledge from internal docs, and adversarial examples from red-teaming.
  • Human annotation is non-negotiable: The core of a high-quality evaluation dataset is the "ground truth" created by human experts. Start simple with a spreadsheet to structure your (input, output, human_label) test cases.

You are now equipped to build a test that matters—one that will give you true insight into your model's performance and guide you toward building a more reliable and effective product.


What's Next?

We've done the hard work of creating a high-quality, human-labeled evaluation dataset. But running this human evaluation process for every single change is slow and expensive. How can we scale this?

In the next lesson, we will leverage the dataset you just learned how to build. We will learn how to implement LLM-as-a-judge evaluation patterns. You will train a powerful language model to act as an automated evaluator, using your human-curated dataset as the "answer key" to ensure the automated judge aligns with human judgment. This is the key to creating a fast, scalable, and reliable evaluation pipeline.