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 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
Results cache¶
mteb.cache.ResultCache
¶
Class to handle the local cache of MTEB results.
Examples:
>>> from mteb.cache import ResultCache
>>> cache = ResultCache(cache_path="~/.cache/mteb") # default
>>> cache.download_from_remote() # download the latest results from the remote repository
>>> result = cache.load_results("task_name", "model_name")
Source code in mteb/cache.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 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 | |
default_cache_path
property
¶
Get the local cache directory for MTEB results.
Returns:
| Type | Description |
|---|---|
Path
|
The path to the local cache directory. |
has_remote
property
¶
Check if the remote results repository exists in the cache directory.
Returns:
| Type | Description |
|---|---|
bool
|
True if the remote results repository exists, False otherwise. |
clear_cache()
¶
Clear the local cache directory.
Source code in mteb/cache.py
250 251 252 253 254 255 256 | |
download_from_remote(remote='https://github.com/embeddings-benchmark/results', download_latest=True)
¶
Downloads the latest version of the results repository from GitHub to a local cache directory. Required git to be installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remote
|
str
|
The URL of the results repository on GitHub. |
'https://github.com/embeddings-benchmark/results'
|
download_latest
|
bool
|
If True it will download the latest version of the repository, otherwise it will only update the existing repository. |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
The path to the local cache directory. |
Source code in mteb/cache.py
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 | |
get_cache_paths(models=None, tasks=None, require_model_meta=True, include_remote=True)
¶
Get all paths to result JSON files in the cache directory.
These paths can then be used to fetch task results, like:
for path in paths:
task_result = TaskResult.from_disk(path)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Sequence[str] | Sequence[ModelMeta] | None
|
A list of model names or ModelMeta objects to filter the paths. |
None
|
tasks
|
Sequence[str] | Sequence[AbsTask] | None
|
A list of task names to filter the paths. |
None
|
require_model_meta
|
bool
|
If True, only return paths that have a model_meta.json file. |
True
|
include_remote
|
bool
|
If True, include remote results in the returned paths. |
True
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
A list of paths in the cache directory. |
Examples:
>>> from mteb.cache import ResultCache
>>> cache = ResultCache()
>>>
>>> # Get all cache paths
>>> paths = cache.get_cache_paths()
>>>
>>> # Get all cache paths for a specific task
>>> paths = cache.get_cache_paths(tasks=["STS12"])
>>>
>>> # Get all cache paths for a specific model
>>> paths = cache.get_cache_paths(models=["sentence-transformers/all-MiniLM-L6-v2"])
>>>
>>> # Get all cache paths for a specific model and revision
>>> model_meta = mteb.get_model_meta("sentence-transformers/all-MiniLM-L6-v2")
>>> paths = cache.get_cache_paths(models=[model_meta])
Source code in mteb/cache.py
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 | |
get_models(tasks=None, require_model_meta=True, include_remote=True)
¶
Get all models in the cache directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tasks
|
Sequence[str] | None
|
A list of task names to filter the models. |
None
|
require_model_meta
|
bool
|
If True, only return models that have a model_meta.json file. |
True
|
include_remote
|
bool
|
If True, include remote results in the returned models. |
True
|
Returns:
| Type | Description |
|---|---|
list[tuple[ModelName, Revision]]
|
A list of tuples containing the model name and revision. |
Source code in mteb/cache.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
get_task_names(models=None, require_model_meta=True, include_remote=True)
¶
Get all task names in the cache directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
list[str] | list[ModelMeta] | None
|
A list of model names or ModelMeta objects to filter the task names. |
None
|
require_model_meta
|
bool
|
If True, only return task names that have a model_meta.json file |
True
|
include_remote
|
bool
|
If True, include remote results in the returned task names. |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of task names in the cache directory. |
Source code in mteb/cache.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
get_task_result_path(task_name, model_name, model_revision=None, remote=False)
¶
Get the path to the results of a specific task for a specific model and revision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
The name of the task. |
required |
model_name
|
str | ModelMeta
|
The name of the model as a valid directory name or a ModelMeta object. |
required |
model_revision
|
str | None
|
The revision of the model. Must be specified if model_name is a string. |
None
|
remote
|
bool
|
If True, it will return the path to the remote results repository, otherwise it will return the path to the local results repository. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
The path to the results of the task. |
Source code in mteb/cache.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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
load_results(models=None, tasks=None, require_model_meta=True, include_remote=True, validate_and_filter=False, only_main_score=False)
¶
Loads the results from the cache directory and returns a BenchmarkResults object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Sequence[str] | Sequence[ModelMeta] | None
|
A list of model names to load the results for. If None it will load the results for all models. |
None
|
tasks
|
Sequence[str] | Sequence[AbsTask] | None
|
A list of task names to load the results for. If None it will load the results for all tasks. |
None
|
require_model_meta
|
bool
|
If True it will ignore results that do not have a model_meta.json file. If false it attempt to extract the model name and revision from the path. |
True
|
include_remote
|
bool
|
If True, it will include results from the remote repository. |
True
|
validate_and_filter
|
bool
|
If True it will validate that the results object for the task contains the correct splits and filter out splits from the results object that are not default in the task metadata. |
False
|
only_main_score
|
bool
|
If True, only the main score will be loaded. |
False
|
Returns:
| Type | Description |
|---|---|
BenchmarkResults
|
A BenchmarkResults object containing the results for the specified models and tasks. |
Examples:
>>> from mteb.cache import ResultCache
>>> cache = ResultCache()
>>>
>>> # Load results for specific models and tasks
>>> results = cache.load_results(
... models=["sentence-transformers/all-MiniLM-L6-v2"],
... tasks=["STS12"],
... require_model_meta=True,
... )
Source code in mteb/cache.py
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 | |
load_task_result(task_name, model_name, model_revision=None, raise_if_not_found=False, prioritize_remote=False)
¶
Load the results from the local cache directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
The name of the task. |
required |
model_name
|
str | ModelMeta
|
The name of the model as a valid directory name or a ModelMeta object. |
required |
model_revision
|
str | None
|
The revision of the model. Must be specified if model_name is a string. |
None
|
raise_if_not_found
|
bool
|
If True, raise an error if the results are not found. |
False
|
prioritize_remote
|
bool
|
If True, it will first try to load the results from the remote repository, if available. |
False
|
Returns:
| Type | Description |
|---|---|
TaskResult | None
|
The results of the task, or None if not found. |
Source code in mteb/cache.py
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 | |
save_to_cache(task_result, model_name, model_revision=None)
¶
Save the task results to the local cache directory in the location {model_name}/{model_revision}/{task_name}.json.
Where model_name is a path-normalized model name. In addition we also save a model_meta.json in the revision folder to preserve the model metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_result
|
TaskResult
|
The results of the task. |
required |
model_name
|
str | ModelMeta
|
The name of the model as a valid directory name or a ModelMeta object. |
required |
model_revision
|
str | None
|
The revision of the model. Must be specified if model_name is a string. |
None
|
Source code in mteb/cache.py
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 | |
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
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 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | |
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.
is_public
property
¶
Check if the task is public.
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The dictionary to create the TaskResult from. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The created TaskResult object. |
Source code in mteb/results/task_result.py
288 289 290 291 292 293 294 295 296 297 298 | |
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
|
Returns:
| Type | Description |
|---|---|
Self
|
The loaded TaskResult object. |
Source code in mteb/results/task_result.py
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 | |
from_task_results(task, scores, evaluation_time, kg_co2_emissions=None)
classmethod
¶
Create a TaskResult from the task and scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
AbsTask | type[AbsTask]
|
The task to create the TaskResult from. |
required |
scores
|
dict[SplitName, dict[HFSubset, ScoresDict]]
|
The scores of the model on the dataset. The scores is a dictionary with the following structure; dict[SplitName, dict[HFSubset, 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. |
required |
evaluation_time
|
float
|
The time taken to evaluate the model. |
required |
kg_co2_emissions
|
float | None
|
The kg of CO2 emissions produced by the model during evaluation. |
None
|
Source code in mteb/results/task_result.py
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 | |
from_validated(**data)
classmethod
¶
Create a TaskResult from validated data.
Returns:
| Type | Description |
|---|---|
Self
|
The created TaskResult object. |
Source code in mteb/results/task_result.py
583 584 585 586 587 588 589 590 | |
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
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | |
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
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | |
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
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 | |
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[Criteria]
|
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
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 | |
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[Criteria]
|
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 |
|---|---|
Self
|
A new TaskResult object with the merged scores. |
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 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 780 781 782 | |
only_main_score()
¶
Return a new TaskResult object with only the main score.
Returns:
| Type | Description |
|---|---|
Self
|
A new TaskResult object with only the main score. |
Source code in mteb/results/task_result.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
to_dict()
¶
Convert the TaskResult to a dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
The TaskResult as a dictionary. |
Source code in mteb/results/task_result.py
280 281 282 283 284 285 286 | |
to_disk(path)
¶
Save TaskResult to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the file to save. |
required |
Source code in mteb/results/task_result.py
315 316 317 318 319 320 321 322 323 324 325 | |
validate_and_filter_scores(task=None)
¶
Validate and filter the scores against the task metadata.
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
|
Returns:
| Type | Description |
|---|---|
Self
|
A new TaskResult object with the validated and filtered scores. |
Source code in mteb/results/task_result.py
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 | |
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
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 | |
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. |
from_validated(**data)
classmethod
¶
Create a ModelResult from validated data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The validated data. |
{}
|
Source code in mteb/results/model_result.py
90 91 92 93 94 95 96 97 98 99 100 | |
select_tasks(tasks)
¶
Select tasks from the ModelResult based on a list of AbsTask objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tasks
|
Sequence[AbsTask]
|
A sequence of AbsTask objects to select from the ModelResult. |
required |
Source code in mteb/results/model_result.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
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
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 | |
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
34 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 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 | |
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_dict(data)
classmethod
¶
Create BenchmarkResults from a dictionary.
Source code in mteb/results/benchmark_results.py
374 375 376 377 | |
from_disk(path)
classmethod
¶
Load the BenchmarkResults from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
Path to the JSON file. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
An instance of BenchmarkResults. |
Source code in mteb/results/benchmark_results.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_validated(**data)
classmethod
¶
Create BenchmarkResults from validated data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dictionary containing the data. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
An instance of BenchmarkResults. |
Source code in mteb/results/benchmark_results.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
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.
Returns:
| Type | Description |
|---|---|
Self
|
A new BenchmarkResults object with the revisions joined. |
Source code in mteb/results/benchmark_results.py
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 | |
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
|
Returns:
| Type | Description |
|---|---|
Self
|
A new BenchmarkResults object with the filtered models. |
Source code in mteb/results/benchmark_results.py
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 | |
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 |
Returns:
| Type | Description |
|---|---|
Self
|
A new BenchmarkResults object with the selected tasks. |
Source code in mteb/results/benchmark_results.py
80 81 82 83 84 85 86 87 88 89 90 91 92 | |
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".
Afterward, 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
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 | |
to_dict()
¶
Convert BenchmarkResults to a dictionary.
Source code in mteb/results/benchmark_results.py
370 371 372 | |
to_disk(path)
¶
Save the BenchmarkResults to a JSON file.
Source code in mteb/results/benchmark_results.py
379 380 381 382 383 | |