Open amin-kh96 opened 2 days ago
To fix the AttributeError: 'list' object has no attribute 'get_sample_type'
, ensure that you are using an EvaluationDataset
instance instead of a list when calling the evaluate
function. Here's how you can create an EvaluationDataset
correctly:
Convert your list to an EvaluationDataset
:
If you have a list of samples, you need to convert it to an EvaluationDataset
:
from ragas import EvaluationDataset
# Assuming ragas_data is your list of samples
evaluation_dataset = EvaluationDataset.from_list(ragas_data)
# Use evaluation_dataset in the evaluate function
evaluation_report = evaluate(evaluation_dataset, metrics=metrics, embeddings=ragas_embeddings, llm=custom_llm)
Ensure your samples are structured correctly:
Make sure each sample in your list is an instance of SingleTurnSample
or MultiTurnSample
, as required by the EvaluationDataset
[1][2].
By following these steps, you should be able to resolve the error and proceed with your evaluation.
To continue talking to Dosu, mention @dosu.
@dosu.
how to fix this error:
Exception has occurred: AttributeError
'list' object has no attribute 'rename_columns'
File "C:\Users\Amin\git\ragas-prototype\src\rag_eva.py", line 196, in
To fix the AttributeError: 'list' object has no attribute 'rename_columns'
, you need to convert your list to a compatible data structure that supports the rename_columns
method. Here's how you can do it:
Convert your list to an EvaluationDataset
:
If you have a list of samples, convert it to an EvaluationDataset
:
from ragas import EvaluationDataset
# Assuming ragas_data is your list of samples
evaluation_dataset = EvaluationDataset.from_list(ragas_data)
# Use evaluation_dataset in the evaluate function
evaluation_report = evaluate(evaluation_dataset, metrics=metrics, embeddings=ragas_embeddings, llm=custom_llm)
Ensure that each sample in your list is structured correctly as required by the EvaluationDataset
[1][2].
To continue talking to Dosu, mention @dosu.
@dosu. but this does not exist in the Ragas library: EvaluationDataset. which version of ragas are you using?
The EvaluationDataset
class might not exist in the current version of the Ragas library. Instead, you can use the available methods to handle datasets or lists of samples. Here are some relevant methods:
from_list()
: Creates a dataset from a list of dictionaries.to_pandas()
: Converts samples to a Pandas DataFrame.to_hf_dataset()
: Converts samples to a Hugging Face dataset.Ensure your samples are instances of SingleTurnSample
or MultiTurnSample
for compatibility [1][2].
To continue talking to Dosu, mention @dosu.
@dosu. i face this error : AttributeError: 'list' object has no attribute 'rename_columns' and my code is this:
ragas_data = [ { "question": entry["text_vector_1"], # Assuming this is a list of strings "answer": entry["text_vector_2"], # Assuming this is a list of strings "contexts": entry["chunks"] # Assuming this is a list of lists of strings } for entry in data_set ]
formatted_data = { "question": [entry["question"] for entry in ragas_data], "contexts": [entry["contexts"] for entry in ragas_data], "answer": [entry["answer"] for entry in ragas_data] }
the important thing is that I have a list of floats(computed embeddings).
To resolve the AttributeError: 'list' object has no attribute 'rename_columns'
, you need to convert your list of dictionaries into a compatible dataset format that supports the rename_columns
method. Here's how you can do it using the from_list
method of the EvaluationDataset
class:
Convert your list to an EvaluationDataset
:
First, ensure your data is structured correctly and then convert it:
from ragas import EvaluationDataset
# Assuming ragas_data is your list of dictionaries
evaluation_dataset = EvaluationDataset.from_list(ragas_data)
# Now you can use evaluation_dataset in the evaluate function
evaluation_report = evaluate(evaluation_dataset, metrics=metrics, embeddings=ragas_embeddings, llm=custom_llm)
Ensure your data structure is correct:
Make sure each dictionary in your list has the correct keys and values as required by the EvaluationDataset
:
ragas_data = [
{
"question": entry["text_vector_1"],
"answer": entry["text_vector_2"],
"contexts": entry["chunks"]
}
for entry in data_set
]
This should help you avoid the AttributeError
by using a compatible dataset structure [1].
To continue talking to Dosu, mention @dosu.
i deifned this function to not use the LLM calls but it still give me this error:
Exception has occurred: AttributeError 'list' object has no attribute 'get_sample_type' File "C:\Users\Amin\OneDrive - unige.it\Documenti\projectss\ragas-prototype\src\rag_eva.py", line 222, in
evaluation_report = evaluate(ragas_data, metrics=metrics, embeddings=ragas_embeddings,llm=custom_llm) # Pass your custom LLM here
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get_sample_type'
my code is this:
Define the custom LLM class
class CustomRagasLLM(BaseRagasLLM): def init(self, api_key: str = None): """ Initialize the custom LLM, optionally using an API key if necessary. """ self.api_key = api_key