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
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 | |
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.
trace_id
class-attribute
instance-attribute
trace_id: str | None = None
The trace ID of the case span.
ReportCaseFailure
dataclass
Bases: Generic[InputsT, OutputT, MetadataT]
A single case in an evaluation report that failed due to an error during task execution.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
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.
error_message
instance-attribute
error_message: str
The message of the exception that caused the failure.
error_stacktrace
instance-attribute
error_stacktrace: str
The stacktrace of the exception that caused the failure.
trace_id
class-attribute
instance-attribute
trace_id: str | None = None
The trace ID of the case span.
ReportCaseAggregate
Bases: BaseModel
A synthetic case that summarizes a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 176 177 178 179 180 181 182 183 184 185 186 | |
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
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 176 177 178 179 180 181 182 183 184 185 186 | |
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
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 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 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 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
cases
instance-attribute
cases: list[ReportCase[InputsT, OutputT, MetadataT]]
The cases in the report.
failures
class-attribute
instance-attribute
failures: list[
ReportCaseFailure[InputsT, OutputT, MetadataT]
] = field(default_factory=list)
The failures in the report. These are cases where task execution raised an exception.
experiment_metadata
class-attribute
instance-attribute
Metadata associated with the specific experiment represented by this report.
trace_id
class-attribute
instance-attribute
trace_id: str | None = None
The trace ID of the evaluation.
span_id
class-attribute
instance-attribute
span_id: str | None = None
The span ID of the evaluation.
render
render(
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,
include_errors: bool = True,
include_error_stacktrace: bool = False,
include_evaluator_failures: 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,
include_reasons: bool = False
) -> str
Render this report to a nicely-formatted string, 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
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 | |
print(
width: int | None = None,
baseline: (
EvaluationReport[InputsT, OutputT, MetadataT] | None
) = None,
*,
console: Console | 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,
include_errors: bool = True,
include_error_stacktrace: bool = False,
include_evaluator_failures: 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,
include_reasons: bool = False
) -> 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
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
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,
include_evaluator_failures: 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,
include_reasons: bool = False,
with_title: bool = True
) -> Table
Return a table containing the data from this report.
If a baseline is provided, returns a diff between this report and the baseline report. Optionally include input and output details.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 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 | |
failures_table
failures_table(
*,
include_input: bool = False,
include_metadata: bool = False,
include_expected_output: bool = False,
include_error_message: bool = True,
include_error_stacktrace: bool = True,
input_config: RenderValueConfig | None = None,
metadata_config: RenderValueConfig | None = None
) -> Table
Return a table containing the failures in this report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
__str__
__str__() -> str
Return a string representation of the report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
503 504 505 | |
RenderValueConfig
Bases: TypedDict
A configuration for rendering a values in an Evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
511 512 513 514 515 516 517 | |
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
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
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
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 | |
build_table
build_table(
report: EvaluationReport, *, with_title: bool = True
) -> Table
Build a table for the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
EvaluationReport
|
The evaluation report to render |
required |
with_title
|
bool
|
Whether to include the title in the table (default True) |
True
|
Returns:
| Type | Description |
|---|---|
Table
|
A Rich Table object |
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 | |
build_diff_table
build_diff_table(
report: EvaluationReport,
baseline: EvaluationReport,
*,
with_title: bool = True
) -> Table
Build a diff table comparing report to baseline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
EvaluationReport
|
The evaluation report to compare |
required |
baseline
|
EvaluationReport
|
The baseline report to compare against |
required |
with_title
|
bool
|
Whether to include the title in the table (default True) |
True
|
Returns:
| Type | Description |
|---|---|
Table
|
A Rich Table object |
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 | |