eval

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package eval measures how well the configured model scores against your interest profile. It has two entry points with different ground truth: benchmark re-scores a hand-authored fixture with the current profile and system prompt, answering "did my edit help"; audit reads the scores already recorded in the store, answering "what happened". Both are read-only and produce a report.

Index

Constants

View Source
const (
	MinScore = 0
	MaxScore = 10
)

Score bounds, matching what the scoring prompt asks for and what rank.ParseScores clamps to.

View Source
const (
	// DefaultLimit is how many store rows a bare `eval audit` samples. Small on
	// purpose: an audit is a look at a slice, and --all is there for the rest.
	DefaultLimit = 10
	// DefaultRepeats scores the fixture once. Raising it measures the noise
	// floor, which matters because ModelTuning carries no temperature or seed.
	DefaultRepeats = 1
)

Defaults for the flags that need one.

View Source
const (
	// WarnConstantScorer means the model answered with almost one value, which
	// makes every other number here an accident of where golden agreed with it.
	WarnConstantScorer = "constant_scorer"
	// WarnNoAgreement means kappa found no relationship to golden.
	WarnNoAgreement = "no_agreement"
	// WarnUnanswered means the model returned nothing for some samples.
	WarnUnanswered = "unanswered"
)

Warning codes. The code is what a script keys on; the text is for reading.

View Source
const HighSignalThreshold = rank.HighSignalScore

HighSignalThreshold is the score at or above which the feed page calls an item high signal: it earns the tier badge and counts toward the high-signal tile. Read from rank so the page and this cannot drift apart.

Nothing is hidden below it. Every scored item appears on the page and in the markdown digest whatever it scored, so this is a label the eye sorts by, not a filter.

View Source
const MinTagSamples = 3

MinTagSamples is the smallest group whose MAE is worth reading as a property of the group rather than of one article. Below it a tag's MAE is a single sample's error wearing the costume of a statistic.

Variables

View Source
var HigherIsBetter = map[string]bool{
	"qwk":                   true,
	"mae":                   false,
	"rmse":                  false,
	"high_signal.precision": true,
	"high_signal.recall":    true,
}

HigherIsBetter gives each headline metric its direction, so a renderer can orient a comparison without knowing what the metrics mean.

Only evaluative metrics belong here. Counts and spreads are diagnostic: a wider spread describes the model's consistency, not its quality, and putting it here would mislead any tool that auto-orients on this map.

View Source
var SweepThresholds = []int{3, 4, 5, 6, 7, 8, 9}

SweepThresholds are the cutoffs HighSignalSweep measures, bracketing HighSignalThreshold well on both sides so a model scoring far below the badge threshold still has rows to show. Below 3 nearly everything qualifies, so the rows stop saying anything.

One threshold cannot separate a model that ranks badly from one that ranks well and scores low: both flag nothing. Across a sweep they look nothing alike. Precision climbing as the cutoff rises means the ordering is sound and the cutoff is the only thing misplaced, which is a dial, not a model problem. Precision flat near the base rate at every cutoff means the ordering carries no signal and no cutoff will rescue it.

Functions

func QWK

func QWK(outcomes []Outcome) (float64, bool)

QWK is quadratic weighted kappa: agreement with golden, corrected for the agreement chance alone would produce. 1.0 is perfect, 0.0 is none beyond chance, below 0 is systematic disagreement. The quadratic weighting means a miss by 5 counts far more than five misses by 1.

It answers a question none of the other metrics can. MAE is in score units, so it depends on how the golden scores are spread and cannot be compared across fixtures; QWK is scale-free and comparable. It is also the metric that catches a degenerate model outright, because a scorer that answers with one constant agrees with chance exactly and lands at 0 however respectable its MAE looks.

The second return is false when kappa is undefined, which happens when either side used a single value throughout and there is no expected disagreement to correct against.

Reported alongside the sample count on purpose: with eleven score categories, kappa is volatile on a small fixture and settles as the fixture grows.

