/** * Evaluation metrics. * * Two rules shape this module. * * First, aggregate accuracy is close to meaningless here. The label distribution is skewed, so a * classifier that guessed NEW_CONTENT for everything would score respectably while being useless. * Per label precision and recall, and the catastrophic counts, are what matter. * * Second, the cost of errors is asymmetric by roughly ten to one. So the headline number is recall * of genuine new content, measured in characters rather than blocks, because losing one long * paragraph is worse than losing one short line. */ import { type Label } from '../types'; export interface LabelledBlock { path: string; blockIndex: number; charCount: number; reference: Label; predicted: Label; /** Whether the prediction would actually be hidden from the reader. */ hidden: boolean; /** Grouping key for per segment breakdowns, for example the client or the language. */ group?: string; /** * Whether the extraction showed any text at all, across every part it emitted. The reference * covers only the part that was annotated, so without this a message whose annotated part is * rightly all history reads as empty even though its new content in another part is on * screen. That was 98 of the 100 empty extractions against the gpt-6-sol corpus reference. */ messageHasVisibleText?: boolean; } export interface LabelMetrics { label: Label; support: number; predicted: number; truePositives: number; precision: number; recall: number; f1: number; } export interface RetentionMetrics { /** Characters the reference calls authored by the sender. */ newContentChars: number; /** How many of those remain visible. This is the headline number. */ newContentCharsRetained: number; newContentCharRecall: number; /** Blocks the reference calls authored, and how many remain visible. */ newContentBlocks: number; newContentBlocksRetained: number; newContentBlockRecall: number; /** Of what was hidden, how much the reference agrees was history. */ hiddenChars: number; hiddenCharsGenuinelyHistory: number; hiddenPrecision: number; /** History the reference identified that is still on screen. */ historyChars: number; historyCharsStillVisible: number; historyStillVisibleShare: number; } export interface CatastrophicCounts { /** Messages where every authored block was hidden. */ allNewContentRemoved: number; /** Messages where an authored block inside an interleaved reply was hidden. */ inlineAnswerRemoved: number; /** Messages where quoted context was hidden while its answer stayed. */ inlineContextRemoved: number; /** Messages where forwarded content was hidden. */ forwardedDiscarded: number; /** Messages where the only visible content is a footer. */ onlyFooterRetained: number; /** Messages producing nothing visible from a non empty body. */ emptyExtraction: number; /** Messages where more than half the hidden characters were UNKNOWN in the reference. */ unknownHidden: number; messages: number; } export interface EvaluationReport { blocks: number; messages: number; exactAgreement: number; perLabel: LabelMetrics[]; confusion: Map; retention: RetentionMetrics; catastrophic: CatastrophicCounts; byGroup: { group: string; blocks: number; agreement: number; newContentCharRecall: number; historyHiddenShare: number; }[]; } export declare function evaluate(rows: readonly LabelledBlock[]): EvaluationReport; //# sourceMappingURL=metrics.d.ts.map