{"slug": "g-eval-explained", "title": "G-Eval, Explained", "summary": "Microsoft researchers introduced G-Eval, a prompting framework that uses large language models to score open-ended text generation without requiring reference examples. The method combines precise rubrics, chain-of-thought evaluation steps, and token-probability scoring to produce ratings that align with human judgment. G-Eval addresses the long-standing challenge of reliably evaluating generative AI outputs in real-world applications like summarization and chatbots.", "body_md": "Everyone who has shipped a summarization feature, a chatbot, or an internal writing assistant has hit the same wall. The model works. You can feel it works when you read the outputs. But when someone in a review meeting asks, “How do we know it works?” the honest answer used to be a shrug followed by a metric nobody in the room actually believes. G-Eval closes that gap. It is a way to score open-ended text generation that agrees with what a careful human reviewer would say.\n\nG-Eval is based on a [2023 paper](https://arxiv.org/abs/2303.16634) by Yang Liu and coauthors at Microsoft, which is open-sourced in their [official repository](https://github.com/nlpyang/geval). The core idea is simple - give a large language model a rubric, let it…\n\n- write its own evaluation steps for that rubric\n- force it to fill out a structured scoring form\n- then read the probability mass behind the score it gives\n\nThe idea is not to rely solely on single-digit scores. This article walks through what G-Eval actually is, why each mechanism matters, and how to use it well in a real system.\n\n## What G-Eval Is\n\nG-Eval is a prompting framework for using a large language model as a reference-free evaluator of generated text. Reference-free means it does not need a gold-standard example to compare against, which matters because most real outputs, a customer support reply, a summary of a novel document, a chatbot turn, do not have one correct answer sitting in a dataset somewhere.\n\nThe framework has three components:\n\n- A prompt that states the task and defines the evaluation criterion precisely, for example, “rate this summary’s coherence on a scale of 1 to 5,” with coherence defined in concrete terms rather than left to the model’s imagination.\n- A\n[chain-of-thought (CoT)](https://arxiv.org/abs/2201.11903)of evaluation steps that the model generates for itself from the task and criterion, before it ever sees a specific example to score. - A scoring function that calls the model with the prompt, the generated CoT, and the actual input and candidate output, and converts the model’s response into a fine-grained numeric score using the underlying token probabilities rather than the raw printed digit.\n\nPut together, this turns “ask an LLM to grade something” from a vague, inconsistent request into a structured, repeatable procedure.\n\n## Why It Works\n\n### Specific Rubrics, Not Generic.\n\nThe prompt is not “rate this 1 to 5.” Instead, it should define the dimension precisely. A vague rubric gives the model nothing to anchor its judgment against, so it falls back on a generic sense of “does this look fine,” which does not discriminate well between a mediocre output and a genuinely strong one. A precise rubric gives the model specific things to check for, which is exactly what makes a human rater consistent too.\n\n### Chain-of-thought Forces Model to Read\n\nInstead of you hand-writing the evaluation steps for every criterion on every task, which does not scale past a handful of internal benchmarks, G-Eval asks the model to generate its own steps from just the task description and the criterion. For a coherence check, the model typically produces something like:\n\n```\n1. Read the source text carefully and identify the main topic and key points.\n2. Read the candidate output and compare it to the source. Check whether it\n   covers the main topic and key points, and whether it presents them in a\n   clear, logical order.\n3. Assign a score for coherence based on the Evaluation Criteria.\n```\n\nGenerating this before scoring anything forces the model to commit to a concrete evaluation procedure rather than pattern-matching to “this reads like a competent piece of writing” and stopping there. It also gives you something valuable - an audit trail. When a score looks wrong, you can read the chain-of-thought and see exactly where the judge’s reasoning diverged from what you would have said.\n\nNote that we are not writing evaluation steps by hand for every new rubric, which is what makes G-Eval usable for arbitrary custom dimensions like “does this response match our brand voice” or “does this answer respect the customer’s stated refund policy,” dimensions that no off-the-shelf metric was ever going to cover.\n\n### Direct Scoring Has Failure Modes\n\nThe naive version of this idea, just ask the model to output an integer score, has two problems that show up as soon as you look at score distributions across many examples rather than one example at a time.\n\nFirst, direct scoring tends to collapse onto a dominant value. Ask for coherence from 1 to 5 across a batch of outputs, and one digit, often the middle of the range, ends up absorbing most of the responses, regardless of real quality differences between them.\n\nSecond, given that most models output integers (even when we ask for decimal scoring), it becomes super difficult to rank two candidates against each other, or track whether a prompt change moved quality up or down by a small amount.\n\n### Probability Weighting is the Fix\n\nG-Eval’s answer to both problems is to stop trusting the printed digit and instead read the probability the model assigns to each possible score, then take the expectation:\n\nwhere is the predefined score set, for example, the integers 1 through 5, and is the probability the model assigns to that token in the scoring field. A judge that is 55 percent confident in a 4 and 45 percent confident in a 5 does not report a flat 4. It reports 4.45. Here, the decimal captures a real distinction between two candidates that the model considers almost the same.\n\nBut, how do we get the probability distribution of tokens? This requires an underlying API to expose token-level log probabilities (such as OpenAI’s [logprobs parameter](https://platform.openai.com/docs/api-reference/chat/create#chat-create-logprobs)), and a lot of chat-completion endpoints either do not expose them at all or only expose them awkwardly.\n\nThe practical workaround, covered below, is to sample the same prompt multiple times at a nonzero temperature and treat the frequency of each score as a stand-in for its probability. It costs more calls, but it recovers most of the benefit.\n\n## The Bias You Need to Know About\n\nFun fact, LLM judges show a measurable bias toward text generated by models from their own family, even when human reviewers prefer the alternative. This is a well-documented self-preference bias in LLM-as-a-judge systems, explored in detail in the [Judging LLM-as-a-Judge with MT-Bench](https://arxiv.org/abs/2306.05685) paper. So, never use the same model, or a close relative of it, for judging.\n\n## G-Eval in Practice\n\nThe full method is a two-step pipeline. Step one, generate the chain-of-thought once per rubric, since it depends only on the task and the criterion definition, not on any specific input, so it can be generated once and cached. Step two, call the judge per example using that cached chain-of-thought plus the actual input and candidate.\n\nStep one: generate the evaluation steps:\n\n```\ncot_prompt = \"\"\"\nYou will be given one summary written for a document.\nYour task is to rate the summary on one metric.\n\nEvaluation Criteria:\nCoherence (1-5) - the collective quality of all sentences. The summary\nshould be well-structured and well-organized, building from sentence to\nsentence to a coherent body of information about a topic, rather than\nbeing a heap of loosely related facts.\n\nEvaluation Steps:\n\"\"\"\n\nresponse = client.chat.completions.create(\n    model=\"gpt-4\",\n    messages=[{\"role\": \"user\", \"content\": cot_prompt}],\n    temperature=1.0,\n)\nevaluation_steps = response.choices[0].message.content\n```\n\nStep two, score a specific input and output pair using the cached steps, and read the token probabilities if your API exposes them:\n\n```\nscoring_prompt = f\"\"\"\n{cot_prompt}\n{evaluation_steps}\n\nSource:\n{source_text}\n\nSummary:\n{candidate_text}\n\nEvaluation Form (scores ONLY):\n- Coherence:\n\"\"\"\n\nresponse = client.chat.completions.create(\n    model=\"gpt-4\",\n    messages=[{\"role\": \"user\", \"content\": scoring_prompt}],\n    temperature=1.0,\n    logprobs=True,\n    top_logprobs=5,\n)\n\ntop_logprobs = response.choices[0].logprobs.content[0].top_logprobs\nscores = {\"1\": 1, \"2\": 2, \"3\": 3, \"4\": 4, \"5\": 5}\nweighted_score = 0.0\ntotal_prob = 0.0\nfor entry in top_logprobs:\n    token = entry.token.strip()\n    if token in scores:\n        prob = pow(2.718281828, entry.logprob)\n        weighted_score += prob * scores[token]\n        total_prob += prob\nfinal_score = weighted_score / total_prob if total_prob > 0 else None\n```\n\nIf your provider does not expose token-level log probabilities for chat completions, fallback to sample the same prompt several times at a nonzero temperature and take the mean of the discrete scores you get back. A few practical habits to follow\n\n- Pin the judge model version as part of your evaluation setup.\n- Never use the system under test and the judge from the same model family.\n- Cache the chain-of-thought per rubric rather than regenerating it on every call.\n- Calibrate every rubric against a small set of human-labeled examples before you trust it.\n- Write the rubric to explicitly rule out biases you do not want rewarded, for example, telling the judge not to prefer longer responses purely for length, since judges left to their own devices tend to read extra length as thoroughness even when it adds nothing.\n\nAlternatively, if you would rather not build and manage this pipeline entirely from scratch, you can use established open-source LLM evaluation frameworks like [DeepEval](https://docs.confident-ai.com/docs/metrics-introduction#g-eval) that provide a pre-built, production-ready G-Eval implementation.\n\n## When This Is the Wrong Tool\n\nG-Eval is the wrong tool, and a needlessly expensive one, for anything with a sharp, closed-form answer. Whether a response contains personal information, whether it is toxic, or whether an output is valid JSON, none of these need a reasoning model reading a rubric. They need a fast classifier or a parser, and reaching for an LLM judge there buys you nothing but latency and cost.\n\n#### Footnote\n\nG-Eval is a prompting framework that turns a large language model into a reference-free evaluator of generated text. It works by combining a precisely defined rubric, a chain-of-thought of evaluation steps the model generates for itself, and a scoring step that reads the model’s token probabilities across possible scores instead of trusting the printed digit.\n\nIts most important caution is that LLM judges show a measurable bias toward text generated by their own model family, so the judge should always come from a different family than the system under test. Used well, with a specific rubric, a cached chain-of-thought, an independent judge model, and periodic recalibration against human labels, it is one of the more reliable ways to measure open-ended text quality.", "url": "https://wpnews.pro/news/g-eval-explained", "canonical_source": "https://arpitbhayani.me/blogs/g-eval", "published_at": "2026-07-14 00:00:00+00:00", "updated_at": "2026-07-14 11:38:11.065988+00:00", "lang": "en", "topics": ["large-language-models", "generative-ai", "natural-language-processing", "ai-research", "ai-tools"], "entities": ["Microsoft", "Yang Liu", "G-Eval"], "alternates": {"html": "https://wpnews.pro/news/g-eval-explained", "markdown": "https://wpnews.pro/news/g-eval-explained.md", "text": "https://wpnews.pro/news/g-eval-explained.txt", "jsonld": "https://wpnews.pro/news/g-eval-explained.jsonld"}}