Types

type AuditOptions

type AuditOptions struct {
	// RatedOnly keeps only rows carrying a user_score, so the report is built
	// from items you actually judged. A missing user_note is fine.
	RatedOnly bool
	// Source and ScoredBy narrow to one feed and one scoring model. Scores also
	// retain profile provenance, but audit currently filters only model
	// provenance; a sample spanning models can otherwise mix incomparable rows.
	Source   string
	ScoredBy string

	// After bounds the window, resolved from --since. Zero means unbounded.
	After time.Time

	// Limit caps the sample. All takes every matching row and ignores Limit.
	Limit int
	All   bool
	// Seed makes the random draw reproducible. Zero draws fresh each run.
	Seed int64
	// Newest orders by recency instead of sampling randomly. Off by default:
	// "the most recent N" is biased toward whichever feeds ran last, which
	// quietly makes the report describe your fetch schedule instead of your feed.
	Newest bool

	// ShowWhy adds the stored model reason and user note beside each sample.
	ShowWhy bool

	Output Output
}

AuditOptions is a resolved `eval audit` invocation: read what the store already recorded. No model is involved.

type BenchmarkOptions

type BenchmarkOptions struct {
	// Path is the golden dataset to load.
	Path string
	// Repeats scores the fixture this many times. Above 1 the report gains a
	// spread, which is the only way to tell a real change from run-to-run jitter.
	Repeats int
	// Limit scores only the first Limit samples, in file order. Zero scores
	// them all. File order rather than a draw, so a limited run stays
	// comparable to the limited run before it.
	Limit int

	// Provider, Host and Model override the configured backend when non-empty,
	// so a bigger local model can be measured without editing the config.
	Provider string
	Host     string
	Model    string

	// BatchSize and MaxParallel override the configured values. Zero keeps the
	// config's, which is the default because a benchmark that batched
	// differently from ingest would measure something the live pipeline never
	// does. Overriding is for a backend ingest never uses, where matching it
	// buys nothing and a bigger batch is faster and cheaper.
	BatchSize   int
	MaxParallel int
	// Think mirrors the resolved inference.think for this run.
	Think bool

	// ShowWhy adds the model's reason and your golden note beside each sample.
	// The samples themselves are listed either way.
	ShowWhy bool

	Output Output
}

BenchmarkOptions is a resolved `eval benchmark` invocation: score a fixture with the current profile and system prompt, and compare against its labels.

type Dataset

type Dataset struct {
	Metadata Metadata `yaml:"metadata"`
	// Tags maps each declared tag to its one-line description, which the
	// report prints beside the group.
	Tags    map[Tag]string `yaml:"tags"`
	Samples []Sample       `yaml:"samples"`

	// Hash fingerprints the file this was read from, so a report can prove
	// which fixture produced it. Set by Load, never read from the YAML.
	Hash string `yaml:"-"`
}

Dataset is a parsed and validated benchmark file.

func Load

func Load(path string) (*Dataset, error)

Load reads and validates the benchmark at path.

Decoding is strict: an unknown key is an error rather than a silently ignored one. This is test data, and a misspelled key that fell back to a zero value would leave the benchmark quietly measuring something else.

func (*Dataset) Items

func (d *Dataset) Items() []feeds.Item

Items converts the samples into the type the scorer takes.

Only Source, Title and Summary are carried, because those are the only fields rank.BuildUserPrompt puts in front of the model. Everything else on a Sample is for the report, and passing it here would make a benchmark sample behave unlike the live item it stands in for.

func (*Dataset) Limit

func (d *Dataset) Limit(n int) *Dataset

Limit returns a copy holding only the first n samples, in file order, or the dataset itself when n is not a narrowing.

File order rather than a random draw, so two runs either side of a profile edit score the same samples and the difference between them means something. Hash is carried over unchanged: it fingerprints the file, not the slice, and RunInfo records the narrowing separately.

type Format

type Format string

Format is how a report is rendered.

