pydantic_evals.reporting
ReportCase
dataclass
Bases: Generic[InputsT, OutputT, MetadataT]
A single case in an evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 |
|
metadata
instance-attribute
metadata: MetadataT | None
Any metadata associated with the case, from Case.metadata
.
expected_output
instance-attribute
expected_output: OutputT | None
The expected output of the task, from Case.expected_output
.
output
instance-attribute
output: OutputT
The output of the task execution.
ReportCaseAggregate
Bases: BaseModel
A synthetic case that summarizes a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 140 141 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 |
|
average
staticmethod
average(cases: list[ReportCase]) -> ReportCaseAggregate
Produce a synthetic "summary" case by averaging quantitative attributes.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 140 141 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 |
|
EvaluationReport
dataclass
Bases: Generic[InputsT, OutputT, MetadataT]
A report of the results of evaluating a model on a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
cases
instance-attribute
cases: list[ReportCase[InputsT, OutputT, MetadataT]]
The cases in the report.
failures
class-attribute
instance-attribute
The failures in the report. These are cases where task execution raised an exception.
print(
width: int | None = None,
baseline: (
EvaluationReport[InputsT, OutputT, MetadataT] | None
) = None,
include_input: bool = False,
include_metadata: bool = False,
include_expected_output: bool = False,
include_output: bool = False,
include_durations: bool = True,
include_total_duration: bool = False,
include_removed_cases: bool = False,
include_averages: bool = True,
input_config: RenderValueConfig | None = None,
metadata_config: RenderValueConfig | None = None,
output_config: RenderValueConfig | None = None,
score_configs: (
dict[str, RenderNumberConfig] | None
) = None,
label_configs: (
dict[str, RenderValueConfig] | None
) = None,
metric_configs: (
dict[str, RenderNumberConfig] | None
) = None,
duration_config: RenderNumberConfig | None = None,
)
Print this report to the console, optionally comparing it to a baseline report.
If you want more control over the output, use console_table
instead and pass it to rich.Console.print
.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 |
|
console_table
console_table(
baseline: (
EvaluationReport[InputsT, OutputT, MetadataT] | None
) = None,
include_input: bool = False,
include_metadata: bool = False,
include_expected_output: bool = False,
include_output: bool = False,
include_durations: bool = True,
include_total_duration: bool = False,
include_removed_cases: bool = False,
include_averages: bool = True,
input_config: RenderValueConfig | None = None,
metadata_config: RenderValueConfig | None = None,
output_config: RenderValueConfig | None = None,
score_configs: (
dict[str, RenderNumberConfig] | None
) = None,
label_configs: (
dict[str, RenderValueConfig] | None
) = None,
metric_configs: (
dict[str, RenderNumberConfig] | None
) = None,
duration_config: RenderNumberConfig | None = None,
) -> Table
Return a table containing the data from this report, or the diff between this report and a baseline report.
Optionally include input and output details.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
__str__
__str__() -> str
Return a string representation of the report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
284 285 286 287 288 289 |
|
RenderValueConfig
Bases: TypedDict
A configuration for rendering a values in an Evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
295 296 297 298 299 300 301 |
|
RenderNumberConfig
Bases: TypedDict
A configuration for rendering a particular score or metric in an Evaluation report.
See the implementation of _RenderNumber
for more clarity on how these parameters affect the rendering.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
value_formatter
instance-attribute
The logic to use for formatting values.
- If not provided, format as ints if all values are ints, otherwise at least one decimal place and at least four significant figures.
- You can also use a custom string format spec, e.g. '{:.3f}'
- You can also use a custom function, e.g. lambda x: f'{x:.3f}'
diff_formatter
instance-attribute
The logic to use for formatting details about the diff.
The strings produced by the value_formatter will always be included in the reports, but the diff_formatter is used to produce additional text about the difference between the old and new values, such as the absolute or relative difference.
- If not provided, format as ints if all values are ints, otherwise at least one decimal place and at least four significant figures, and will include the percentage change.
- You can also use a custom string format spec, e.g. '{:+.3f}'
- You can also use a custom function, e.g. lambda x: f'{x:+.3f}'. If this function returns None, no extra diff text will be added.
- You can also use None to never generate extra diff text.
diff_atol
instance-attribute
diff_atol: float
The absolute tolerance for considering a difference "significant".
A difference is "significant" if abs(new - old) < self.diff_atol + self.diff_rtol * abs(old)
.
If a difference is not significant, it will not have the diff styles applied. Note that we still show both the rendered before and after values in the diff any time they differ, even if the difference is not significant. (If the rendered values are exactly the same, we only show the value once.)
If not provided, use 1e-6.
diff_rtol
instance-attribute
diff_rtol: float
The relative tolerance for considering a difference "significant".
See the description of diff_atol
for more details about what makes a difference "significant".
If not provided, use 0.001 if all values are ints, otherwise 0.05.
diff_increase_style
instance-attribute
diff_increase_style: str
The style to apply to diffed values that have a significant increase.
See the description of diff_atol
for more details about what makes a difference "significant".
If not provided, use green for scores and red for metrics. You can also use arbitrary rich
styles, such as "bold red".
diff_decrease_style
instance-attribute
diff_decrease_style: str
The style to apply to diffed values that have significant decrease.
See the description of diff_atol
for more details about what makes a difference "significant".
If not provided, use red for scores and green for metrics. You can also use arbitrary rich
styles, such as "bold red".
EvaluationRenderer
dataclass
A class for rendering an EvalReport or the diff between two EvalReports.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
|