rust_metrics
rust_metrics is a rust-native evaluation toolkit that provides incremental metrics for
classification and text generation pipelines. Each metric implements the same incremental
Metric trait, so you can feed batched predictions over time and ask for the final score when
ready.
Getting started
Add the crate to your project:
# or enable the BERT-based similarity metric
Evaluate batched predictions:
use ;
let predictions = ;
let targets = ;
let mut accuracy = new;
accuracy.update.unwrap;
assert_eq!;
let scores = ;
let mut auroc = new; // 0 => compute exact ROC AUC
auroc.update.unwrap;
assert!;
Available metrics
Classification
BinaryAccuracy,MulticlassAccuracy,MultilabelAccuracyBinaryPrecision,BinaryRecallBinaryHingeBinaryAuroc(exact or binned ROC AUC)
Text
Bleuwith optional smoothing and arbitrary n-gram depthEditDistancewith sum or mean reductionSentenceEmbeddingSimilarity(requires thetext-bertfeature) backed byfastembed. This metric embeds each sentence pair with lightweight BERT embeddings and reports cosine similarity scores.
Feature flags
| Feature | Default | Description |
|---|---|---|
text-bert |
no | Enables BERT sentence embedding similarity via fastembed. |