Functional Correctness
This metric measures whether the performance of any application performs what it is intended to do. This is easy to measure for deterministic systems.
Similarity Measurement aginst reference data
This checks how similar the LLM generated data is to the gold standard. The gold standard could be generated by AI or human.
Exact match
This can be one to one mapping of the answer or one to many mapping.
Lexical similarity
This measures the overlap of tokens in two texts. Approximate string matching or fuzzy matching is used for this like edit distance, n-gram similarity, BLEU, ROUGE, METEOR++, TER and CIDEr.
BLEU (Bilingual Evaluation Understudy): It measures how many word sequences (1-gram, 2-gram, 3-gram, 4-gram) in the generated text also appear in the reference text.
- Count matching n-grams between candidate and reference
- Compute precision for each n-gram length (1 to 4 typically)
- Take the geometric mean of these precisions.
- Apply brevity penalty (since precision alone rewards very short outputs, 2 word output that happens to match is 100% precise), BLEU penalizes candidate shorter than the reference.
This was built for translation.
ROUGE (Recall-Oriented Understudy for Gisting Evaluation): This is n-gram recall, how much of the reference’s content is captured in the generated text.
ROUGE-N: n-graph overlap ROUGE-L: based on longest common subsequence (LCS) ROUGE-S: skip-bigram overlap, allowing graps between matched word pairs
This was build for summarization to capture if the summary captures the content from the source even if worded differently.
METEOR(Metric for Evaluation of Translation with Explicit Ordering): This measures the word-level alignment between candidate and reference but it accounts fro synonyms, stemming and paraphrasing.
- Aligns words between candidate and reference using exact match, then stemmed match, then synonym match, then paraphrase match
- Computes a weighted harmonic mean of precision and recall (recall weighted more heavily than BLUE does)
- Applies a fragmentation penalty, penalizes if matched words appear in a scrambled/discontinuous order relative to the reference
METEOR++: This adds further paraphrase tables, additional language resources or tuned parameter weights on top of the base METEOR formulation.
TER(Translation Edit Rate): It measures the minimum number of edits(insertions, deletions, substitutions or shifts of word sequences) needed to transform the generated text into the reference text, normalized by reference length.
$$ \text{TER} = \frac{\text{number of edits}}{\text{average number of reference words}} $$
CIDEr (Consensus-based Image Description Evaluation): Similarity between a generated caption and a set of multiple reference captions, weighting n-grams by TF-IDF.
- Represent both candidate and each reference caption as TF-IDF weighted n-gram vectors
- Compute cosine-similarity between the candidate vector and each reference vector
- Average across all references, across multiple n-gram length (typically 1-4), then combine
Semantic similarity: AI as Judge
Biases of AI as judge:
- LLMs has self-bias where a model favors its own responses over the responses generated by other models.
- First-position bias: LLMs favor the first answer in a pairwise comparison or the first in a list of options. This opposite to the human judgement. Human tends to favor the answer they see last which is called recency bias.
- Verbosity-bias: favors lengthier answer regardless of quality.
Reward Model: A reward model takes in a (prompt, response) pair and scores how good the response is given the prompt. RLHF is one of the reward model.
Reference-based judge: A reference-based judge evaluates the generated response with respect to one or more reference responses. This judge can output a similarity score or quality score.
Preference model: A preference model takes in (prompt, response 1, response 2) as input and outputs which of the two responses is better (preferred by users) for the given prompt.