Skip to content

LLM-based Context Precision

Definition

Context Precision is used to measure information density.

while

Example Usage

Required data items: question, retrieved_context

from continuous_eval.metrics.retrieval import ContextPrecision
datum = {
"question": "What is the capital of France?",
"retrieved_context": [
"Paris is the capital of France and also the largest city in the country.",
"Lyon is a major city in France.",
],
}
metric = ContextPrecision()
print(metric(**datum))

Sample Output

{
"percentage_relevant": 0.5,
"context_precision": 0.5000000000746547,
"context_mean_average_precision": 1.0,
}