@mastra/evals 1.10.9-alpha.0 → 1.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-evals-completeness.md +5 -1
- package/dist/docs/references/reference-evals-context-precision.md +3 -1
- package/dist/docs/references/reference-evals-faithfulness.md +5 -5
- package/dist/scorers/prebuilt/index.cjs +1 -1
- package/dist/scorers/prebuilt/index.cjs.map +1 -1
- package/dist/scorers/prebuilt/index.js +1 -1
- package/dist/scorers/prebuilt/index.js.map +1 -1
- package/package.json +7 -7
package/dist/docs/SKILL.md
CHANGED
|
@@ -79,7 +79,11 @@ The scorer evaluates completeness through linguistic element coverage analysis.
|
|
|
79
79
|
- Exact matches for short terms (≤3 chars)
|
|
80
80
|
- Substantial overlap (>60%) for longer terms
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
When the input yields no elements, the scorer returns `1` if the output also has no elements and `0` otherwise.
|
|
83
|
+
|
|
84
|
+
Final score: `covered_elements / total_input_elements`
|
|
85
|
+
|
|
86
|
+
The completeness scorer has no `scale` option. The score is always between 0 and 1.
|
|
83
87
|
|
|
84
88
|
### Score interpretation
|
|
85
89
|
|
|
@@ -30,7 +30,9 @@ Use when optimizing context selection for:
|
|
|
30
30
|
|
|
31
31
|
**options** (`ContextPrecisionMetricOptions`): Configuration options for the scorer
|
|
32
32
|
|
|
33
|
-
Either `context` or `contextExtractor` must be provided.
|
|
33
|
+
Either `context` or `contextExtractor` must be provided. `contextExtractor` is only called when the run input and output have agent shapes: the input has `inputMessages`, `rememberedMessages` and `systemMessages` arrays plus a `taggedSystemMessages` object, and the output is an array of messages. For any other input/output shape the scorer uses `context`. When neither is provided, the scorer throws.
|
|
34
|
+
|
|
35
|
+
If you pass `context`, the array must be non-empty. The constructor throws `Context array cannot be empty if provided` even when `contextExtractor` is also configured. When only `contextExtractor` is configured and the run isn't agent-shaped, there's no context to score against and evaluation throws `No context available for evaluation`.
|
|
34
36
|
|
|
35
37
|
## `.run()` returns
|
|
36
38
|
|
|
@@ -16,7 +16,7 @@ The `createFaithfulnessScorer()` function accepts a single options object with t
|
|
|
16
16
|
|
|
17
17
|
**options.context** (`string[]`): Array of context chunks against which the output's claims will be verified. When omitted, the scorer uses the results of tool calls in the run output.
|
|
18
18
|
|
|
19
|
-
**options.scale** (`number`): The maximum score value. The final score will be normalized to this scale.
|
|
19
|
+
**options.scale** (`number`): The maximum score value. The final score will be normalized to this scale. A value of 0 falls back to 1 (the implementation uses scale || 1).
|
|
20
20
|
|
|
21
21
|
This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer)), but the return value includes LLM-specific fields as documented below.
|
|
22
22
|
|
|
@@ -32,7 +32,7 @@ This function returns an instance of the MastraScorer class. The `.run()` method
|
|
|
32
32
|
|
|
33
33
|
**analyzePrompt** (`string`): The prompt sent to the LLM for the analyze step (optional).
|
|
34
34
|
|
|
35
|
-
**score** (`number`): A score between 0 and the
|
|
35
|
+
**score** (`number`): A score between 0 and the effective scale, representing the proportion of claims that are supported by the context. The effective scale is scale || 1, so an unset or 0 scale means 1.
|
|
36
36
|
|
|
37
37
|
**reason** (`string`): A detailed explanation of the score, including which claims were supported, contradicted, or marked as unsure.
|
|
38
38
|
|
|
@@ -60,13 +60,13 @@ The scorer evaluates faithfulness through claim verification against provided co
|
|
|
60
60
|
|
|
61
61
|
- Counts supported claims
|
|
62
62
|
- Divides by total claims
|
|
63
|
-
- Scales to
|
|
63
|
+
- Scales to the effective range
|
|
64
64
|
|
|
65
|
-
Final score: `(supported_claims / total_claims) * scale`
|
|
65
|
+
Final score: `(supported_claims / total_claims) * effective_scale`, where `effective_scale` is `scale || 1`
|
|
66
66
|
|
|
67
67
|
### Score interpretation
|
|
68
68
|
|
|
69
|
-
A faithfulness score between 0 and the
|
|
69
|
+
A faithfulness score between 0 and the effective scale (default 1). With the default scale:
|
|
70
70
|
|
|
71
71
|
- **1.0**: All claims are accurate and directly supported by the context.
|
|
72
72
|
- **0.7 to 0.9**: Most claims are correct, with minor additions or omissions.
|
|
@@ -540,7 +540,7 @@ function createAnswerSimilarityScorer({ model, options = ANSWER_SIMILARITY_DEFAU
|
|
|
540
540
|
case "missing": score -= mergedOptions.missingPenalty;
|
|
541
541
|
}
|
|
542
542
|
const maxPossibleScore = totalUnits * (1 + mergedOptions.exactMatchBonus);
|
|
543
|
-
score
|
|
543
|
+
score /= maxPossibleScore;
|
|
544
544
|
const contradictionPenalty = analysis.contradictions.length * mergedOptions.contradictionPenalty;
|
|
545
545
|
score -= contradictionPenalty;
|
|
546
546
|
const extraInfoPenalty = Math.min(analysis.extraInOutput.length * mergedOptions.extraInfoPenalty, .2);
|