windlass.providers.evaluation.builtin¶
builtin
¶
Built-in evaluation metrics.
Two families, deliberately separated:
Lexical metrics need no model and no dependencies. They are fast, free and
deterministic, which makes them the right choice for CI regression gates:
exact_match, f1, rouge_l, answer_relevancy_lexical,
context_precision_lexical, context_recall_lexical.
LLM-judged metrics need a judge model and cost tokens, but measure things
lexical overlap cannot: faithfulness (is the answer supported by the
retrieved context?), answer_relevancy, answer_correctness,
context_relevancy.
Faithfulness is the one to watch. It is the direct measure of hallucination in a RAG system, and it is the metric that catches a retrieval regression before your users do.
Example
from windlass.interfaces.evaluator import EvalSample ev = BuiltinEvaluator(metrics=["exact_match", "f1"]) report = ev.evaluate([EvalSample(question="q", answer="the cat", reference="the cat")]) report.summary["exact_match"], report.summary["f1"] (1.0, 1.0)
BuiltinEvaluator
¶
BuiltinEvaluator(
*,
metrics: Sequence[str] | None = None,
threshold: float = 0.5,
llm: Any = None,
concurrency: int | None = None,
**config: Any
)
Bases: Evaluator
Windlass's own evaluation metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
Sequence[str] | None
|
Metric names from :data: |
None
|
threshold
|
float
|
Score at or above which a result passes. |
0.5
|
llm
|
Any
|
Judge model. Required only for :data: |
None
|
concurrency
|
int | None
|
Maximum simultaneous sample evaluations. |
None
|
**config
|
Any
|
Forwarded to :class: |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For an unknown metric name. |
EvaluationError
|
When a judged metric is requested with no judge model. |
Performance
Lexical metrics are pure Python and effectively free. Each judged metric costs one model call per sample, so a 4-metric run over 500 samples is 2,000 calls — batch it and use a small judge model.
Source code in src\windlass\providers\evaluation\builtin.py
default_metrics
classmethod
¶
Return the default metric set: lexical only, so no model is needed.
available_metrics
classmethod
¶
aevaluate_sample
async
¶
Score one sample against every configured metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
EvalSample
|
The interaction to score. |
required |
Returns:
| Type | Description |
|---|---|
list[EvaluationResult]
|
One result per metric. A metric whose inputs are missing (a |
list[EvaluationResult]
|
reference-based metric with no reference) is skipped rather than |
list[EvaluationResult]
|
scored zero, so averages stay honest. |