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:
>>> import mteb
>>> cache = mteb.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/result_cache.py
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 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 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 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 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 | |
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. |
remote_repo_path
property
¶
Get the path to the remote repository clone.
Returns:
| Type | Description |
|---|---|
Path
|
The path to the remote repository clone. |
remote_results_path
property
¶
Get the path to the remote results directory.
Returns:
| Type | Description |
|---|---|
Path
|
The path to the remote results directory. |
clear_cache()
¶
Clear the local cache directory.
Source code in mteb/cache/result_cache.py
667 668 669 670 671 672 673 674 675 | |
download_from_remote(remote='https://github.com/embeddings-benchmark/results', download_latest=True, revision=None)
¶
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
|
revision
|
str | None
|
If specified, it will checkout the given revision after cloning or pulling the repository. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The path to the local cache directory. |
Source code in mteb/cache/result_cache.py
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 | |
get_cache_paths(models=None, tasks=None, require_model_meta=True, include_remote=True, load_experiments=LoadExperimentEnum.NO_EXPERIMENTS)
¶
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] | Iterable[ModelMeta] | None
|
A list of model names or ModelMeta objects to filter the paths. |
None
|
tasks
|
Sequence[str] | Iterable[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
|
load_experiments
|
LoadExperimentEnum | str
|
If True, include experiments in the returned paths. |
NO_EXPERIMENTS
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
A list of paths in the cache directory. |
Examples:
>>> import mteb
>>> cache = mteb.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/result_cache.py
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 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 | |
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/result_cache.py
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
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/result_cache.py
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 | |
get_task_result_path(task_name, model_name, model_revision=None, remote=False, experiment_name=None)
¶
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
|
experiment_name
|
str | None
|
The name of the experiment as a valid directory name. If model_name is a ModelMeta object, its experiment_name will be used. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The path to the results of the task. |
Source code in mteb/cache/result_cache.py
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 | |
load_results(models=None, tasks=None, *, require_model_meta=True, include_remote=True, validate_and_filter=False, only_main_score=False, load_experiments=LoadExperimentEnum.MATCH_KWARGS, experiment_kwargs=None)
¶
Loads the results from the cache directory and returns a BenchmarkResults object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Sequence[str] | Iterable[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] | Iterable[AbsTask] | Benchmark | Sequence[Benchmark] | str | None
|
A list of task names to load the results for. If str is passed, then benchmark will be loaded. If Benchmark is passed, then all tasks in the benchmark will be loaded. 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
|
load_experiments
|
LoadExperimentEnum | str
|
If True, it will also load results from experiment folders. |
MATCH_KWARGS
|
experiment_kwargs
|
Mapping[str, Any] | list[Mapping[str, Any]] | None
|
If specified, it will only load results from experiments with the specified kwargs. Only used if load_experiments is True. |
None
|
Returns:
| Type | Description |
|---|---|
BenchmarkResults
|
A BenchmarkResults object containing the results for the specified models and tasks. |
Examples:
>>> import mteb
>>> cache = mteb.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/result_cache.py
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 | |
load_task_result(task_name, model_name, model_revision=None, raise_if_not_found=False, prioritize_remote=False, experiment_name=None)
¶
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
|
experiment_name
|
str | None
|
Optional experiment folder name (a valid directory name). If None, the default is used. |
None
|
Returns:
| Type | Description |
|---|---|
TaskResult | None
|
The results of the task, or None if not found. |
Source code in mteb/cache/result_cache.py
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 | |
save_to_cache(task_result, model_name, model_revision=None, *, encode_kwargs=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
|
encode_kwargs
|
Mapping[str, Any] | None
|
The keyword arguments passed to the model's encode method during evaluation. |
None
|
Source code in mteb/cache/result_cache.py
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 | |
submit_results(models=None, *, create_pr=False)
¶
Create a commit of the results to the official MTEB results repository (https://github.com/embeddings-benchmark/results).
It does this by downloading the remote (if not downloaded already) and
submitting the diff from the local result to the repository. Requires PyGithub
to be installed if create_pr=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Sequence[str] | Sequence[ModelMeta] | str | ModelMeta | None
|
Model(s) whose results should be submitted. Can either a list of string or ModelMeta objects. If None it will get all models from local cache. |
None
|
create_pr
|
bool
|
If True, create a PR directly to the remote. If False, prints instructions for manual submission. |
False
|
Returns:
| Type | Description |
|---|---|
SubmitResultsResponse
|
Dictionary containing submission metadata: - status: "ready_for_submission" or "pr_created" - models_submitted: list of (model_name, revision) tuples - result_count: number of result files submitted - pr_url: URL to created PR (only if create_pr=True) - pr_number: PR number (only if create_pr=True) - fork_url: URL to user's fork (only if create_pr=True) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no models found or invalid input. |
RuntimeError
|
If git operations fail. |
ImportError
|
If create_pr=True and PyGithub is not installed. |
GithubException
|
If GitHub API operations fail. |
Examples:
>>> import mteb
>>> cache = mteb.ResultCache()
>>> model_meta = mteb.get_model_meta(...)
>>> tasks = mteb.get_tasks(...)
>>> results = mteb.evaluate(model_meta, tasks, cache=cache)
>>>
>>> # Manual submission (step-by-step)
>>> submission = cache.submit_results(model_meta, create_pr=False)
>>> # Follow printed instructions
>>>
>>> # Automated submission
>>> submission = cache.submit_results(model_meta, create_pr=True)
>>> print(f"PR created: {submission['pr_url']}")
Source code in mteb/cache/result_cache.py
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 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 | |
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
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 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 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 | |
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.
main_score
property
¶
Get the main score of the result.
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[str, Any]
|
The dictionary to create the TaskResult from. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The created TaskResult object. |
Source code in mteb/results/task_result.py
332 333 334 335 336 337 338 339 340 341 342 | |
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 |
|---|---|
TaskResult
|
The loaded TaskResult object. |
Source code in mteb/results/task_result.py
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 | |
from_task_results(task, scores, evaluation_time, kg_co2_emissions=None, date=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, Mapping[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
|
date
|
datetime | None
|
The date the model was trained on. |
None
|
Source code in mteb/results/task_result.py
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 | |
from_validated(**data)
classmethod
¶
Create a TaskResult from validated data.
Returns:
| Type | Description |
|---|---|
TaskResult
|
The created TaskResult object. |
Source code in mteb/results/task_result.py
629 630 631 632 633 634 635 636 | |
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
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 | |
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
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |
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]], float]
|
The aggregation function to use. |
mean
|
Returns:
| Type | Description |
|---|---|
float
|
The result of the aggregation function on the scores. |
Source code in mteb/results/task_result.py
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 | |
is_mergeable(result, criteria=['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 "dataset_revision" or "mteb_version" (opt-in). It will always check that the task name match. |
['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
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 | |
merge(new_results, criteria=['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. |
['dataset_revision']
|
Returns:
| Type | Description |
|---|---|
TaskResult
|
A new TaskResult object with the merged scores. |
Source code in mteb/results/task_result.py
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 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 | |
only_main_score()
¶
Return a new TaskResult object with only the main score.
Returns:
| Type | Description |
|---|---|
TaskResult
|
A new TaskResult object with only the main score. |
Source code in mteb/results/task_result.py
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | |
to_dict()
¶
Convert the TaskResult to a dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The TaskResult as a dictionary. |
Source code in mteb/results/task_result.py
324 325 326 327 328 329 330 | |
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
359 360 361 362 363 364 365 366 367 368 369 370 | |
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 |
|---|---|
TaskResult
|
A new TaskResult object with the validated and filtered scores. |
Source code in mteb/results/task_result.py
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 | |
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
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 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
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[Modalities]
|
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_disk(path)
classmethod
¶
Load ModelResult from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the JSON file to load. |
required |
Returns:
| Type | Description |
|---|---|
ModelResult
|
The loaded ModelResult object. |
Source code in mteb/results/model_result.py
447 448 449 450 451 452 453 454 455 456 457 458 | |
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
116 117 118 119 120 121 122 123 124 125 126 127 | |
push_model_results(user=None, *, benchmark=None, create_pr=False, raise_error=False)
¶
Push the model results to the Hugging Face Hub.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
str | None
|
The user or organization of results source. |
None
|
benchmark
|
Benchmark | Sequence[Benchmark] | None
|
Whether to push the benchmark results. |
None
|
create_pr
|
bool
|
Whether to create a pull request |
False
|
raise_error
|
bool
|
Whether to push results if model have missing scores. |
False
|
Source code in mteb/results/model_result.py
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 | |
select_tasks(tasks)
¶
Select tasks from the ModelResult based on a list of AbsTask objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tasks
|
Iterable[AbsTask]
|
A sequence of AbsTask objects to select from the ModelResult. |
required |
Source code in mteb/results/model_result.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
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] | str | 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
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 | |
to_disk(path)
¶
Save ModelResult to disk as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the file to save. |
required |
Source code in mteb/results/model_result.py
438 439 440 441 442 443 444 445 | |
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
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 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 | |
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
526 527 528 529 | |
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
552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
from_validated(**data)
classmethod
¶
Create BenchmarkResults from validated data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
Arbitrary keyword arguments containing the data. |
{}
|
Returns:
| Type | Description |
|---|---|
BenchmarkResults
|
An instance of BenchmarkResults. |
Source code in mteb/results/benchmark_results.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |
get_aggregated_scores()
¶
Get aggregated scores for each model.
When a benchmark is associated with these results, uses
:meth:Benchmark.get_score to compute scores. Otherwise computes
the equivalent statistics directly from all task results.
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, float | None]] | dict[str, dict[str, dict[str, float | None]]]
|
A dict mapping each model name to a dict with the keys: |
dict[str, dict[str, float | None]] | dict[str, dict[str, dict[str, float | None]]]
|
|
dict[str, dict[str, float | None]] | dict[str, dict[str, dict[str, float | None]]]
|
|
Examples:
>>> bench_results.get_aggregated_scores()
{
"model1": {"Mean(Task)": 0.5, "Mean(TaskType)": 0.52},
"model2": {"Mean(Task)": 0.45, "Mean(TaskType)": 0.48},
}
Source code in mteb/results/benchmark_results.py
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 | |
get_benchmark_result()
¶
Get aggregated scores for each model in the benchmark.
Uses the benchmark's summary table creation method to compute scores.
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with the aggregated benchmark scores for each model. |
Source code in mteb/results/benchmark_results.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
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 |
|---|---|
BenchmarkResults
|
A new BenchmarkResults object with the revisions joined. |
Source code in mteb/results/benchmark_results.py
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 | |
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 |
|---|---|
BenchmarkResults
|
A new BenchmarkResults object with the filtered models. |
Source code in mteb/results/benchmark_results.py
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 | |
select_tasks(tasks)
¶
Select tasks from the benchmark results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tasks
|
Iterable[AbsTask]
|
List of tasks to select. Can be a list of AbsTask objects or task names. |
required |
Returns:
| Type | Description |
|---|---|
BenchmarkResults
|
A new BenchmarkResults object with the selected tasks. |
Source code in mteb/results/benchmark_results.py
112 113 114 115 116 117 118 119 120 121 122 123 124 | |
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', 'language']
|
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. - "language": Aggregates the scores by language. The DataFrame will have one row per model and language. |
'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
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 | |
to_dict()
¶
Convert BenchmarkResults to a dictionary.
Source code in mteb/results/benchmark_results.py
522 523 524 | |
to_disk(path)
¶
Save the BenchmarkResults to a JSON file.
Source code in mteb/results/benchmark_results.py
531 532 533 534 535 | |