跳到正文
DEV Community· Conor Bronsdon·· 1 小時前AI 評分64

如何不靠 ROUGE 或 BERTScore 評估開放式回答

Grade open-ended answers without ROUGE or BERTScore

AI 導讀

文章建議以 LLM 評審補足 ROUGE 和 BERTScore 的不足,評估開放式回答是否適合呈現給用戶。判定只用 pass、fail、cannot_tell,並要求一行指出所套用準則的理由;無效輸出則在 wrapper 中記為 cannot_tell。文章建議記錄模型與人工標籤不一致的案例,檢視 cannot_tell 和分歧紀錄後再修改評分規則。

正文

Overlap metrics tell you how close a reply is to a reference. They do not tell you whether a person would accept it. For open-ended output I'd put an LLM judge in that gap, and keep it on a short leash: one label, a one-line reason, and an honest "cannot tell".

Why do ROUGE and BERTScore miss replies users reject?

A reply can share most of its wording with a reference summary and still be a response you should not ship. ROUGE (Recall-Oriented Understudy for Gisting Evaluation) scores a machine-written summary against one or more summaries written by people. Chin-Yew Lin introduced the package in 2004 and tested it against human judgments from the Document Understanding Conference, the NIST-sponsored summarization evaluation. ROUGE-N counts shared n-grams, so ROUGE-1 is single words and ROUGE-2 is word pairs. ROUGE-L uses the longest common subsequence, which rewards words in the same order without requiring them to be adjacent. ROUGE-S counts skip-bigrams, pairs in sentence order with gaps allowed. The recall-oriented design is what separates ROUGE from BLEU. Those variants answer a narrow question: how much of the reference showed up in the candidate. Users also care whether the reply was fit to send.

BERTScore was introduced in 2019 by Tianyi Zhang and colleagues at Cornell and ASAPP because BLEU and ROUGE match surface words, so a paraphrase that means the same thing scores poorly. BERTScore embeds every token in the candidate and the reference with a pretrained contextual model, matches each token to its most similar counterpart by cosine similarity, and reports precision, recall, and F1. The authors tested it on the outputs of 363 machine translation and image captioning systems and found it correlated better with human judgments than the existing metrics. That catches paraphrase. The score is still similarity to a reference. Open-ended replies often have several acceptable wordings, and a close match can still be the wrong reply for the person who asked.

Chip Huyen used a book summary for this bind. A summary can sound reasonable, and you may still have to read the whole book to know whether it is good. She also pointed to a LinkedIn case study of a job-fit assistant. Asked whether a candidate was a good fit for a role, the bot could reply "No, you're a terrible fit." The answer was correct, and it was still a bad response. Overlap with a reference that also says the candidate is a poor fit would look fine. She said teams report scores like coherence and relevancy as if they were exact metrics.

But they're actually very highly dependent on the models you use, on the prompt you use for the judge.

Chip Huyen, author of Designing Machine Learning Systems, on Chain of Thought ep 5 (December 2024)

Vivienne Zhang described a domain version of the same miss on an NVIDIA copilot for chip designers. Asked what CTL means, a generally accepted answer is combinational time logic. For those designers the answer is Compute Trace Library, specific to NVIDIA. A reference that rewards the public expansion rewards the wrong term in that room. She also pointed to open leaderboards, including RewardBench, where a lot of humans do not agree on which answer is better. She said there is no right answer, and there could be 10 different answers.

I think I have a very simplified view representing users, which is the application gives an answer that looks correct, but it's not what the user is looking for, and I will consider that a hallucination.

Vivienne Zhang, then a senior product manager for generative AI software at NVIDIA, on Chain of Thought ep 5 (December 2024)

What should one judge call return?

LLM-as-a-judge gives a capable model the output, a rubric, and often the question and a reference, and asks for a score or a verdict. You cannot hand-review every production reply, so the judge is how you get a signal on the volume. The judge is a fallible model. It can be inconsistent, biased toward longer or more confident answers, and only as good as the rubric you give it. A 1 to 10 rating produces noise. I would start with three outcomes and nothing else.

Pass means the reply meets the criteria you wrote down. Fail means it breaks one of them, including a factually correct reply that is unfit to show a user. Cannot tell means the rubric, or the domain context you supplied, does not decide the case. Keep cannot tell as its own bucket. A person labels those rows. If the same gap keeps appearing, that gap becomes a new line in the rubric.

How do you write the prompt?

Put the criteria in the prompt before the answer. Name the failures in reviewer language: a detail missing from the context, a reply that misses the question, a correct but hostile reply, or a public definition that is wrong for this product. If an explicit "I can't answer from this" should pass when the context is insufficient, say that in the rubric. Tell the model to ignore length and phrasing unless they change the meaning. Require JSON with two fields only, label and reason. The reason is one line and names the criterion. The allowed labels are pass, fail, and cannot_tell. Anything else is not a verdict.

What does the wrapper log?

The sketch below is an illustration of the call wrapper and the disagreement log. call_model stands in for sending the prompt and returning text. It is not production code, and it is not a pipeline any guest described.

# Sketch only. Not production code.
import json

LABELS = ("pass", "fail", "cannot_tell")

def judge_prompt(question, answer, rubric):
    return (
        "Grade this one reply. Ignore length and phrasing unless they change meaning.\n"
        "label must be pass, fail, or cannot_tell.\n"
        "Use cannot_tell if the rubric does not decide the case.\n"
        "reason is one line and must name the criterion you applied.\n"
        "Return only JSON with keys label and reason.\n\n"
        f"Rubric:\n{rubric}\n\nQuestion: {question}\nAnswer: {answer}"
    )

def run_judge(question, answer, rubric, call_model):
    data = json.loads(call_model(judge_prompt(question, answer, rubric)))
    if data.get("label") not in LABELS or not data.get("reason"):
        return {
            "label": "cannot_tell",
            "reason": "Judge output was missing a valid label or reason.",
        }
    return {"label": data["label"], "reason": data["reason"]}

def log_disagreement(log, case_id, judge_row, human_label):
    if judge_row["label"] != human_label:
        log.append({
            "id": case_id,
            "judge": judge_row["label"],
            "human": human_label,
            "reason": judge_row["reason"],
        })
    return log

When a reviewer has marked the same case, append a row only if the two labels differ, and store the judge's one-line reason with that row. Read the cannot tell rows and the disagreement log before you change the prompt. The reason tells you whether the judge misread a criterion you already wrote, or whether the rubric never covered the case.

Checklist

  • Write user-facing failures into the rubric first, including a correct reply that is still a bad one to send.
  • Allow only pass, fail, and cannot tell, and require a one-line reason that names the criterion.
  • If the model returns any other shape, store cannot tell in the wrapper and leave the case unscored.
  • Log each row where the judge label and a human label differ, and keep the judge's reason on that row.
  • Read the cannot tell rows and the disagreement log before you add a domain rule or edit the prompt.

The longer explainer, with the episode clips, is on Chain of Thought. It draws on this episode.

Subscribe to the Chain of Thought newsletter for new episodes and write-ups like this one.

Drafted with AI assistance from the episode transcripts.

來源:DEV Community · dev.to