RAG-011RAG · Answer qualitylayaeval.FactualCorrectness

Factual Correctness

Does the answer match the known correct answer?

ANSWERCORRECT ANSWERCityParisCityParisPeople2.1MPeople2.1MMatches the correct answer
Simulation state:
When it passes

Matches the answer key.

Threshold satisfied: evaluation score >= 3.0.

When it fails

One fact differs.

Violation detected: execution flagged for human review or fallback routing.

SDK Specification

ParameterValueDescription
ClassFactualCorrectnessPython evaluator class in layaeval
Required Fields"query", "response", "ground_truth"Arguments expected in the call signature
Default Threshold>= 3.0Passes when quality score is at or above this value
CategoryRAG EvaluationAnswer quality (Is the reply on topic, complete and correct?)

Python Example

pip install layaeval
factual-correctness.py
1from layaeval import FactualCorrectness
2
3metric = FactualCorrectness(threshold=3.0) # passes at or above 3.0
4
5res = metric(
6 query="What is the capital of France?",
7 response="Paris is the capital of France.",
8 ground_truth="Paris",
9)
10
11print(res.passed, res.value, res.confidence)

Related RAG Checks

Other checks in Answer quality

View all 42 checks →