LLM-as-a-Judge: Building LLM-Based Evaluation Pipelines for AI Applications LLM-as-a-Judge uses a second large language model to evaluate AI-generated responses against predefined criteria, enabling scalable automated evaluation for AI applications. The approach, demonstrated with the Wayfinder flight search agent, assesses dimensions such as helpfulness, relevance, completeness, groundedness, and instruction following, and is supported by evaluation platforms like LangSmith. The complete implementation is available in the Wayfinder repository on GitHub under the v0.4.0 release. AI Engineering Fundamentals AI Evaluation · Part 5 ← Part 4 https://pub.towardsai.net/human-evaluation-building-reusable-evaluation-datasets-for-ai-applications-54f6d93fd2db?sharedUserId=divakar.ungatla 📦 Complete Code The complete implementation used in this article is available in the companionWayfinderrepository on GitHub. To follow along with the exact code and examples from this article, check out thev0.4.0 release. View the complete code on GitHub In the previous article, we explored Human Evaluation and how human reviewers can assess AI application quality using structured evaluation criteria. Human evaluation solves an important problem - it allows us to measure qualities that are difficult to express as deterministic rules, such as helpfulness, relevance, completeness and groundedness. However human evaluation has a practical limitation — it does not scale. As AI application grows, the number of interactions increases rapidly. Reviewing every response manually becomes expensive, time-consuming, and difficult to maintain. This raises an important question: Can we automate the evaluation process while maintaining the quality of human judgment ? This is where LLM-as-a-Judge comes in. Instead of relying entirely on human reviewers, we can use another large language model to evaluate AI-generated responses against predefined evaluation criteria. At a high level, LLM-as-a-Judge introduces another LLM into the evaluation pipeline. The application LLM generates the response, while the judge LLM evaluates that response against predefined criteria. In this article, we will explore how LLM-as-a-Judge works, build an evaluation pipeline for an AI application, and see how evaluation platforms like LangSmith help run and track these evaluations at scale. The key idea behind LLM-as-a-Judge is simple — instead of asking a language model only to generate responses, we introduce another language model whose responsibility is to evaluate those responses. In an AI application, there are now two distinct roles: The application LLM tries to solve the user’s request. The judge LLM does not solve the request again; it reviews whether the response produced by the application meets the expected quality standards. Let’s understand this using Wayfinder https://github.com/DivakarUngatla/wayfinder/tree/v0.4.0 , our flight search AI application. A user asks: Find the cheapest flight from Bangalore to Tokyo tomorrow. The Wayfinder https://github.com/DivakarUngatla/wayfinder/tree/v0.4.0 agent processes the request, searches available flight data, and generates a response: The cheapest flight is Air India AI302 at ₹410. Now the judge LLM evaluates this response. The judge receives: User Query:Find the cheapest flight from Bangalore to Tokyo tomorrow.Application Response:The cheapest flight is Air India AI302 at ₹410.Retrieved Context:Available flight information returned by the search tool.Evaluation Criteria:- Helpfulness- Relevance- Completeness- Groundedness- Instruction Following The judge is not checking whether the response matches a hardcoded expected answer. Instead, it evaluates whether the response is correct, useful, and supported by the available context. The output is an evaluation result: Helpfulness: 5/5Groundedness: 5/5Instruction Following: 5/5Explanation:The response correctly identifies the cheapest flightand the information is supported by the retrieved flight data. An LLM judge is only as effective as the criteria it uses to evaluate responses. Just like human reviewers need a clear rubric to evaluate AI outputs consistently, an LLM judge also needs predefined evaluation criteria that describe what a good response looks like. For Wayfinder, we use the same evaluation dimensions introduced in human evaluation: These criteria form the evaluation rubric that defines how the judge LLM should assess response quality. For example, instead of asking: Is this response good? the judge receives specific criteria: Evaluate this response for:- Helpfulness- Groundedness- Instruction Following This makes evaluations more consistent and repeatable across different responses. In the next section, we will see how these criteria are translated into an LLM-as-a-Judge implementation and how the evaluator produces structured scores and explanations. Now that we have defined our evaluation criteria, the next step is to build an evaluator that can apply this rubric to AI-generated responses. An LLM-as-a-Judge pipeline starts with an evaluation dataset. The complete code is here — Wayfinder https://github.com/DivakarUngatla/wayfinder/tree/v0.4.0 . An evaluation dataset contains representative user scenarios that we want our AI application to handle. Each evaluation sample contains: For Wayfinder, our dataset contains scenarios such as: { "inputs": { "query": "Find the cheapest flight from Bangalore to Tokyo tomorrow." }, "outputs": { "expected behavior": "Recommend the retrieved flight with the lowest price without inventing information." }, "metadata": { "category": "cheapest" }} The important thing is that the dataset does not contain a fixed expected answer. Instead, it describes the expected behavior of the application. During evaluation, each dataset sample is executed against the AI application. The quality of an LLM-as-a-Judge system depends heavily on how the judge prompt is designed. A good judge prompt should clearly define: For Wayfinder, the judge prompt follows this pattern: You are an expert evaluator assessing the quality of an AI assistant response.You will be given:- The user's original query.- The expected behavior: a description of what a good assistant response should do for this query.- The assistant's actual response.- The flight data retrieved by the search tool before the response was generated.Your task is to evaluate the assistant's response against each of the following criteria.Evaluation criteria and rubric:{criteria block}Instructions:- "Expected behavior" describes what the application was expected to do for this sample. It is not a model answer. Use it to understand the intent of the query.- Evaluate the response against each criterion independently.- When evaluating Groundedness, cross-reference the response against the retrieved flight data.- Do not invent facts that are not present in the supplied context.- Score every criterion from 1 to 5 using the rubric above.- Provide a concise explanation for every criterion score.- Provide an overall score from 1 to 5 that reflects your holistic judgment. Do not calculate the overall score as an average of the criteria scores.- Provide a concise overall explanation."""User Query:{query}Application Response:{response}Retrieved Context:{context}Provide a score from 1-5 for each criterionand explain your reasoning. The judge is not asked to generate a better response. Its only responsibility is to evaluate the response it receives. Free-form evaluation responses from the judge are difficult to analyze automatically. Instead, the evaluator asks the LLM Judge to return structured output. In our implementation, we enforce a predefined response schema so every evaluation produces a consistent format. The schema contains: Example: { "criteria scores": { "criterion": "Helpfulness", "score": 5, "explanation": "The response directly answers the user's request." }, { "criterion": "Groundedness", "score": 5, "explanation": "The response is supported by the provided context." }, { "criterion": "Instruction Following", "score": 5, "explanation": "The response satisfies the user's requirements." } , "overall score": 5} With the evaluation dataset, criteria, judge prompt, and structured output format in place, we can now implement the LLM-as-a-Judge evaluator. The evaluator acts as a reusable component that takes an AI application’s output and evaluates it using the predefined rubric. At a high level, the judge performs four steps: The evaluator receives: User QueryApplication ResponseExpected BehaviorRetrieved ContextEvaluation Criteria and produces: Criterion Scores+Explanations+Overall Assessment The application code exposes a simple interface: result = judge.evaluate query=query, expected behavior=expected behavior, response=response, retrieved flights=retrieved context Internally, the evaluator builds the judge prompt: messages = { "role": "system", "content": judge instructions }, { "role": "user", "content": evaluation input } The system prompt defines the judge’s role, evaluation criteria and scoring guidelines. The user message provides the specific evaluation sample, including the query, response and supporting context. The LLM response is then parsed into the structured evaluation model: JudgeResult criteria scores= CriterionScore criterion="Groundedness", score=5, explanation="The response is supported by the retrieved context." , overall score=5, overall explanation="The response satisfies the user's request." Keeping the judge as a separate component makes it reusable. The same evaluator can be applied to different versions of an AI application using the same evaluation dataset and criteria. This allows teams to measure whether changes actually improve the system: Instead of manually reviewing responses after every change, teams can run repeatable evaluations and compare results across versions. The complete implementation used throughout this article is available in the companion GitHub repository .To follow along with exactly the same code shown in this article, check out thev0.4.0release.This ensures the code, commands, and screenshots remain consistent over time. To run the examples locally, clone the repository and checkout the release containing the LLM-as-a-Judge implementation. git clone https://github.com/DivakarUngatla/wayfinder.gitcd wayfindergit checkout v0.4.0-llm-judge Install the project dependencies: uv sync Before running the evaluation, configure the required environment variables. Create a .env file: cp .env.example .env Add your OpenAI API key: OPENAI API KEY=