AI and ML Network Blog

Measuring Annotation Quality Mathematically: IoU, mAP, Cohen’s Kappa & Krippendorff’s Alpha

Measure data annotation and LLM evaluation quality rigorously using IoU, box/mask F1, Cohen's Kappa, and Krippendorff's Alpha with Python code and QA thresholds.

November 7, 2026 Updated November 25, 2026 Onidul Islam Siyam Onidul Islam Siyam 10 min read Advanced
Quality Assurance Computer Vision RLHF Data Annotation MLOps

The Short Answer

Never judge training data or LLM evaluation quality by a vague headline percentage. Match the metric to the geometry and label structure: use IoU + Instance F1 for bounding boxes and segmentation masks, OKS / pixel tolerance for keypoints, IDF1 / ID-switch count for video tracking, Cohen’s Kappa for two-reviewer categorical tasks, and Krippendorff’s Alpha for multi-reviewer, sparse, or ordinal AI response evaluation rubrics.

When a vendor quotes a flat accuracy number without defining the unit of measurement, threshold, and chance correction, your engineering team has no way to predict downstream model behavior.

Why “99% Accuracy” Means Nothing Without a Metric Definition

In production ML pipelines, two datasets can both claim high accuracy while producing completely different model metrics:

  • Frame-level vs. object-level denominator: An image with 19 empty frames and 1 frame containing 10 missed objects looks “95% accurate” at the frame level—yet fails completely on recall.
  • Class imbalance illusion: On a safety or defect dataset where 96% of samples are normal, labeling every sample “normal” achieves 96% raw accuracy and 0% defect recall.
  • Geometry vs. classification confusion: A bounding box can carry the right class ID while sitting 15 pixels too loose around a pedestrian, dragging down mAP@0.50:0.95 during training.

A real QA contract separates localization precision, detection completeness (missing/extra instances), and class or rubric agreement.

Choosing the Right QA Metric by AI Modality

Modality / TaskPrimary QA Metric(s)Typical Production GatePrimary Failure Mode Caught
2D Bounding BoxesMean IoU + Matched Instance F1 (IoU >= 0.75–0.90)F1 >= 0.96, mIoU >= 0.88Loose boxes, missed small objects, wrong class IDs
Semantic / Instance SegmentationBoundary IoU (B-IoU) + Mask Dice / IoUMask IoU >= 0.90, B-IoU >= 0.80Edge bleed, jagged polygons, merged adjacent instances
Keypoints / PoseOKS (Object Keypoint Similarity) + Visibility Flag MatchOKS >= 0.90, visibility match >= 95%Swapped left/right joints, wrong v=0/1/2 flags
Video Object TrackingIDF1 + ID-Switch Rate + MOTAZero unresolved ID swaps per clipBroken trajectories after occlusion or re-entry
3D LiDAR Cuboids3D BEV IoU + Yaw Error (degrees)3D IoU >= 0.70–0.80, yaw <= 5°Flipped heading direction, ground-plane z-drift
Text / NER ClassificationExact Span F1 + Cohen’s Kappa (κ)κ >= 0.80, span F1 >= 0.92Partial entity spans, inconsistent boundary punctuation
LLM Preference / Rubric EvalsKrippendorff’s Alpha (α, nominal or ordinal)α >= 0.75–0.80 (ordinal/binary)Subjective rubric drift, ambiguous tie-breaking

Computer Vision QA: Separating Localization From Completeness

A common mistake in vision QA is averaging IoU only across matched boxes while ignoring missed objects (false negatives) or hallucinated boxes (false positives). Always compute two numbers against a reviewed gold set:

  1. Localization Quality (Mean IoU of matched pairs): Measures how tightly annotators hug object boundaries.
  2. Detection Completeness (Precision, Recall, and F1 at a strict IoU cutoff): Penalizes every missed object, duplicate box, and class swap.

Watch Out for Small-Object IoU Sensitivity

