Results¶
When a models is evaluated in MTEB it produces results. These results consist of:
TaskResult
: Result for a single taskModelResult
: Result for a model on a set of tasksBenchmarkResults
: Result for a set of models models on a set of tasks
In normal use these come up when running a model:
# ...
models_results = mteb.evaluate(model, tasks)
type(models_results) # mteb.results.ModelResults
task_result = models_results.task_results
type(models_results) # mteb.results.TaskResult
Result Objects¶
mteb.results.TaskResult
¶
Bases: BaseModel
A class to represent the MTEB result.
Attributes:
Name | Type | Description |
---|---|---|
task_name |
str
|
The name of the MTEB task. |
dataset_revision |
str
|
The revision dataset for the task on HuggingFace dataset hub. |
mteb_version |
str | None
|
The version of the MTEB used to evaluate the model. |
scores |
dict[SplitName, list[ScoresDict]]
|
The scores of the model on the dataset. The scores is a dictionary with the following structure; dict[SplitName, list[Scores]]. Where Scores is a dictionary with the following structure; dict[str, Any]. Where the keys and values are scores. Split is the split of the dataset. |
evaluation_time |
float | None
|
The time taken to evaluate the model. |
kg_co2_emissions |
float | None
|
The kg of CO2 emissions produced by the model during evaluation. |
Examples:
>>> scores = {
... "evaluation_time": 100,
... "train": {
... "en-de": {
... "main_score": 0.5,
... },
... "en-fr": {
... "main_score": 0.6,
... },
... },
... }
>>> sample_task = ... # some MTEB task
>>> mteb_results = TaskResult.from_task_results(sample_task, scores)
>>> mteb_results.get_score() # get the main score for all languages
0.55
>>> mteb_results.get_score(languages=["fra"]) # get the main score for French
0.6
>>> mteb_results.to_dict()
{'dataset_revision': '1.0', 'task_name': 'sample_task', 'mteb_version': '1.0.0', 'evaluation_time': 100, 'scores': {'train':
[
{'main_score': 0.5, 'hf_subset': 'en-de', 'languages': ['eng-Latn', 'deu-Latn']},
{'main_score': 0.6, 'hf_subset': 'en-fr', 'languages': ['eng-Latn', 'fra-Latn']}
]}
}
Source code in mteb/results/task_result.py
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 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 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 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 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 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
domains
property
¶
Get the domains of the task.
eval_splits
property
¶
Get the eval splits present in the scores.
hf_subsets
property
¶
Get the hf_subsets present in the scores.
languages
property
¶
Get the languages present in the scores.
task
cached
property
¶
Get the task associated with the result.
task_type
property
¶
Get the type of the task.
from_dict(data)
classmethod
¶
Create a TaskResult from a dictionary.
Source code in mteb/results/task_result.py
266 267 268 269 |
|
from_disk(path, load_historic_data=True)
classmethod
¶
Load TaskResult from disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
The path to the file to load. |
required |
load_historic_data
|
bool
|
Whether to attempt to load historic data from before v1.11.0. |
True
|
Source code in mteb/results/task_result.py
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 |
|
get_hf_eval_results()
¶
Create HF evaluation results objects from TaskResult objects.
Returns:
Type | Description |
---|---|
list[EvalResult]
|
List of EvalResult objects for each split and subset. |
Source code in mteb/results/task_result.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
get_missing_evaluations(task)
¶
Checks which splits and subsets are missing from the results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
AbsTask
|
The task to check against. |
required |
Returns:
Type | Description |
---|---|
dict[str, list[str]]
|
A dictionary with the splits as keys and a list of missing subsets as values. |
Source code in mteb/results/task_result.py
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
|
get_score(splits=None, languages=None, scripts=None, getter=lambda scores: scores['main_score'], aggregation=np.mean)
¶
Get a score for the specified splits, languages, scripts and aggregation function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
splits
|
list[SplitName] | None
|
The splits to consider. |
None
|
languages
|
list[ISOLanguage | ISOLanguageScript] | None
|
The languages to consider. Can be ISO language codes or ISO language script codes. |
None
|
scripts
|
list[ISOLanguageScript] | None
|
The scripts to consider. |
None
|
getter
|
Callable[[ScoresDict], Score]
|
A function that takes a scores dictionary and returns a score e.g. "main_score" or "evaluation_time". |
lambda scores: scores['main_score']
|
aggregation
|
Callable[[list[Score]], Any]
|
The aggregation function to use. |
mean
|
Returns:
Type | Description |
---|---|
Any
|
The result of the aggregation function on the scores. |
Source code in mteb/results/task_result.py
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 |
|
is_mergeable(result, criteria=['mteb_version', 'dataset_revision'], raise_error=False)
¶
Checks if the TaskResult object can be merged with another TaskResult or Task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result
|
TaskResult | AbsTask
|
The TaskResult or Task object to check against. |
required |
criteria
|
list[str] | list[Criterias]
|
Additional criteria to check for merging. Can be "mteb_version" or "dataset_revision". It will always check that the task name match. |
['mteb_version', 'dataset_revision']
|
raise_error
|
bool
|
If True, raises an error if the objects cannot be merged. If False, returns False. |
False
|
Returns:
Type | Description |
---|---|
bool
|
True if the TaskResult object can be merged with the other object, False otherwise. |
Source code in mteb/results/task_result.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
merge(new_results, criteria=['mteb_version', 'dataset_revision'])
¶
Merges two TaskResult objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_results
|
TaskResult
|
The new TaskResult object to merge with the current one. |
required |
criteria
|
list[str] | list[Criterias]
|
Additional criteria to check for merging. Can be "mteb_version" or "dataset_revision". It will always check that the task name match. |
['mteb_version', 'dataset_revision']
|
Returns:
Type | Description |
---|---|
TaskResult
|
A new TaskResult object with the merged scores. |
Source code in mteb/results/task_result.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
|
to_dict()
¶
Convert the TaskResult to a dictionary.
Source code in mteb/results/task_result.py
262 263 264 |
|
validate_and_filter_scores(task=None)
¶
This ensures that the scores are correct for the given task, by removing any splits besides those specified in the task metadata. Additionally it also ensure that all of the splits required as well as the languages are present in the scores. Returns new TaskResult object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
AbsTask | None
|
The task to validate the scores against. E.g. if the task supplied is limited to certain splits and languages, the scores will be filtered to only include those splits and languages. If None it will attempt to get the task from the task_name. |
None
|
Source code in mteb/results/task_result.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 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 |
|
mteb.results.ModelResult
¶
Bases: BaseModel
Data class to hold the results of a model on a set of tasks.
Attributes:
Name | Type | Description |
---|---|---|
model_name |
str
|
Name of the model. |
model_revision |
str | None
|
Revision of the model. |
task_results |
list[TaskResult]
|
List of TaskResult objects. |
Source code in mteb/results/model_result.py
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 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 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 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 |
|
domains
property
¶
Get all domains in the model results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of domains in the model results. |
languages
property
¶
Get all languages in the model results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of languages in the model results. |
modalities
property
¶
Get all modalities in the task results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of modalities in the task results. |
task_names
property
¶
Get all task names in the model results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of task names in the model results. |
task_types
property
¶
Get all task types in the model results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of task types in the model results. |
to_dataframe(aggregation_level='task', aggregation_fn=None, include_model_revision=False, format='wide')
¶
Get a DataFrame with the scores for all models and tasks. The DataFrame will have the following columns in addition to the metadata columns:
- model_name: The name of the model.
- task_name: The name of the task.
- score: The main score of the model on the task.
In addition, the DataFrame can have the following columns depending on the aggregation level:
- split: The split of the task. E.g. "test", "train", "validation".
- subset: The subset of the task. E.g. "en", "fr-en".
Afterwards, the DataFrame will be aggregated according to the aggregation method and pivoted to either a wide format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aggregation_level
|
Literal['subset', 'split', 'task']
|
The aggregation to use. Can be one of: - "subset"/None: No aggregation will be done. The DataFrame will have one row per model, task, split and subset. - "split": Aggregates the scores by split. The DataFrame will have one row per model, task and split. - "task": Aggregates the scores by task. The DataFrame will have one row per model and task. |
'task'
|
aggregation_fn
|
Callable[[list[Score]], Any] | None
|
The function to use for aggregation. If None, the mean will be used. |
None
|
include_model_revision
|
bool
|
If True, the model revision will be included in the DataFrame. If False, it will be excluded. |
False
|
format
|
Literal['wide', 'long']
|
The format of the DataFrame. Can be one of: - "wide": The DataFrame will be of shape (number of tasks, number of models). Scores will be in the cells. - "long": The DataFrame will of length (number of tasks * number of model). Scores will be in columns. |
'wide'
|
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with the scores for all models and tasks. |
Source code in mteb/results/model_result.py
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 |
|
mteb.results.BenchmarkResults
¶
Bases: BaseModel
Data class to hold the benchmark results of a model.
Attributes:
Name | Type | Description |
---|---|---|
model_results |
list[ModelResult]
|
List of ModelResult objects. |
Source code in mteb/results/benchmark_results.py
35 36 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 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 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 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 |
|
domains
property
¶
Get all domains in the benchmark results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of domains in ISO 639-1 format. |
languages
property
¶
Get all languages in the benchmark results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of languages in ISO 639-1 format. |
modalities
property
¶
Get all modalities in the benchmark results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of modalities. |
model_names
property
¶
Get all model names in the benchmark results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of model names. |
model_revisions
property
¶
Get all model revisions in the benchmark results.
Returns:
Type | Description |
---|---|
list[dict[str, str | None]]
|
A list of dictionaries with model names and revisions. |
task_names
property
¶
Get all task names in the benchmark results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of task names. |
task_types
property
¶
Get all task types in the benchmark results.
Returns:
Type | Description |
---|---|
list[str]
|
A list of task types. |
from_disk(path)
classmethod
¶
Load the BenchmarkResults from a JSON file.
Source code in mteb/results/benchmark_results.py
381 382 383 384 385 386 387 |
|
join_revisions()
¶
Join revisions of the same model.
In case of conflicts, the following rules are applied: 1) If the main revision is present, it is kept. The main revision is the defined in the models ModelMeta object. 2) If there is multiple revisions and some of them are None or na, they are filtered out. 3) If there is no main revision, we prefer the one run using the latest mteb version.
Source code in mteb/results/benchmark_results.py
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 |
|
select_models(names, revisions=None)
¶
Get models by name and revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
list[str] | list[ModelMeta]
|
List of model names to filter by. Can also be a list of ModelMeta objects. In which case, the revision is ignored. |
required |
revisions
|
list[str | None] | None
|
List of model revisions to filter by. If None, all revisions are returned. |
None
|
Source code in mteb/results/benchmark_results.py
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 |
|
select_tasks(tasks)
¶
Select tasks from the benchmark results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks
|
Sequence[AbsTask]
|
List of tasks to select. Can be a list of AbsTask objects or task names. |
required |
Source code in mteb/results/benchmark_results.py
81 82 83 84 85 86 87 88 89 90 |
|
to_dataframe(aggregation_level='task', aggregation_fn=None, include_model_revision=False, format='wide')
¶
Get a DataFrame with the scores for all models and tasks. The DataFrame will have the following columns in addition to the metadata columns:
- model_name: The name of the model.
- task_name: The name of the task.
- score: The main score of the model on the task.
In addition, the DataFrame can have the following columns depending on the aggregation level:
- split: The split of the task. E.g. "test", "train", "validation".
- subset: The subset of the task. E.g. "en", "fr-en".
Afterwards, the DataFrame will be aggregated according to the aggregation method and pivoted to either a wide format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aggregation_level
|
Literal['subset', 'split', 'task']
|
The aggregation to use. Can be one of: - "subset"/None: No aggregation will be done. The DataFrame will have one row per model, task, split and subset. - "split": Aggregates the scores by split. The DataFrame will have one row per model, task and split. - "task": Aggregates the scores by task. The DataFrame will have one row per model and task. |
'task'
|
aggregation_fn
|
Callable[[list[Score]], Any] | None
|
The function to use for aggregation. If None, the mean will be used. |
None
|
include_model_revision
|
bool
|
If True, the model revision will be included in the DataFrame. If False, it will be excluded.
If there are multiple revisions for the same model, they will be joined using the |
False
|
format
|
Literal['wide', 'long']
|
The format of the DataFrame. Can be one of: - "wide": The DataFrame will be of shape (number of tasks, number of models). Scores will be in the cells. - "long": The DataFrame will of length (number of tasks * number of model). Scores will be in columns. |
'wide'
|
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with the scores for all models and tasks. |
Source code in mteb/results/benchmark_results.py
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 |
|
to_disk(path)
¶
Save the BenchmarkResults to a JSON file.
Source code in mteb/results/benchmark_results.py
368 369 370 371 372 |
|