Exact String Match¶
Heuristic Single Turn Binary
At a Glance¶
Score Range
0.0 or 1.0Binary pass/fail
Default Threshold
0.5Pass/fail cutoff
Required Inputs
actual_output expected_outputFull text comparison
What It Measures
Exact String Match checks whether the actual output is identical to the expected output (after stripping whitespace). This is the strictest form of text matching—the response must be exactly what was expected.
| Score | Interpretation |
|---|---|
| 1.0 | Perfect match—strings are identical |
| 0.0 | No match—any difference fails |
- Exact output format is required
- Testing deterministic transformations
- Validating code generation
- Comparing structured outputs (JSON, XML)
- Minor variations are acceptable
- Semantic equivalence matters more
- Paraphrasing is allowed
- Case differences should be ignored
See Also: Contains Match
Exact String Match checks if actual equals expected. Contains Match checks if expected is a substring of actual.
Use Exact Match when precision matters; use Contains Match for keyword validation.
How It Works
Simple string equality check after stripping whitespace.
Step-by-Step Process¶
flowchart TD
subgraph INPUT["📥 Inputs"]
A[Actual Output]
B[Expected Output]
end
subgraph PROCESS["🔍 Processing"]
C[Strip whitespace]
D["Check: actual == expected?"]
end
subgraph OUTPUT["📊 Result"]
E["1.0 = Match"]
F["0.0 = No Match"]
end
A & B --> C
C --> D
D -->|Yes| E
D -->|No| F
style INPUT stroke:#f59e0b,stroke-width:2px
style PROCESS stroke:#3b82f6,stroke-width:2px
style OUTPUT stroke:#10b981,stroke-width:2px
Configuration¶
| Parameter | Type | Default | Description |
|---|---|---|---|
| (none) | - | - | No configuration options |
Simple by Design
Exact String Match is intentionally simple with no configuration. For case-insensitive or fuzzy matching, use Levenshtein Ratio.
Code Examples¶
Example Scenarios¶
âś… Scenario 1: Perfect Match (Score: 1.0)
Identical Strings
Expected: "The answer is 42."
Actual: "The answer is 42."
Result: 1.0
Strings are character-for-character identical.
❌ Scenario 2: Case Mismatch (Score: 0.0)
Different Case
Expected: "PASS"
Actual: "Pass"
Result: 0.0
Case sensitivity causes failure.
⚠️ Scenario 3: Whitespace Handling
Leading/Trailing Whitespace
Expected: " Hello "
Actual: "Hello"
Result: 1.0
Whitespace is stripped before comparison, so these match.
❌ Scenario 4: Extra Content (Score: 0.0)
Additional Text
Expected: "Paris"
Actual: "The answer is Paris."
Result: 0.0
Even containing the expected text, the strings aren't equal.
Why It Matters¶
O(n) string comparison. No external dependencies or LLM calls.
No false positives—only identical strings pass.
Perfect for testing deterministic transformations and code generation.
Quick Reference¶
TL;DR
Exact String Match = Is the output identical to the expected text?
- Use it when: Exact output format is required (code, JSON, IDs)
- Score interpretation: 1.0 = identical, 0.0 = any difference
- Key behavior: Case-sensitive, whitespace-trimmed
-
API Reference
-
Related Metrics
Contains Match · Levenshtein Ratio · Sentence BLEU