Evaluating how well a language model utilises provided context chunks is essential for ensuring accurate, relevant, and contextually appropriate responses. A model that effectively leverages context can generate more reliable and factually grounded outputs, reducing hallucinations and improving consistency.Failure to properly utilise context can lead to:
Incomplete responses – Missing relevant details present in the provided context.
Context misalignment – The model generating responses that contradict or ignore the context.
Inefficient information usage – Not fully leveraging the available context to improve accuracy.
Export your API key and Secret key into your environment variables.
Copy
result = evaluator.evaluate( eval_templates="chunk_attribution", inputs={ "context": "Honey never spoils because it has low moisture content and high acidity, creating an environment that resists bacteria and microorganisms. Archaeologists have even found pots of honey in ancient Egyptian tombs that are still perfectly edible.", "input": "Why doesn’t honey go bad?", "output": "Honey doesn’t spoil because its low moisture and high acidity prevent the growth of bacteria and other microbes." }, model_name="turing_flash")print(result.eval_results[0].output)print(result.eval_results[0].reason)
Measures how effectively the model integrates the retrieved context chunks into its response. Unlike Chunk Attribution, which only checks for references, Chunk Utilization assigns a score based on how well the context contributes to a meaningful response.
Higher Score – The model extensively incorporates relevant chunks.
Lower Score – The model includes minimal or no context.
result = evaluator.evaluate( eval_templates="chunk_utilization", inputs={ "context": "Honey never spoils because it has low moisture content and high acidity, creating an environment that resists bacteria and microorganisms. Archaeologists have even found pots of honey in ancient Egyptian tombs that are still perfectly edible.", "output": "Honey doesn’t spoil because its low moisture and high acidity prevent the growth of bacteria and other microbes." }, model_name="turing_flash")print(result.eval_results[0].output)print(result.eval_results[0].reason)