ContextPrecisionMetric<T>
Models & Types · AiDotNet.RetrievalAugmentedGeneration.Evaluation
Evaluates context precision (RAGAS): whether the relevant retrieved contexts are ranked highly.
Inheritance: RAGMetricBase<T> → ContextPrecisionMetric<T>
How It Works
Context precision rewards a retriever for placing the useful contexts near the top of the ranked
list. Each retrieved context is first judged relevant or not (against the ground-truth answer when
present, otherwise the query). The score is the average of Precision@k evaluated at each rank that
holds a relevant context — the standard average-precision formulation used by RAGAS:
sum_k (Precision@k * relevant_k) / total_relevant.
Relevance of each context is decided by the text generator (a yes/no judge) when one is supplied, otherwise by cosine similarity against an embedding model, otherwise by an offline lexical Jaccard-overlap threshold.
Constructors
| Constructor | Summary |
|---|---|
ContextPrecisionMetric(ITextGenerator generator, IEmbeddingModel<T> embeddingModel, double relevanceThreshold) |
Initializes a new instance of the ContextPrecisionMetric class. |
Properties
| Property | Summary |
|---|---|
string Description { get; } |
Gets the description of what this metric measures. |
string Name { get; } |
Gets the name of this metric. |