svgtext-metric-scores
Generated-text scores per row
How do overlap scores spread across rows, metric by metric (and system by system)?
How to read it
- Read each column as one metric: dots are rows, the box spans the middle half and the thick line is the median.
- Compare systems side by side within a metric; the spread shows how uneven the outputs are.
- Look for rows scoring near zero: they often hold a correct answer worded differently, or a real failure worth reading.
- Callout 1: A box: the middle half of the rows for one metric and system.
- Callout 2: Low-scoring rows worth reading.
- Callout 3: Systems side by side within a metric.
Watch out
- Corpus BLEU pools counts across rows, so it is not the median or mean of these dots.
- Overlap metrics reward wording, not meaning; read a sample of the outputs before deciding.
Defaults
No settings: the chart draws one way.
Pinned in the code
- Draws what the Python or R engine computed; the chart computes nothing statistical.
- Row-level BLEU uses the effective n-gram order and exponential smoothing (sacreBLEU's sentence_bleu); corpus BLEU pools n-gram counts and is not the mean of these dots.
- Boxes show the type-7 quartiles and the median; horizontal jitter is a fixed hash of the row, so the picture is the same every time.
- Overlap metrics reward shared wording: a correct paraphrase can score low, so read the spread beside a human or LLM-as-judge review.
# Generated-text scores per row — Codesplash Chart Lab (recipe "text-metric-scores")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
df = pd.read_csv("text-metric-scores-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["metric"] = pd.Categorical(df["metric"].astype("string"), categories=["BLEU", "chrF", "ROUGE-1", "ROUGE-2", "ROUGE-L"])
df["system"] = pd.Categorical(df["system"].astype("string"), categories=["baseline", "fine-tuned"])
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
def levels_of(s):
"""Declared level order (categoricals), else order of first appearance."""
if isinstance(s.dtype, pd.CategoricalDtype):
return [v for v in s.cat.categories if (s == v).any()]
return list(dict.fromkeys(s.dropna().astype(str)))
M = "metric"
SCORE = "score"
SYS = "system"
d = df.dropna(subset=[M, SCORE])
metrics = levels_of(d[M])
systems = levels_of(d[SYS]) if SYS else [None]
rng = np.random.default_rng(1) # the app uses a fixed hash; any fixed jitter shows the same spread
fig, ax = plt.subplots(figsize=(8, 4.5))
slot = 0.8 / len(systems)
for j, s in enumerate(systems):
for i, m in enumerate(metrics):
v = d.loc[(d[M].astype(str) == m) & ((d[SYS].astype(str) == str(s)) if SYS else True), SCORE].to_numpy()
if not len(v):
continue
x = i - 0.4 + slot * (j + 0.5)
ax.scatter(x + (rng.random(len(v)) - 0.5) * slot * 0.7, v, s=8, alpha=0.35, color=PALETTE[j % len(PALETTE)], label=s if i == 0 else None)
ax.boxplot([v], positions=[x], widths=slot * 0.5, showfliers=False, whis=0, medianprops=dict(color="black"))
ax.set_xticks(range(len(metrics)), metrics)
ax.set_ylim(0, 100)
ax.set_ylabel("score (0–100)")
if SYS:
ax.legend(title=SYS, fontsize=8)
ax.set_title("Score of each row, by metric")
plt.show()Needs pandas, numpy, matplotlib · reads text-metric-scores-demo.csv · app theme from the optional codesplash helper
# Generated-text scores per row — Codesplash Chart Lab (recipe "text-metric-scores")
# controls: defaults
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
df = pd.read_csv("text-metric-scores-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["metric"] = pd.Categorical(df["metric"].astype("string"), categories=["BLEU", "chrF", "ROUGE-1", "ROUGE-2", "ROUGE-L"])
df["system"] = pd.Categorical(df["system"].astype("string"), categories=["baseline", "fine-tuned"])
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
def levels_of(s):
"""Declared level order (categoricals), else order of first appearance."""
if isinstance(s.dtype, pd.CategoricalDtype):
return [v for v in s.cat.categories if (s == v).any()]
return list(dict.fromkeys(s.dropna().astype(str)))
M = "metric"
SCORE = "score"
SYS = "system"
d = df.dropna(subset=[M, SCORE])
systems = levels_of(d[SYS]) if SYS else [None]
fig = go.Figure()
for j, s in enumerate(systems):
m = (d[SYS].astype(str) == str(s)) if SYS else np.ones(len(d), bool)
fig.add_box(x=d.loc[m, M], y=d.loc[m, SCORE], name=str(s) if s is not None else "rows", boxpoints="all", jitter=0.5,
pointpos=0, marker=dict(size=4, opacity=0.4, color=PALETTE[j % len(PALETTE)]), line=dict(color=PALETTE[j % len(PALETTE)]))
fig.update_layout(boxmode="group", yaxis=dict(range=[0, 100], title="score (0–100)"), title="Score of each row, by metric")
fig.update_xaxes(categoryorder="array", categoryarray=levels_of(d[M]))
fig.show()Needs pandas, numpy, plotly · reads text-metric-scores-demo.csv · app theme from the optional codesplash helper
# Generated-text scores per row — Codesplash Chart Lab (recipe "text-metric-scores")
# controls: defaults
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
df <- read.csv("text-metric-scores-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["metric"]] <- factor(df[["metric"]], levels = c("BLEU", "chrF", "ROUGE-1", "ROUGE-2", "ROUGE-L"))
df[["system"]] <- factor(df[["system"]], levels = c("baseline", "fine-tuned"))
tok <- if (has_cs) codesplashr::cs_palette(dark = FALSE) else list()
seq_ramp <- if (is.null(tok$sequential)) c("#eff6fd", "#1a469d") else tok$sequential # low → high
div_ramp <- if (is.null(tok$diverging)) c("#c13e2e", "#f3f5f8", "#0859ac") else tok$diverging # −, 0, +
ref_col <- if (is.null(tok$reference)) "#4e5661" else tok$reference
grey_col <- if (is.null(tok$dim)) "#ced1d6" else tok$dim
levels_of <- function(v) if (is.factor(v)) levels(droplevels(v)) else unique(as.character(v[!is.na(v)]))
m_col <- "metric"
score_col <- "score"
sys_col <- "system"
d <- df[!is.na(df[[m_col]]) & !is.na(df[[score_col]]), ]
d$metric <- factor(as.character(d[[m_col]]), levels = levels_of(d[[m_col]]))
ks <- if (is.null(sys_col)) "rows" else levels_of(d[[sys_col]])
d$sys <- factor(if (is.null(sys_col)) "rows" else as.character(d[[sys_col]]), levels = ks)
set.seed(1) # fixed jitter
p <- ggplot(d, aes(x = metric, y = .data[[score_col]], colour = sys)) +
geom_point(position = position_jitterdodge(jitter.width = 0.25, dodge.width = 0.8), alpha = 0.35, size = 1.2) +
geom_boxplot(position = position_dodge(width = 0.8), width = 0.35, fill = NA, outlier.shape = NA, coef = 0, colour = "grey20") +
scale_colour_manual(values = setNames(rep_len(cs_cat, length(ks)), ks)) +
scale_y_continuous(limits = c(0, 100)) +
labs(x = NULL, y = "score (0–100)", colour = sys_col, title = "Score of each row, by metric") + theme_cs
print(p)Needs ggplot2 · reads text-metric-scores-demo.csv · app theme from the optional codesplashr helper