const (
	// FormatText is the terminal report and the default: aligned columns, no
	// markup, the same bytes whether it lands on a TTY or in a file.
	FormatText Format = "text"
	// FormatMarkdown is the same report as a document, for pasting into an
	// issue or a pull request.
	FormatMarkdown Format = "markdown"
	// FormatJSON is the machine-readable results file. Two of these can be
	// diffed to answer whether a profile or prompt edit moved the numbers.
	FormatJSON Format = "json"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates a --format value.

type HighSignal

type HighSignal struct {
	Threshold int `json:"threshold"`
	// Flagged is how many the model marks high signal; Wanted how many golden
	// puts at or above the threshold.
	Flagged int `json:"n_flagged"`
	Wanted  int `json:"wanted"`
	// Hit was flagged and wanted, Noise flagged and not wanted, Missed wanted
	// and not flagged.
	Hit    int `json:"hit"`
	Noise  int `json:"noise"`
	Missed int `json:"missed"`
	// Precision and Recall are nil when undefined: precision when nothing was
	// flagged, recall when nothing was wanted. Zero would be a different claim.
	Precision *float64 `json:"precision"`
	Recall    *float64 `json:"recall"`

	// Scored is how many samples the threshold was applied to, and BaseRate the
	// precision a scorer picking at random would reach at it (Wanted/Scored).
	//
	// Precision alone is unreadable without it, and the base rate moves with the
	// threshold: nearly everything clears a low cutoff, so a high precision
	// there is arithmetic rather than skill. Comparing every row against one
	// global base rate would credit exactly that.
	Scored   int      `json:"n_scored"`
	BaseRate *float64 `json:"base_rate"`
}

HighSignal measures the one judgement the product publishes: which items it puts the high-signal badge on.

This is the only metric here stated in terms a reader feels. MAE is a proxy: a model can be two points off everywhere and still pick out exactly the right articles, or be close on average and still badge all the wrong ones.

func HighSignalAt

func HighSignalAt(outcomes []Outcome, threshold int) HighSignal

HighSignalAt measures precision and recall at a score threshold.

func HighSignalSweep

func HighSignalSweep(outcomes []Outcome) []HighSignal

HighSignalSweep measures precision and recall at each of SweepThresholds, so the cutoff can be read as the dial it is rather than assumed correct.

type HistBucket

type HistBucket struct {
	Err   int `json:"err"`
	Count int `json:"count"`
}

HistBucket is one signed-error column.

type Metadata

type Metadata struct {
	Name    string `yaml:"name"`
	Version int    `yaml:"version"`
}

Metadata identifies the benchmark.

type MetricInfo

type MetricInfo struct {
	Key   string
	Label string
	Min   float64
	Max   float64
	Best  float64
	About string
}

MetricInfo describes one metric so every renderer says the same thing about it. It says what the metric measures and where it sits, never whether the number is good: that reading belongs to whoever is looking at the feed.

Best is the value the metric is best at, which is where the direction comes from: equal to Max means higher is better, equal to Min means lower is, and anything between means aim for it.

func (MetricInfo) Range

func (m MetricInfo) Range() string

Range renders the bounds and the direction as one cell, e.g. "-1..1 up".

type Metrics

type Metrics struct {
	// Samples is every outcome, Scored those the model answered, Missing the
	// rest. Samples == Scored + Missing.
	Samples int
	Scored  int
	Missing int

	// MAE is the mean unsigned distance from golden, over scored samples.
	// Lower is better, 0 is exact agreement.
	MAE float64
	// RMSE penalises a large miss more than several small ones, so it separates
	// a model that is uniformly a bit off from one that is usually right and
	// occasionally catastrophic. MAE alone rates those the same.
	RMSE float64
	// SignedMean is the mean signed distance. Near zero with a high MAE means
	// the model is noisy; consistently positive or negative means it is
	// systematically generous or harsh, which is a different fix.
	SignedMean float64

	// Histogram counts scored samples by signed error, so the shape of the
	// disagreement is visible rather than just its average.
	Histogram map[int]int
}

Metrics summarises how close a set of outcomes came to their labels.

There is deliberately no pass/fail count. An exact match is not a meaningful bar: a 9 answered as an 8 is not a defect, and with no temperature or seed in ModelTuning no score repeats reliably anyway. Distance is what carries signal.

func Compute

func Compute(outcomes []Outcome) Metrics

Compute summarises outcomes. Missing ones are counted and otherwise left out: they are an absence of evidence, not evidence of a wrong score.

func (Metrics) Within

func (m Metrics) Within(n int) int

Within counts scored samples whose score landed no further than n from the label. Reported across several n rather than against one threshold, so no tolerance has to be argued for.

type Outcome

type Outcome struct {
	Sample Sample
	// Score is the model's 0-10, meaningful only when Scored.
	Score int
	// Reason is the model's stated rationale, carried for the report.
	Reason string
	// Scored is false when the model returned nothing for this sample.
	//
	// This case has to be tracked rather than defaulted. rank.ScoreAll drops
	// items it could not score instead of failing (internal/rank/rank.go), so a
	// benchmark that read a missing entry as the zero value would score an
	// unanswered sample as 0, which is a real verdict, and quietly credit
	// itself for agreeing with any sample expecting a low score.
	Scored bool
}

Outcome is one sample and what the model did with it.

func Worst

func Worst(outcomes []Outcome, n int) []Outcome

Worst returns up to n scored outcomes, furthest from their label first, so the report can print the disagreements alongside the note explaining what you meant. Ties break by id to keep runs comparable.

func (Outcome) AbsErr

func (o Outcome) AbsErr() int

AbsErr is the unsigned distance from the label.

func (Outcome) Err

func (o Outcome) Err() int

Err is the signed distance from golden: positive when the model scored higher. Meaningless unless Scored.

type Output

type Output struct {
	Format Format
	// Path is the file to write. Empty means stdout.
	Path string
}

Output is where a report goes and in what shape, shared by both subcommands.

type RenderOptions

type RenderOptions struct {
	Format Format
	// ShowWhy adds the model's stated reason and the golden note beside every
	// sample. Off by default: the sample list is a scan, not a read.
	ShowWhy bool
}

RenderOptions is everything a renderer needs. Where the bytes end up is the caller's problem, so there is no path here.

type Report

type Report struct {
	SchemaVersion int             `json:"schema_version"`
	Info          RunInfo         `json:"config"`
	Timing        TimingBlock     `json:"timing"`
	Results       ResultsBlock    `json:"results"`
	ByTag         []TagRow        `json:"by_tag"`
	Samples       []SampleRow     `json:"samples"`
	Spread        *SpreadBlock    `json:"spread,omitempty"`
	Warnings      []Warning       `json:"warnings"`
	Rated         map[string]bool `json:"higher_is_better"`
}

Report is the computed result of a benchmark run and the single source every renderer draws from. The renderers are pure functions of this shape: they compute nothing of their own, so adding a fourth costs nothing here.

func Summarize

func Summarize(res *Results, ds *Dataset) *Report

Summarize computes the report from a run.

The headline metrics describe the first run only; extra repeats feed Spread and nothing else. Pooling them would change what MAE means, mixing how hard a sample is with how much the model wavers on it, and the two want different fixes.

func (*Report) Write

func (r *Report) Write(w io.Writer, opt RenderOptions) error

Write renders the report in the requested format. Where the bytes go is the caller's business: this only ever writes to w.

func (*Report) WriteJSON

func (r *Report) WriteJSON(w io.Writer) error

WriteJSON writes the machine-readable report.

Every number the other renderers show lives under results, at a stable key, so a script reads .results.qwk rather than hunting for a label. The metric descriptions are deliberately not here: they are wording for a reader, they would need keeping in step with results, and nothing consumes them.

The config block is provenance rather than something to diff — it carries a timestamp and an elapsed time that differ on every run by design.

func (*Report) WriteMarkdown

func (r *Report) WriteMarkdown(w io.Writer, opt RenderOptions) error

WriteMarkdown renders the report as a document, for pasting into an issue or a pull request. Same sections and same order as the text report; only the styling differs, and it derives nothing of its own.

func (*Report) WriteText

func (r *Report) WriteText(w io.Writer, opt RenderOptions) error

WriteText renders the report for a terminal: aligned columns, no markup, no colour, and the same bytes whether it lands on a TTY or in a file.

It builds the whole report before writing a byte, so a failed write leaves no half-rendered file behind.

type Results

type Results struct {
	Info RunInfo
	Runs [][]Outcome
	// RunSeconds is how long each repeat took, parallel to Runs. Recorded
	// because the decision --model exists to serve is quality against speed,
	// and a report carrying only the quality half answers half the question.
	RunSeconds []float64
}

Results is the raw output of a run: one slice of outcomes per repeat.

func Run

func Run(ctx context.Context, cfg RunConfig) (*Results, error)

Run scores the fixture Repeats times and pairs every score back to its label.

It never writes to the store and never mutates the dataset.

type ResultsBlock

type ResultsBlock struct {
	Samples int `json:"n_samples"`
	Scored  int `json:"n_scored"`
	// Missing counts samples the model returned nothing for. They are excluded
	// from every metric below rather than read as a zero score.
	Missing int `json:"n_unanswered"`

	MAE        float64 `json:"mae"`
	RMSE       float64 `json:"rmse"`
	SignedMean float64 `json:"signed_mean"`

	// QWK is chance-corrected agreement, nil when undefined. Unlike MAE it does
	// not depend on how the golden scores are spread, so it is the number that
	// compares across fixtures and the one that exposes a constant scorer.
	QWK *float64 `json:"qwk"`

	// HighSignal is precision and recall at the mark the feed page badges as
	// high signal. Nothing is hidden below it, so this measures what the badge
	// claims rather than what reaches the page.
	HighSignal HighSignal `json:"high_signal"`
	// HighSignalSweep is the same measurement at marks either side of it, which
	// is what separates a model that ranks badly from one that ranks well and
	// scores low. At a single mark the two are indistinguishable.
	HighSignalSweep []HighSignal `json:"high_signal_sweep"`

	// Within maps a distance to how many samples landed inside it.
	Within map[string]int `json:"within"`
	// Histogram is the signed error distribution, ascending, ready to plot.
	Histogram []HistBucket `json:"histogram"`

	// ScoreSpread counts how many samples got each score, and LabelSpread the
	// same for golden.
	//
	// A model that answers with only one or two distinct scores is not
	// discriminating at all, and every other metric here is then measuring an
	// accident: it will look accurate wherever golden happens to agree with
	// its one answer. Nothing else in the report shows that.
	ScoreSpread []ScoreBucket `json:"score_spread"`
	LabelSpread []ScoreBucket `json:"label_spread"`
}

ResultsBlock is the headline set.

type RunConfig

type RunConfig struct {
	Dataset *Dataset
	// Profile is the interest profile under test, passed to the scorer verbatim.
	Profile string
	// Prompt is the effective system prompt under test, empty when disabled.
	Prompt string
	Scorer rank.Scorer

	// BatchSize and MaxParallel come from the main config rather than being
	// forced to 1. A batched model sees the other articles in its context and
	// scores relative to them, so a benchmark that batched differently from
	// ingest would measure something the live pipeline never does.
	BatchSize   int
	MaxParallel int

	// Repeats scores the fixture this many times. Runs past the first exist to
	// measure the noise floor, not to improve the estimate.
	Repeats int

	// DatasetSamples is what the golden file holds before --limit narrowed it.
	// Zero means the run used the whole file.
	DatasetSamples int
	// Limit is the --limit that produced Dataset, recorded so a partial run is
	// not read as a full one.
	Limit int

	// Identity of the run, recorded so two reports can be compared.
	Provider string
	Model    string
	Think    bool
}

RunConfig is everything a benchmark run needs.

type RunInfo

type RunInfo struct {
	Benchmark   string    `json:"benchmark"`
	StartedAt   time.Time `json:"run_started_at"`
	Provider    string    `json:"provider"`
	Model       string    `json:"model"`
	Think       bool      `json:"think"`
	BatchSize   int       `json:"batch_size"`
	MaxParallel int       `json:"max_parallel"`
	Repeats     int       `json:"repeats"`
	ProfileHash string    `json:"profile_hash"`
	PromptHash  string    `json:"prompt_hash"`
	DatasetHash string    `json:"dataset_hash"`

	// ElapsedSeconds is the wall clock across every repeat. Seconds rather than
	// a Duration so the JSON stays readable and comparable, as go test -json does.
	ElapsedSeconds float64 `json:"elapsed_seconds"`

	// DatasetSamples is what the golden file holds; the report's own sample
	// count is what this run scored. They differ under Limit.
	//
	// Both are recorded because DatasetHash cannot tell them apart: it
	// fingerprints the file, so a limited run and a full one over the same file
	// would otherwise look equally authoritative.
	DatasetSamples int `json:"dataset_samples"`
	Limit          int `json:"limit,omitempty"`
}

RunInfo identifies what produced a report: which model, which profile, which golden file, and how long it took.

The three hashes are the point: without them "did my profile edit help" is unanswerable, because there is nothing to prove the two runs differed only in the way you think they did.

This block is provenance, not something to diff. StartedAt and ElapsedSeconds differ on every run by design, so comparing two reports means comparing results and reading config to check the two runs were comparable at all.

func (RunInfo) Duration

func (i RunInfo) Duration() time.Duration

Duration is ElapsedSeconds as a Duration, for Go callers and the renderers.

type Sample

type Sample struct {
	ID      string `yaml:"id"`
	Source  string `yaml:"source"`
	Title   string `yaml:"title"`
	Summary string `yaml:"summary"`
	// Expected is the 0-10 the model should land on. A pointer so that an
	// omitted key is distinguishable from a deliberate 0, which is a real
	// score and the one a missing field would otherwise silently impersonate.
	// Load guarantees it is non-nil; use ExpectedScore.
	Expected *int `yaml:"expected_llm_score"`
	// Tags are the groups this sample belongs to in the report.
	Tags []Tag `yaml:"tags"`
	// Note is the author's reasoning, printed beside the sample when it fails.
	Note string `yaml:"note"`
}

Sample is one labelled article. Field names track the items table, since a sample stands in for a real row.

func (Sample) ExpectedScore

func (s Sample) ExpectedScore() int

ExpectedScore is the score the sample should receive. Valid on any sample that came from Load.

type SampleRow

type SampleRow struct {
	ID       string   `json:"id"`
	Source   string   `json:"source,omitempty"`
	Title    string   `json:"title"`
	Tags     []string `json:"tags,omitempty"`
	Expected int      `json:"expected_llm_score"`
	// Score and Err are meaningless when Scored is false.
	Scored bool   `json:"scored"`
	Score  int    `json:"llm_score"`
	Err    int    `json:"err"`
	Reason string `json:"llm_score_reason,omitempty"`
	Note   string `json:"note,omitempty"`
}

SampleRow is one sample and what the model did with it. Every sample appears, not only the disagreements, so a renderer can show the whole table.

type ScoreBucket

type ScoreBucket struct {
	Score int `json:"score"`
	Count int `json:"count"`
}

ScoreBucket counts samples at one score.

type Spread

type Spread struct {
	Runs int
	// MAEMin and MAEMax bound the aggregate across runs.
	MAEMin, MAEMax float64
	// WidestSample is the largest gap between the highest and lowest score any
	// single sample was given across runs, and the id it belongs to.
	WidestSample   int
	WidestSampleID string
}

Spread reports how much repeated runs of the same fixture disagreed with each other. It is the noise floor, and nothing smaller than it should be read as a result: ModelTuning carries no temperature or seed, so two identical runs are not expected to agree, and a profile edit that moves MAE by less than the spread has not been shown to do anything.

func SpreadOf

func SpreadOf(runs [][]Outcome) Spread

SpreadOf measures the disagreement across repeated runs. Each element of runs is one full pass over the fixture. Fewer than two runs measures nothing.

type SpreadBlock

type SpreadBlock struct {
	Runs      int       `json:"runs"`
	MAEPerRun []float64 `json:"mae_per_run"`
	MAEMin    float64   `json:"mae_min"`
	MAEMax    float64   `json:"mae_max"`
	// RunSeconds is how long each repeat took, parallel to MAEPerRun, so the
	// noise floor shows what the consistency cost in time.
	RunSeconds     []float64 `json:"run_seconds,omitempty"`
	WidestSample   int       `json:"widest_sample_swing"`
	WidestSampleID string    `json:"widest_sample_id,omitempty"`
}

SpreadBlock reports run-to-run disagreement, present only with repeats.

type Tag

type Tag string

Tag is an evaluation parameter: it groups samples so the report can be sliced by whatever distinction matters to you. The vocabulary belongs to the benchmark file rather than to this package, since which distinctions are worth measuring depends on the profile being tested. A fixture declares its own tags and this loader only checks that samples use ones that were declared.

Not to be confused with items.tags in the store, which is feed-owned metadata on real rows. These exist only for the benchmark and never reach the model.

type TagMetrics

type TagMetrics struct {
	Tag Tag
	// Description is the tag's line from the fixture, printed beside the group.
	Description string
	Metrics
}

TagMetrics is one tag's slice of the run.

func ByTag

func ByTag(outcomes []Outcome, descriptions map[Tag]string) []TagMetrics

ByTag groups outcomes by tag and summarises each, worst MAE first so the group needing attention reads first. A sample carrying several tags counts toward each, so the groups overlap by design.

This is where a bad number becomes an actionable one: a poor overall MAE says only that scoring is off, while one tag standing out says which kind of article it is off about.

Groups under MinTagSamples sort after every full one regardless of MAE. The ordering exists to put what needs attention at the top, and a one-sample group taking that slot from a real one inverts the purpose: it promotes the noisiest row in the table precisely because it is the noisiest.

func (TagMetrics) Thin

func (t TagMetrics) Thin() bool

Thin reports whether the group is too small for its MAE to mean anything.

type TagRow

type TagRow struct {
	Tag         string  `json:"tag"`
	Description string  `json:"description,omitempty"`
	Samples     int     `json:"n_samples"`
	Scored      int     `json:"n_scored"`
	MAE         float64 `json:"mae"`
	SignedMean  float64 `json:"signed_mean"`
	// Thin marks a group too small for its MAE to describe the group rather
	// than one article. Carried rather than recomputed so both renderers, and
	// anything reading the JSON, draw the same line.
	Thin bool `json:"thin"`
}

TagRow is one tag's slice of the run.

type TimingBlock

type TimingBlock struct {
	Seconds float64 `json:"seconds"`
	// PerSample is Seconds over the samples attempted, which is the figure that
	// carries over to a real ingest of a different size.
	PerSample float64 `json:"seconds_per_sample"`
}

TimingBlock is what the run cost in wall clock, for the headline run only.

Quality is half of the choice --model exists to make: a model twice as good and twenty times slower is not obviously the right one, and without this the report cannot be used to decide.

type Warning

type Warning struct {
	Code string `json:"code"`
	// Text is plain prose. It carries no Markdown and no terminal styling, so
	// that each renderer can apply its own and the same string stays correct in
	// all three.
	Text string `json:"text"`
}

Warning is something about the run that undermines reading the rest of it. These are the only judgements the report makes: everything else states what a metric measures and leaves the verdict to whoever is reading.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL