AttributeError when I try to use ContextRelevance, LLMContextPrecisionWithoutReference to evaluate the test dataset
Describe the bug I got an AttributeError: property' object has no attribute 'get' when I try to use evaluate() function to evaluate a dataset with ContextRelevance, LLMContextPrecisionWithoutReference metrics. It's working when I only use faithfulness. And it's working when I evaluate a SingleTurnSample-
Ragas version: newest version Python version: newest version
Code to Reproduce result = evaluate(eval_dataset, metrics=[faithfulness, AnswerRelevancy], llm = evaluator_llm)
Error trace
File
The evaluation dataset I created is using eval_dataset = EvaluationDataset.from_pandas(df) because the data source is a pandas dataframe
I ran into the same problem with BleuScore, but it was because I wasn't passing it properly.
results = evaluate(eval_dataset, metrics=[BleuScore])
> 'property' object has no attribute 'get'
results = evaluate(eval_dataset, metrics=[BleuScore()])
> {'bleu_score': ...}
Perhaps a more detailed error message would help here! Or, even better, if the user passes a class instead of an object, perhaps initialise it for them?
Hi @Haoyuxiaohan,
Were you able to resolve it? Thanks @ziggycross for helping us out. Yes, we need to pass the object of metrics in the list of metrics when doing evaluations.
Take reference form the below example.
import pandas as pd
from ragas.dataset_schema import EvaluationDataset
sample_dict = {'user_input': {0: 'When was Einstein born?'},
'response': {0: 'Albert Einstein was born in 1879.'},
'reference': {0: 'Albert Einstein was born in 1879.'},
'retrieved_contexts': {0: []}}
df = pd.DataFrame(data = sample_dict)
dataset = EvaluationDataset.from_pandas(dataframe=df)
result = evaluate(dataset , metrics=[ContextRelevance(llm=evaluator_llm)])