Evaluation
Modules:
Name | Description |
---|---|
evaluator |
|
evaluators |
|
experiment |
|
Classes:
Name | Description |
---|---|
EvaluationRecord |
A record identifying evaluations for a specific task. |
Evaluator |
A class for LLM output evaluators. |
ExperimentBatchConfig |
Configuration for a batch of experiments to be executed by a pipeline. |
ExperimentConfig |
Configuration for an experiment to be executed by a pipeline. |
GenerationRecord |
A record identifying generations for a specific task. |
PerturbationGroupedRecord |
A record grouping evaluation records by generator name |
ResultRecord |
A record indicating the result of generation or evaluation. |
ScoreCalculator |
A protocol for computing evaluation scores. |
ScorerFactory |
A protocol for constructing a Scorer given a Model. |
TaskConfig |
Configuration for a task to be executed by a pipeline. |
EvaluationRecord
Bases: GenerationRecord
A record identifying evaluations for a specific task.
Attributes:
Name | Type | Description |
---|---|---|
dataset_record |
DatasetRecord
|
The record of the dataset. |
generator_name |
str
|
The name of the generator. |
task_name |
str
|
The name of the task. |
model_record |
ModelRecord
|
The record of the model. |
experiment_name |
str | None
|
The name of the experiment, if applicable. |
evaluator_name |
str
|
The name of the evaluator. |
Methods:
Name | Description |
---|---|
__eq__ |
Checks equality with another record. |
__hash__ |
Generates a hash for the evaluation record. |
__lt__ |
Checks if this record is less than another record. |
get_evaluation_record |
Generates an evaluation record from the generation record. |
get_perturbation_grouped_record |
Generates a perturbation grouped record from the evaluation record. |
Source code in evalsense/evaluation/experiment.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
generation_record
property
Generates a generation record from the evaluation record.
Returns:
Name | Type | Description |
---|---|---|
GenerationRecord |
GenerationRecord
|
The generation record. |
label
property
Generates a label for the evaluation record.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The label for the evaluation record. |
__eq__
Checks equality with another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the records are equal, False otherwise. |
Source code in evalsense/evaluation/experiment.py
__hash__
Generates a hash for the evaluation record.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash of the evaluation record. |
Source code in evalsense/evaluation/experiment.py
__lt__
Checks if this record is less than another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this record is less than the other, False otherwise. |
Source code in evalsense/evaluation/experiment.py
get_evaluation_record
Generates an evaluation record from the generation record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
evaluator_name
|
str
|
The name of the evaluator. |
required |
Returns:
Name | Type | Description |
---|---|---|
EvaluationRecord |
EvaluationRecord
|
The evaluation record. |
Source code in evalsense/evaluation/experiment.py
get_perturbation_grouped_record
Generates a perturbation grouped record from the evaluation record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric_name
|
str
|
The name of the metric being evaluated. |
required |
Returns:
Name | Type | Description |
---|---|---|
PerturbationGroupedRecord |
PerturbationGroupedRecord
|
The perturbation grouped record. |
Source code in evalsense/evaluation/experiment.py
Evaluator
dataclass
A class for LLM output evaluators.
Attributes:
Name | Type | Description |
---|---|---|
model_name |
str
|
Retrieves the model name associated with the evaluator config. |
Source code in evalsense/evaluation/evaluator.py
ExperimentBatchConfig
dataclass
Configuration for a batch of experiments to be executed by a pipeline.
Methods:
Name | Description |
---|---|
validate |
Validates the experiment configuration. |
Attributes:
Name | Type | Description |
---|---|---|
all_experiments |
list[ExperimentConfig]
|
Generates a list of all experiments in the batch. |
Source code in evalsense/evaluation/experiment.py
all_experiments
property
Generates a list of all experiments in the batch.
Returns:
Type | Description |
---|---|
list[ExperimentConfig]
|
list[ExperimentConfig]: A list of all experiments in the batch. |
validate
Validates the experiment configuration.
Raises:
Type | Description |
---|---|
ValueError
|
If the configuration is invalid. |
Source code in evalsense/evaluation/experiment.py
ExperimentConfig
dataclass
Configuration for an experiment to be executed by a pipeline.
Attributes:
Name | Type | Description |
---|---|---|
evaluation_record |
EvaluationRecord
|
A identifying evaluations for a specific task. |
generation_record |
GenerationRecord
|
A identifying generations for a specific task. |
Source code in evalsense/evaluation/experiment.py
evaluation_record
property
A identifying evaluations for a specific task.
Returns:
Name | Type | Description |
---|---|---|
EvaluationRecord |
EvaluationRecord
|
A record of the evaluations for the experiment. |
generation_record
property
A identifying generations for a specific task.
Returns:
Name | Type | Description |
---|---|---|
GenerationsRecord |
GenerationRecord
|
A record of the generations for the experiment. |
GenerationRecord
Bases: BaseModel
A record identifying generations for a specific task.
Attributes:
Name | Type | Description |
---|---|---|
dataset_record |
DatasetRecord
|
The record of the dataset. |
generator_name |
str
|
The name of the generator. |
task_name |
str
|
The name of the task. |
model_record |
ModelRecord
|
The record of the model. |
experiment_name |
str | None
|
The name of the experiment, if applicable. |
Methods:
Name | Description |
---|---|
__eq__ |
Checks equality with another record. |
__hash__ |
Generates a hash for the generation record. |
__lt__ |
Checks if this record is less than another record. |
get_evaluation_record |
Generates an evaluation record from the generation record. |
Source code in evalsense/evaluation/experiment.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
label
property
Generates a label for the generation record.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The label for the generation record. |
__eq__
Checks equality with another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the records are equal, False otherwise. |
Source code in evalsense/evaluation/experiment.py
__hash__
Generates a hash for the generation record.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash of the generation record. |
Source code in evalsense/evaluation/experiment.py
__lt__
Checks if this record is less than another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this record is less than the other, False otherwise. |
Source code in evalsense/evaluation/experiment.py
get_evaluation_record
Generates an evaluation record from the generation record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
evaluator_name
|
str
|
The name of the evaluator. |
required |
Returns:
Name | Type | Description |
---|---|---|
EvaluationRecord |
EvaluationRecord
|
The evaluation record. |
Source code in evalsense/evaluation/experiment.py
PerturbationGroupedRecord
Bases: EvaluationRecord
A record grouping evaluation records by generator name (as generator name specifies the perturbation tier).
Attributes:
Name | Type | Description |
---|---|---|
dataset_record |
DatasetRecord
|
The record of the dataset. |
generator_name |
str
|
The name of the generator. |
task_name |
str
|
The name of the task. |
model_record |
ModelRecord
|
The record of the model. |
experiment_name |
str | None
|
The name of the experiment, if applicable. |
evaluator_name |
str
|
The name of the evaluator. |
metric_name |
str
|
The name of the metric being evaluated. |
Methods:
Name | Description |
---|---|
__eq__ |
Checks equality with another record. |
__hash__ |
Generates a hash for the perturbation grouped record. |
__lt__ |
Checks if this record is less than another record. |
get_evaluation_record |
Generates an evaluation record from the generation record. |
get_perturbation_grouped_record |
Generates a perturbation grouped record from the evaluation record. |
Source code in evalsense/evaluation/experiment.py
generation_record
property
Generates a generation record from the evaluation record.
Returns:
Name | Type | Description |
---|---|---|
GenerationRecord |
GenerationRecord
|
The generation record. |
label
property
Generates a label for the evaluation record.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The label for the evaluation record. |
__eq__
Checks equality with another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the records are equal, False otherwise. |
Source code in evalsense/evaluation/experiment.py
__hash__
Generates a hash for the perturbation grouped record.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash of the perturbation grouped record. |
Source code in evalsense/evaluation/experiment.py
__lt__
Checks if this record is less than another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this record is less than the other, False otherwise. |
Source code in evalsense/evaluation/experiment.py
get_evaluation_record
Generates an evaluation record from the generation record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
evaluator_name
|
str
|
The name of the evaluator. |
required |
Returns:
Name | Type | Description |
---|---|---|
EvaluationRecord |
EvaluationRecord
|
The evaluation record. |
Source code in evalsense/evaluation/experiment.py
get_perturbation_grouped_record
Generates a perturbation grouped record from the evaluation record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric_name
|
str
|
The name of the metric being evaluated. |
required |
Returns:
Name | Type | Description |
---|---|---|
PerturbationGroupedRecord |
PerturbationGroupedRecord
|
The perturbation grouped record. |
Source code in evalsense/evaluation/experiment.py
ResultRecord
Bases: BaseModel
A record indicating the result of generation or evaluation.
Attributes:
Name | Type | Description |
---|---|---|
status |
RecordStatus
|
The status of the record. |
error_message |
str | None
|
The error message, if any. |
log_location |
str | None
|
The location of the associated Inspect log file. |
Source code in evalsense/evaluation/experiment.py
ScoreCalculator
Bases: Protocol
A protocol for computing evaluation scores.
Methods:
Name | Description |
---|---|
calculate |
Computes evaluation scores for the given evaluation method |
calculate_async |
Asynchronously computes evaluation scores for the given evaluation method |
Source code in evalsense/evaluation/evaluator.py
calculate
abstractmethod
calculate(
*,
prediction: str,
input: str | None = None,
reference: str | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: dict,
) -> Score
Computes evaluation scores for the given evaluation method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prediction
|
str
|
The model output to evaluate. |
required |
input
|
str
|
The input to the model. Optional. |
None
|
reference
|
str
|
The reference output to compare against. Optional. |
None
|
metadata
|
dict[str, Any]
|
Additional Inspect AI sample/task state metadata. Optional. |
None
|
**kwargs
|
dict
|
Additional keyword arguments specific to the given evaluation method. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Score |
Score
|
The Inspect AI Score object with the calculated result. |
Source code in evalsense/evaluation/evaluator.py
calculate_async
abstractmethod
async
calculate_async(
*,
prediction: str,
input: str | None = None,
reference: str | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: dict,
) -> Score
Asynchronously computes evaluation scores for the given evaluation method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prediction
|
str
|
The model output to evaluate. |
required |
input
|
str
|
The input to the model. Optional. |
None
|
reference
|
str
|
The reference output to compare against. Optional. |
None
|
metadata
|
dict[str, Any]
|
Additional Inspect AI sample/task state metadata. Optional. |
None
|
**kwargs
|
dict
|
Additional keyword arguments specific to the given evaluation method. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Score |
Score
|
The Inspect AI Score object with the calculated result. |
Source code in evalsense/evaluation/evaluator.py
ScorerFactory
Bases: Protocol
A protocol for constructing a Scorer given a Model.
Methods:
Name | Description |
---|---|
create_scorer |
Creates a Scorer from a Model. |
Source code in evalsense/evaluation/evaluator.py
create_scorer
abstractmethod
Creates a Scorer from a Model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model
|
The model to create a scorer for. |
required |
Returns:
Name | Type | Description |
---|---|---|
Scorer |
Scorer
|
The created scorer. |
TaskConfig
dataclass
Configuration for a task to be executed by a pipeline.