IoU is unforgiving on small objects. A 20 × 20 px traffic sign shifted by just 2 pixels on two sides drops from 1.00 to roughly 0.68 IoU, whereas a 400 × 400 px truck shifted by 2 pixels still scores 0.98.

For mixed-scale scenes (such as aerial imagery, CCTV, or 3D perception datasets), stratify your QA thresholds by object area:

  • Large objects (> 96 × 96 px): Strict IoU >= 0.90
  • Medium objects (32 × 32 to 96 × 96 px): IoU >= 0.85
  • Small objects (< 32 × 32 px): IoU >= 0.75 or <= 2 px boundary tolerance

Text, NLP & LLM Evaluation QA: Cohen’s Kappa vs. Krippendorff’s Alpha

When teams move from computer vision to text annotation or AI response evaluation, raw agreement breaks down quickly because human judgment involves class skew and ordinal scales.

Cohen’s Kappa (κ) — Best for Two Reviewers, Categorical Labels

Cohen’s Kappa measures agreement beyond chance between two annotators rating the same set of items:

kappa = (p_observed - p_expected_by_chance) / (1 - p_expected_by_chance)
  • κ < 0.40: Guidelines are broken or underspecified; pause labeling immediately.
  • κ = 0.60 – 0.79: Usable for rough exploration, but ambiguous edge cases still need written examples.
  • κ >= 0.80: Production-ready consistency for binary/categorical classification and groundedness checks.

Krippendorff’s Alpha (α) — The Gold Standard for Production Ops

Real annotation pods rarely have the exact same two people label 100% of items. Usually, 5 to 15 reviewers annotate subsets, with a 10–20% overlapping audit slice. Krippendorff’s Alpha handles:

  • Any number of reviewers
  • Missing/sparse overlap matrices (not every reviewer scores every item)
  • Nominal labels (categories), ordinal rubrics (e.g., 1–4 severity), and interval scores (where a 1 vs. 2 disagreement is penalized less than a 1 vs. 4 disagreement)

Practical Python QA Verification Script

You can integrate this lightweight verification check into your CI/CD data pipeline or calibration review to compute both 2D box IoU / F1 and chance-corrected Cohen’s Kappa:

from collections import Counter
from typing import List, Tuple

Box = Tuple[int, float, float, float, float]  # (class_id, x1, y1, x2, y2)

def compute_iou(a: Box, b: Box) -> float:
    ix1, iy1 = max(a[1], b[1]), max(a[2], b[2])
    ix2, iy2 = min(a[3], b[3]), min(a[4], b[4])
    inter = max(0.0, ix2 - ix1) * max(0.0, iy2 - iy1)
    area_a = max(0.0, a[3] - a[1]) * max(0.0, a[4] - a[2])
    area_b = max(0.0, b[3] - b[1]) * max(0.0, b[4] - b[2])
    union = area_a + area_b - inter
    return inter / union if union > 0 else 0.0

def evaluate_box_qa(pred: List[Box], gold: List[Box], iou_thresh: float = 0.85) -> dict:
    matched_gold = set()
    ious = []
    tp = 0
    for p in pred:
        best_iou, best_idx = 0.0, -1
        for idx, g in enumerate(gold):
            if idx in matched_gold or p[0] != g[0]:
                continue
            score = compute_iou(p, g)
            if score > best_iou:
                best_iou, best_idx = score, idx
        if best_iou >= iou_thresh and best_idx >= 0:
            matched_gold.add(best_idx)
            ious.append(best_iou)
            tp += 1
    fp = len(pred) - tp
    fn = len(gold) - tp
    precision = tp / (tp + fp) if (tp + fp) else 1.0
    recall = tp / (tp + fn) if (tp + fn) else 1.0
    f1 = (2 * precision * recall / (precision + recall)) if (precision + recall) else 0.0
    return {
        "matched_tp": tp,
        "false_positives": fp,
        "missed_fn": fn,
        "f1": round(f1, 4),
        "mean_iou": round(sum(ious) / len(ious), 4) if ious else 0.0,
    }

