Dataset schema
BaseEvalSample
Bases: BaseModel
Base class for evaluation samples.
to_dict
SingleTurnSample
Bases: BaseEvalSample
Represents evaluation samples for single-turn interactions.
Attributes:
Name | Type | Description |
---|---|---|
user_input |
Optional[str]
|
The input query from the user. |
retrieved_contexts |
Optional[List[str]]
|
List of contexts retrieved for the query. |
reference_contexts |
Optional[List[str]]
|
List of reference contexts for the query. |
response |
Optional[str]
|
The generated response for the query. |
multi_responses |
Optional[List[str]]
|
List of multiple responses generated for the query. |
reference |
Optional[str]
|
The reference answer for the query. |
rubric |
Optional[Dict[str, str]]
|
Evaluation rubric for the sample. |
MultiTurnSample
Bases: BaseEvalSample
Represents evaluation samples for multi-turn interactions.
Attributes:
Name | Type | Description |
---|---|---|
user_input |
List[Union[HumanMessage, AIMessage, ToolMessage]]
|
A list of messages representing the conversation turns. |
reference |
(Optional[str], optional)
|
The reference answer or expected outcome for the conversation. |
reference_tool_calls |
(Optional[List[ToolCall]], optional)
|
A list of expected tool calls for the conversation. |
rubrics |
(Optional[Dict[str, str]], optional)
|
Evaluation rubrics for the conversation. |
reference_topics |
(Optional[List[str]], optional)
|
A list of reference topics for the conversation. |
validate_user_input
classmethod
validate_user_input(
messages: List[
Union[HumanMessage, AIMessage, ToolMessage]
]
) -> List[Union[HumanMessage, AIMessage, ToolMessage]]
Validates the user input messages.
Source code in src/ragas/dataset_schema.py
to_messages
pretty_repr
Returns a pretty string representation of the conversation.
EvaluationDataset
Bases: BaseModel
Represents a dataset of evaluation samples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
samples
|
List[BaseEvalSample]
|
A list of evaluation samples. |
required |
Attributes:
Name | Type | Description |
---|---|---|
samples |
List[BaseEvalSample]
|
A list of evaluation samples. |
Methods:
Name | Description |
---|---|
validate_samples |
Validates that all samples are of the same type. |
get_sample_type |
Returns the type of the samples in the dataset. |
to_hf_dataset |
Converts the dataset to a Hugging Face Dataset. |
to_pandas |
Converts the dataset to a pandas DataFrame. |
features |
Returns the features of the samples. |
from_list |
Creates an EvaluationDataset from a list of dictionaries. |
from_dict |
Creates an EvaluationDataset from a dictionary. |
validate_samples
validate_samples(
samples: List[BaseEvalSample],
) -> List[BaseEvalSample]
Validates that all samples are of the same type.
Source code in src/ragas/dataset_schema.py
get_sample_type
to_hf_dataset
Converts the dataset to a Hugging Face Dataset.
Source code in src/ragas/dataset_schema.py
to_pandas
Converts the dataset to a pandas DataFrame.
Source code in src/ragas/dataset_schema.py
features
from_list
classmethod
Creates an EvaluationDataset from a list of dictionaries.
Source code in src/ragas/dataset_schema.py
from_dict
classmethod
Creates an EvaluationDataset from a dictionary.