genai-evaluation-metrics
Use when evaluating generative models — choosing metrics (FID, IS, KID, sFID, FDD, FVD, PRDC, LPIPS, SSIM, AuthPct, Vendi), setting up online or offline evaluation, feature extractor selection, distributed computation, memory management during sampling. Triggers: "FID", "IS", "KID", "inception score", "frechet", "LPIPS", "SSIM", "evaluation metrics", "generative evaluation", "FVD"
Best use case
genai-evaluation-metrics is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when evaluating generative models — choosing metrics (FID, IS, KID, sFID, FDD, FVD, PRDC, LPIPS, SSIM, AuthPct, Vendi), setting up online or offline evaluation, feature extractor selection, distributed computation, memory management during sampling. Triggers: "FID", "IS", "KID", "inception score", "frechet", "LPIPS", "SSIM", "evaluation metrics", "generative evaluation", "FVD"
Teams using genai-evaluation-metrics should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/genai-evaluation-metrics/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How genai-evaluation-metrics Compares
| Feature / Agent | genai-evaluation-metrics | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when evaluating generative models — choosing metrics (FID, IS, KID, sFID, FDD, FVD, PRDC, LPIPS, SSIM, AuthPct, Vendi), setting up online or offline evaluation, feature extractor selection, distributed computation, memory management during sampling. Triggers: "FID", "IS", "KID", "inception score", "frechet", "LPIPS", "SSIM", "evaluation metrics", "generative evaluation", "FVD"
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# GenAI Evaluation Metrics
## When to Use
- Setting up online evaluation during generative model training
- Choosing which metrics to compute (image vs video, distribution vs perceptual)
- Selecting feature extractors (InceptionV3 vs DINOv2 vs CLIP)
- Configuring sample counts for training-time vs final benchmarks
- Debugging OOM during evaluation sampling phases
- Distributed metric computation with HuggingFace Accelerate
- Evaluating memorization, diversity, or mode collapse
## Metric Catalog
### Distribution Metrics (Frechet Distance family)
All compute distance between real and generated feature distributions using mean + covariance.
| Metric | Feature Extractor | Dim | What It Captures |
|--------|------------------|-----|-----------------|
| **FID** | InceptionV3 pool3 | 2048 | Overall distribution quality (standard benchmark) |
| **sFID** | InceptionV3 spatial (Mixed_6e) | 2023 | Spatial structure quality |
| **FDD** | DINOv2 ViT-L/14 | 1024 | Modern FID alternative, better on textures |
| **FVD** | I3D | 400 | Video temporal + spatial quality |
### Diversity & Quality Metrics
| Metric | What It Measures |
|--------|-----------------|
| **IS** (Inception Score) | Quality (confident predictions) + diversity (class coverage) |
| **KID** (Kernel Inception Distance) | Unbiased FID alternative using MMD with polynomial kernel |
| **PRDC** (Precision/Recall/Density/Coverage) | Manifold overlap: fidelity (P), mode coverage (R), sample density (D), support coverage (C) |
| **Vendi Score** | Diversity via eigenvalue entropy of similarity matrix |
### Perceptual Metrics (paired, per-sample)
| Metric | Feature Extractor | Use Case |
|--------|------------------|----------|
| **LPIPS** | AlexNet (spatial) | Perceptual similarity between paired images/frames |
| **SSIM** | Gaussian filter | Structural similarity (luminance, contrast, structure) |
| **PSNR** | None (MSE) | Pixel-level reconstruction quality |
### Memorization & Overfitting Metrics
| Metric | What It Detects |
|--------|----------------|
| **AuthPct** | % of generated samples that are "authentic" (not memorized) |
| **CT Score** | Data copying / memorization detection |
| **FLS** (Frechet Likelihood Score) | KDE-based likelihood, sensitive to overfitting |
| **FD-infinity** | FID extrapolated to infinite samples (removes sample-size bias) |
## Patterns
### Metric Orchestrator
Wrap all metrics behind a unified update/compute interface:
```python
class MyMetric:
def __init__(self, device="cuda", choices=["fid"]):
if "fid" in choices:
self._fid = FrechetInceptionDistance(
feature=2048, reset_real_features=True,
normalize=False, sync_on_compute=True,
).to(device)
if "is" in choices:
self._is = InceptionScore().to(device)
if "kid" in choices:
self._kid = KernelInceptionDistance(subset_size=50).to(device)
if "prdc" in choices:
self._prdc = PRDC(nearest_k=5).to(device)
if "sfid" in choices:
self._sfid = sFrechetInceptionDistance().to(device)
if "fdd" in choices:
self._fdd = FrechetDinovDistance().to(device)
if "fvd" in choices:
self._fvd = FrechetVideoDistance()
if "dinov2" in choices:
self._dinov2 = DinoV2_Metric().to(device)
def update_real(self, imgs):
# IS only gets fake images — skip real for IS
for name in self.choices:
if name != "is":
getattr(self, f"_{name}").update(imgs, real=True)
def update_fake(self, imgs):
for name in self.choices:
getattr(self, f"_{name}").update(imgs, real=False)
def compute(self):
results = {}
for name in self.choices:
results.update(getattr(self, f"_{name}").compute())
return results
```
Image vs video metric selection:
```python
# Images
metric = MyMetric(choices=["fid", "is", "kid", "prdc", "sfid", "fdd", "dinov2"])
# Videos
metric = MyMetric(choices=["fid", "fvd"], video_frame=16)
```
### Online Evaluation (During Training)
Evaluate periodically using the EMA model (not the training model):
```python
if step % cfg.sample_fid_every == 0 and step > 0:
with torch.no_grad():
torch.cuda.empty_cache()
metric.reset()
# 1) Feed real images
for _ in range(n_fid_samples // batch_size):
metric.update_real(next(real_data_iter))
# 2) Generate fake images with EMA model
for _ in range(n_fid_batches):
z = torch.randn(batch_size, C, H, W, device=device)
samples = sample_fn(z, ema_model)
if use_latent:
samples = vae.decode(samples / 0.18215).sample
samples = (samples.clamp(-1, 1) * 127.5 + 127.5).to(torch.uint8)
samples = accelerator.gather(samples.contiguous())
metric.update_fake(samples)
del samples, z
torch.cuda.empty_cache()
results = metric.compute()
best_fid = min(results["fid"], best_fid)
```
Track multiple bests for checkpointing:
```python
best_fid = min(results["fid"], best_fid)
best_fdd = min(results["fdd"], best_fdd)
best_sfid = min(results["sfid"], best_sfid)
best_dinov2_fid = min(results["dinov2_fid"], best_dinov2_fid)
```
### sFID, FDD, FVD: Distribution Metric Implementations
sFID uses InceptionV3 spatial features (Mixed_6e), FDD uses DINOv2 ViT-L/14, FVD uses I3D for video.
See [references/distribution-metrics.md](references/distribution-metrics.md) for implementation details.
### DINOv2 Multi-Metric (FID+KID+IS+PRDC in one pass)
Compute FID, KID, IS, and PRDC in DINOv2 feature space with a single extraction pass.
See [references/dinov2-multi-metric.md](references/dinov2-multi-metric.md) for implementation.
### PRDC, AuthPct, Vendi Score, FD-infinity
Diversity and memorization metrics: k-NN manifold overlap (PRDC), memorization detection (AuthPct), eigenvalue diversity (Vendi), and sample-size debiased FID (FD-infinity).
See [references/diversity-memorization-metrics.md](references/diversity-memorization-metrics.md) for implementations.
### Video Perceptual Metrics (FVD, LPIPS, SSIM, PSNR)
Frame-by-frame perceptual metrics for video evaluation using I3D, AlexNet, and structural similarity.
See [references/video-perceptual-metrics.md](references/video-perceptual-metrics.md) for implementation details.
## Feature Extractor Selection Guide
| Extractor | Best For | Dim | Speed |
|-----------|---------|-----|-------|
| **InceptionV3** (pool3) | Standard FID benchmarks, paper comparisons | 2048 | Fast |
| **InceptionV3** (spatial) | Spatial structure evaluation (sFID) | 2023 | Fast |
| **DINOv2 ViT-L/14** | Modern alternative, better texture sensitivity | 1024 | Medium |
| **CLIP ViT-L/14** | Text-conditioned generation, cross-modal | varies | Medium |
| **I3D** | Video quality (FVD) | 400 | Slow |
| **AlexNet** (LPIPS) | Perceptual similarity (paired) | spatial | Fast |
## Sample Count Strategy
```yaml
# Online (during training): fast directional signal
evaluation:
sample_fid_n: 5000
sample_fid_every: 20000 # steps
sample_fid_bs: 4 # must be <= training batch_size
# Offline (final benchmark): full standard count
num_fid_samples: 50000
```
Multi-GPU scaling:
```python
fid_batches = cfg.sample_fid_n // (cfg.sample_fid_bs * accelerator.num_processes)
# torchmetrics bug at >= 32 GPUs
if accelerator.num_processes >= 32:
cfg.sample_fid_n = min(cfg.sample_fid_n, 1000)
```
## Memory Management
```python
with torch.no_grad():
torch.cuda.empty_cache()
metric.reset()
for _ in range(n_batches):
samples = sample_fn(z, ema_model)
samples = accelerator.gather(samples.contiguous())
metric.update_fake(samples)
del samples, z
torch.cuda.empty_cache()
```
Key rules:
- `sample_fid_bs <= training batch_size` (or OOM)
- `torch.no_grad()` around entire eval block
- `del` + `empty_cache()` per batch during sampling
- `.contiguous()` before `accelerator.gather()`
## Anti-Patterns
- **Only computing FID**: Use multiple metrics. FID misses spatial structure (sFID), mode collapse (PRDC recall), memorization (AuthPct).
- **FID with 50K samples during training**: Use 5K for directional signal, 50K for final benchmarks only.
- **Using training model for sampling (not EMA)**: EMA produces better samples. Always use EMA for evaluation.
- **Forgetting `accelerator.gather()`**: Each GPU only sees local samples, metrics computed on partial data.
- **`normalize=True` with uint8 images**: torchmetrics expects [0,255] uint8 when `normalize=False`.
- **InceptionV3 for everything**: Consider DINOv2 (FDD) for modern benchmarks, I3D for video (FVD).
- **Ignoring memorization**: High-quality samples may be copied from training data. Add AuthPct or CT score.
- **FID at >=32 GPUs without workaround**: torchmetrics sync bug. Cap samples or verify manually.
## See Also
- `gpu-training-acceleration` — Memory management during evaluation sampling
- `wandb-experiment-tracking` — Logging evaluation metrics to W&BRelated Skills
ml-ablation-design
Use when designing ablation studies to compare model components, loss functions, or architectural choices. Covers synthetic data experiments, variant loops, production metrics, and W&B grouping. Triggers: "ablation", "ablation study", "variant comparison", "controlled experiment", "synthetic data experiment"
gpu-training-acceleration
Use when optimizing PyTorch training speed or memory on CUDA GPUs — global flags, torch.compile, fused optimizers, mixed precision, gradient checkpointing, kernel fusion, memory layout, or latent-space training. Applies to any PyTorch training workload. Triggers: "torch.compile", "TF32", "fused optimizer", "mixed precision", "bf16", "fp16", "gradient checkpointing", "Triton kernel", "CUDA flags", "GPU slow", "GPU memory"
youtube-wiki
Use when reading a YouTube video (especially an AI/ML interview, podcast, or technical talk) and producing a faithful, timestamped wiki entry the user can return to weeks later. Fetches the transcript via yt-dlp, sections by chapters or LLM-detected topics, summarizes per-section with parallel subagents, preserves verbatim quotes with speaker attribution, and runs a coverage test against the raw transcript. Triggers: "youtube wiki", "video wiki", "summarize this youtube", "watch this interview", "read this talk", "digest this video", "https://youtu.be/", "https://www.youtube.com/watch"
pdf-reader
Use when reading PDF papers, reports, or long documents where text, figures, and tables must all be captured and chunk-summarized without truncation. Converts PDF to a markdown + paper_content.json workspace, extracts figures and tables as standalone files, then delegates to arxiv-latex-reader's progressive two-layer reading (section index + on-demand deep reads). Triggers: "read pdf", "pdf to markdown", "summarize pdf", "pdf paper", "extract figures from pdf", "extract tables from pdf", "marker pdf", "pymupdf", "docling", "paper digest", "pdf reader"
insert-wiki
Use when capturing a single URL (X tweet, LinkedIn post, HN thread, short blog, news article, GitHub gist or issue) as a small persistent markdown entry the user can re-read later for motivation or grep across future sessions. Verbatim body + author + tags + a one-line "Why I saved this" hook. Writes to docs/wikis/YYYY-MM-DD-<slug>.md. WebFetch by default; CDP via Playwright MCP for login-walled hosts (x.com, twitter.com, linkedin.com). Redirects YouTube / arXiv / GitHub repo URLs to their specialized skills. Triggers: "insert wiki", "add to wiki", "insert this", "save this tweet", "capture this post", "add this to my wiki", "remember this link", "https://x.com/", "https://twitter.com/", "https://linkedin.com/posts/"
idea-feasibility
Use when evaluating whether a research or product idea is actually feasible — buildable, evaluable, and de-risked by available checkpoints, code, datasets, and GPU budget. Normalizes the idea, gathers primary-source evidence (arXiv, GitHub, project pages, model hosts), scores it against four mandatory hard gates, and emits a verdict + falsifiable MVP. Triggers: "idea feasibility", "is this idea feasible", "feasibility check", "can we do this", "is this practical", "worth pursuing", "评估想法可行性", "可行性分析", "这个 idea 能做吗", "这个想法靠谱吗"
idea-explore
Use when proposing new research ideas grounded in a seed paper or method — surfaces the gaps that the citation cone hasn't filled, the drawbacks the community already complains about in the official repo's GitHub issues, and the adjacent angles the literature suggests. Orchestrates followup-analysis (already-done exclusion), GitHub-issue mining (known drawbacks), and academic-deep-research (adjacent literature) into a ranked candidate-ideas report. Triggers: "idea explore", "idea-explore", "propose ideas", "explore ideas", "new directions", "research gaps", "what's missing", "build on this paper", "探索想法", "提出新想法", "研究空白"
idea-box
Use when promoting an idea from a fleeting thought into a tracked artifact with a lifecycle. Defines a per-idea on-disk directory (./idea_box/<slug>/) and a hard-gated state machine (explored → feasible/blocked → building → built/killed) that the existing reader/evaluator skills (idea-feasibility, ml-ablation-design, academic-deep-research, followup-analysis, arxiv-latex-reader, pdf-reader, github-reader, blog-reader) plug into. Public repo ships only the convention; idea data lives in the user's private idea-box repo. Triggers: "idea box", "idea-box", "new idea", "advance idea", "list ideas", "kill idea", "想法箱", "新想法", "推进想法", "列出想法"
github-reader
Use when reading a GitHub repository (especially a research code release with an accompanying paper) and producing a faithful digest that covers the implementation logic, the main insight, and the key reported results. Research-first with graceful fallback for non-paper repos. Handles arXiv link detection and delegates paper reading to arxiv-latex-reader / pdf-reader. Triggers: "read repo", "read this github", "analyze github", "digest repo", "github reader", "extract from github", "summarize this codebase", "read this code", "https://github.com/"
blog-reader
Use when reading a long technical blog post (ML research, engineering deep-dives, Distill/Lil'Log-style posts) and producing a faithful, figure-aware summary. Handles context-over-limit via section-based chunking, captures important figures via multimodal Read, and runs a coverage test to catch missing information. Triggers: "read this blog", "summarize this post", "read blog", "digest this article", "long blog post", "read this article", "blog summary", "distill post", "summarize url", "chunk and summarize"
arxiv-latex-reader
Use when reading large arxiv papers without context overflow. Progressive two-layer reading: index all sections (~2k tokens), then deep-read on demand. Never truncates. Triggers: "read paper", "paper sections", "section index", "progressive reading", "paper_content.json", "section summary"
academic-deep-research
Use when evaluating academic papers or surveying a research topic. Gathers venue, citations, GitHub stats, social buzz, reproducibility, and author signals to produce a scored markdown report. Triggers: "evaluate paper", "paper review", "research survey", "literature review", "is this paper good", "find papers on", "compare papers", "paper impact"