def cohens_kappa(rater_a: List[str], rater_b: List[str]) -> float:
    assert len(rater_a) == len(rater_b) and len(rater_a) > 0
    n = len(rater_a)
    p_obs = sum(1 for a, b in zip(rater_a, rater_b) if a == b) / n
    counts_a, counts_b = Counter(rater_a), Counter(rater_b)
    labels = set(counts_a) | set(counts_b)
    p_exp = sum((counts_a[k] / n) * (counts_b[k] / n) for k in labels)
    return 1.0 if p_exp == 1.0 else round((p_obs - p_exp) / (1.0 - p_exp), 4)

Operationalizing QA: The 3-Gate Calibration Loop

Metrics only improve your model when they are wired into release gates:

  1. Gate 1 — Calibration Pilot (50–150 items): Two or more reviewers independently label the exact same edge-case-heavy slice. Compute mIoU / F1 or κ / α. Every disagreement becomes a new visual or textual example inside your annotation guidelines.
  2. Gate 2 — Rolling Gold-Set Injection (5–10% of production): Mix pre-verified gold items blindly into live batches inside CVAT, Roboflow, Encord, or Label Studio so drift is detected per annotator and per class in real time.
  3. Gate 3 — Pre-Export Schema & Class Audit: Before handoff, run automated scripts to check zero-area boxes, out-of-bounds coordinates, invalid visibility flags, missing rationales, and unexpected class-distribution shifts (paired with our full computer vision QA checklist).

When Low Agreement Signals a Guideline Bug (Not a Bad Annotator)

If three careful reviewers all disagree on the same 15% of items, firing annotators will not fix your dataset. Low inter-annotator agreement is usually a specification bug:

  • Two classes overlap semantically (e.g., "van" vs. "truck", or "minor hallucination" vs. "incomplete answer").
  • Occlusion rules aren’t quantified (e.g., “label if more than 30% visible”).
  • An ordinal LLM rubric uses vague 1–5 scales instead of decomposed yes/no criteria.

Fixing the guideline before scaling saves weeks of relabeling and directly boosts downstream model convergence.

Need a Calibration QA Audit on Your Dataset or Eval Rubric?

AI and ML Network builds written edge-case guidelines, runs calibration pilot batches, and delivers QA-audited computer vision, 3D LiDAR, and LLM evaluation datasets directly inside your preferred workspace. Start your project with a sample batch or schedule a scoping call to define your exact acceptance metrics.

Frequently Asked Questions

Why is raw percent agreement misleading for data annotation QA? +

Percent agreement ignores agreement that happens by pure chance. On an imbalanced dataset where 95 percent of items belong to the negative class, two careless annotators who blindly label everything negative achieve 95 percent raw agreement while producing a useless dataset. Chance-corrected metrics such as Cohen's Kappa and Krippendorff's Alpha expose that failure immediately.

What IoU threshold should teams use for computer vision annotation QA? +

For standard 2D bounding boxes on medium or large objects, teams typically audit annotator-to-gold alignment at IoU 0.85 to 0.92 depending on object density. For small objects under 32 by 32 pixels, even a 2-pixel shift lowers IoU sharply, so QA specs should pair IoU with pixel-tolerance rules.

When should you use Krippendorff's Alpha instead of Cohen's Kappa? +

Use Cohen's Kappa only when exactly two annotators label every item in a categorical task. Use Krippendorff's Alpha whenever you have three or more annotators, sparse overlapping review samples (missing values), or ordinal rubric scores such as 0 to 3 LLM quality ratings.

How large should a calibration gold set be before scaling production labeling? +

Most computer vision and LLM evaluation pipelines start with a 50 to 150 item calibration set that intentionally over-samples ambiguous edge cases, rare classes, and occlusions. Agreement is measured on this calibration set before full production begins.

Work With AI and ML Network

Need help with annotation, QA, or AI model evaluation?

Share your dataset, model objective, or evaluation criteria. We work inside your preferred platform and scope a clear pilot before production.