Tasks¶
A task is an implementation of a dataset for evaluation. It could, for instance, be the MIRACL dataset consisting of queries, a corpus of documents ,and the correct documents to retrieve for a given query. In addition to the dataset, a task includes the specifications for how a model should be run on the dataset and how its output should be evaluated. Each task also comes with extensive metadata including the license, who annotated the data, etc.

mteb
Utilities¶
mteb.get_tasks(tasks=None, *, languages=None, script=None, domains=None, task_types=None, categories=None, exclude_superseded=True, eval_splits=None, exclusive_language_filter=False, modalities=None, exclusive_modality_filter=False, exclude_aggregate=False, exclude_private=True)
¶
Get a list of tasks based on the specified filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks
|
list[str] | None
|
A list of task names to include. If None, all tasks which pass the filters are included. |
None
|
languages
|
list[str] | None
|
A list of languages either specified as 3 letter languages codes (ISO 639-3, e.g. "eng") or as script languages codes e.g. "eng-Latn". For multilingual tasks this will also remove languages that are not in the specified list. |
None
|
script
|
list[str] | None
|
A list of script codes (ISO 15924 codes, e.g. "Latn"). If None, all scripts are included. For multilingual tasks this will also remove scripts that are not in the specified list. |
None
|
domains
|
list[TaskDomain] | None
|
A list of task domains, e.g. "Legal", "Medical", "Fiction". |
None
|
task_types
|
list[TaskType] | None
|
A string specifying the type of task e.g. "Classification" or "Retrieval". If None, all tasks are included. |
None
|
categories
|
list[TaskCategory] | None
|
A list of task categories these include "t2t" (text to text), "t2i" (text to image). See TaskMetadata for the full list. |
None
|
exclude_superseded
|
bool
|
A boolean flag to exclude datasets which are superseded by another. |
True
|
eval_splits
|
list[str] | None
|
A list of evaluation splits to include. If None, all splits are included. |
None
|
exclusive_language_filter
|
bool
|
Some datasets contains more than one language e.g. for STS22 the subset "de-en" contain eng and deu. If exclusive_language_filter is set to False both of these will be kept, but if set to True only those that contains all the languages specified will be kept. |
False
|
modalities
|
list[Modalities] | None
|
A list of modalities to include. If None, all modalities are included. |
None
|
exclusive_modality_filter
|
bool
|
If True, only keep tasks where all filter modalities are included in the task's modalities and ALL task modalities are in filter modalities (exact match). If False, keep tasks if any of the task's modalities match the filter modalities. |
False
|
exclude_aggregate
|
bool
|
If True, exclude aggregate tasks. If False, both aggregate and non-aggregate tasks are returned. |
False
|
exclude_private
|
bool
|
If True (default), exclude private/closed datasets (is_public=False). If False, include both public and private datasets. |
True
|
Returns:
Type | Description |
---|---|
MTEBTasks
|
A list of all initialized tasks objects which pass all of the filters (AND operation). |
Examples:
>>> get_tasks(languages=["eng", "deu"], script=["Latn"], domains=["Legal"])
>>> get_tasks(languages=["eng"], script=["Latn"], task_types=["Classification"])
>>> get_tasks(languages=["eng"], script=["Latn"], task_types=["Clustering"], exclude_superseded=False)
>>> get_tasks(languages=["eng"], tasks=["WikipediaRetrievalMultilingual"], eval_splits=["test"])
>>> get_tasks(tasks=["STS22"], languages=["eng"], exclusive_language_filter=True) # don't include multilingual subsets containing English
Source code in mteb/overview.py
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 |
|
mteb.get_task(task_name, languages=None, script=None, eval_splits=None, hf_subsets=None, exclusive_language_filter=False, modalities=None, exclusive_modality_filter=False)
¶
Get a task by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name
|
str
|
The name of the task to fetch. |
required |
languages
|
list[str] | None
|
A list of languages either specified as 3 letter languages codes (ISO 639-3, e.g. "eng") or as script languages codes e.g. "eng-Latn". For multilingual tasks this will also remove languages that are not in the specified list. |
None
|
script
|
list[str] | None
|
A list of script codes (ISO 15924 codes). If None, all scripts are included. For multilingual tasks this will also remove scripts |
None
|
eval_splits
|
list[str] | None
|
A list of evaluation splits to include. If None, all splits are included. |
None
|
hf_subsets
|
list[str] | None
|
A list of Huggingface subsets to evaluate on. |
None
|
exclusive_language_filter
|
bool
|
Some datasets contains more than one language e.g. for STS22 the subset "de-en" contain eng and deu. If exclusive_language_filter is set to False both of these will be kept, but if set to True only those that contains all the languages specified will be kept. |
False
|
modalities
|
list[Modalities] | None
|
A list of modalities to include. If None, all modalities are included. |
None
|
exclusive_modality_filter
|
bool
|
If True, only keep tasks where all filter modalities are included in the task's modalities and ALL task modalities are in filter modalities (exact match). If False, keep tasks if any of the task's modalities match the filter modalities. |
False
|
Returns:
Type | Description |
---|---|
AbsTask
|
An initialized task object. |
Examples:
>>> get_task("BornholmBitextMining")
Source code in mteb/overview.py
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 |
|
Metadata¶
Each task also contains extensive metadata. We annotate this using the following object, which allows us to use pydantic to validate the metadata.
mteb.TaskMetadata
¶
Bases: BaseModel
Metadata for a task.
Attributes:
Name | Type | Description |
---|---|---|
dataset |
MetadataDatasetDict
|
All arguments to pass to datasets.load_dataset to load the dataset for the task. |
name |
str
|
The name of the task. |
description |
str
|
A description of the task. |
type |
TaskType
|
The type of the task. These includes "Classification", "Summarization", "STS", "Retrieval", "Reranking", "Clustering", "PairClassification", "BitextMining". The type should match the abstask type. |
category |
TaskCategory | None
|
The category of the task. E.g. includes "t2t" (text to text), "t2i" (text to image). |
reference |
StrURL | None
|
A URL to the documentation of the task. E.g. a published paper. |
eval_splits |
list[str]
|
The splits of the dataset used for evaluation. |
eval_langs |
Languages
|
The languages of the dataset used for evaluation. Languages follows a ETF BCP 47 standard consisting of "{language}-{script}" tag (e.g. "eng-Latn"). Where language is specified as a list of ISO 639-3 language codes (e.g. "eng") followed by ISO 15924 script codes (e.g. "Latn"). Can be either a list of languages or a dictionary mapping huggingface subsets to lists of languages (e.g. if a the huggingface dataset contain different languages). |
main_score |
str
|
The main score used for evaluation. |
date |
tuple[StrDate, StrDate] | None
|
The date when the data was collected. Specified as a tuple of two dates. |
domains |
list[TaskDomain] | None
|
The domains of the data. These includes "Non-fiction", "Social", "Fiction", "News", "Academic", "Blog", "Encyclopaedic", "Government", "Legal", "Medical", "Poetry", "Religious", "Reviews", "Web", "Spoken", "Written". A dataset can belong to multiple domains. |
task_subtypes |
list[TaskSubtype] | None
|
The subtypes of the task. E.g. includes "Sentiment/Hate speech", "Thematic Clustering". Feel free to update the list as needed. |
license |
Licenses | StrURL | None
|
The license of the data specified as lowercase, e.g. "cc-by-nc-4.0". If the license is not specified, use "not specified". For custom licenses a URL is used. |
annotations_creators |
AnnotatorType | None
|
The type of the annotators. Includes "expert-annotated" (annotated by experts), "human-annotated" (annotated e.g. by mturkers), "derived" (derived from structure in the data). |
dialect |
list[str] | None
|
The dialect of the data, if applicable. Ideally specified as a BCP-47 language tag. Empty list if no dialects are present. |
sample_creation |
SampleCreationMethod | None
|
The method of text creation. Includes "found", "created", "machine-translated", "machine-translated and verified", and "machine-translated and localized". |
prompt |
str | PromptDict | None
|
The prompt used for the task. Can be a string or a dictionary containing the query and passage prompts. |
bibtex_citation |
str | None
|
The BibTeX citation for the dataset. Should be an empty string if no citation is available. |
adapted_from |
Sequence[str] | None
|
Datasets adapted (translated, sampled from, etc.) from other datasets. |
is_public |
bool
|
Whether the dataset is publicly available. If False (closed/private), a HuggingFace token is required to run the datasets. |
Source code in mteb/abstasks/task_metadata.py
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 |
|
bcp47_codes
property
¶
Return the languages and script codes of the dataset formatting in accordance with the BCP-47 standard.
descriptive_stat_path
property
¶
Return the path to the descriptive statistics file.
descriptive_stats
property
¶
Return the descriptive statistics for the dataset.
hf_subsets
property
¶
Return the huggingface subsets.
hf_subsets_to_langscripts
property
¶
Return a dictionary mapping huggingface subsets to languages.
intext_citation
property
¶
Create an in-text citation for the dataset.
is_multilingual
property
¶
Check if the task is multilingual.
languages
property
¶
Return the languages of the dataset as iso639-3 codes.
n_samples
property
¶
Returns the number of samples in the dataset
revision
property
¶
Return the dataset revision.
scripts
property
¶
Return the scripts of the dataset as iso15924 codes.
generate_dataset_card(existing_dataset_card=None)
¶
Generates a dataset card for the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
existing_dataset_card
|
DatasetCard | None
|
The existing dataset card to update. If None, a new dataset card will be created. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DatasetCard |
DatasetCard
|
The dataset card for the task. |
Source code in mteb/abstasks/task_metadata.py
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 |
|
is_filled()
¶
Check if all the metadata fields are filled.
Source code in mteb/abstasks/task_metadata.py
332 333 334 335 336 337 338 |
|
push_dataset_card_to_hub(repo_name)
¶
Pushes the dataset card to the huggingface hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_name
|
str
|
The name of the repository to push the dataset card to. |
required |
Source code in mteb/abstasks/task_metadata.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
Metadata Types¶
mteb.abstasks.task_metadata.AnnotatorType = Literal['expert-annotated', 'human-annotated', 'derived', 'LM-generated', 'LM-generated and reviewed']
module-attribute
¶
The type of the annotators. Is often important for understanding the quality of a dataset.
mteb.abstasks.task_metadata.SampleCreationMethod = Literal['found', 'created', 'human-translated and localized', 'human-translated', 'machine-translated', 'machine-translated and verified', 'machine-translated and localized', 'LM-generated and verified', 'machine-translated and LM verified', 'rendered', 'multiple']
module-attribute
¶
How the text was created. It can be an important factor for understanding the quality of a dataset. E.g. used to filter out machine-translated datasets.
mteb.abstasks.task_metadata.TaskCategory = Literal['t2t', 't2c', 'i2i', 'i2c', 'i2t', 't2i', 'it2t', 'it2i', 'i2it', 't2it', 'it2it']
module-attribute
¶
The category of the task. E.g. includes "t2t" (text to text), "t2i" (text to image) and "i2c" (image to category).
mteb.abstasks.task_metadata.TaskDomain = Literal['Academic', 'Blog', 'Constructed', 'Encyclopaedic', 'Engineering', 'Fiction', 'Government', 'Legal', 'Medical', 'News', 'Non-fiction', 'Poetry', 'Religious', 'Reviews', 'Scene', 'Social', 'Spoken', 'Subtitles', 'Web', 'Written', 'Programming', 'Chemistry', 'Financial', 'Entertainment']
module-attribute
¶
mteb.abstasks.task_metadata.TaskType = Literal[_TASK_TYPE]
module-attribute
¶
The type of the task. E.g. includes "Classification", "Retrieval" and "Clustering".
mteb.abstasks.task_metadata.TaskSubtype = Literal['Article retrieval', 'Patent retrieval', 'Conversational retrieval', 'Dialect pairing', 'Dialog Systems', 'Discourse coherence', 'Duplicate Image Retrieval', 'Language identification', 'Linguistic acceptability', 'Political classification', 'Question answering', 'Sentiment/Hate speech', 'Thematic clustering', 'Scientific Reranking', 'Claim verification', 'Topic classification', 'Code retrieval', 'False Friends', 'Cross-Lingual Semantic Discrimination', 'Textual Entailment', 'Counterfactual Detection', 'Emotion classification', 'Reasoning as Retrieval', 'Rendered Texts Understanding', 'Image Text Retrieval', 'Object recognition', 'Scene recognition', 'Caption Pairing', 'Emotion recognition', 'Textures recognition', 'Activity recognition', 'Tumor detection', 'Duplicate Detection', 'Rendered semantic textual similarity', 'Intent classification']
module-attribute
¶
The subtypes of the task. E.g. includes "Sentiment/Hate speech", "Thematic Clustering". This list can be updated as needed.
mteb.abstasks.task_metadata.PromptDict = TypedDict('PromptDict', {(prompt_type.value): strfor prompt_type in PromptType}, total=False)
module-attribute
¶
A dictionary containing the prompt used for the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
The prompt used for the queries in the task. |
required | |
document
|
The prompt used for the passages in the task. |
required |
The Task Object¶
All tasks in mteb
inherits from the following abstract class.
mteb.AbsTask
¶
AbsTask
¶
Bases: ABC
The abstract class for the tasks
Attributes:
Name | Type | Description |
---|---|---|
metadata |
TaskMetadata
|
The metadata describing the task |
dataset |
dict[HFSubset, DatasetDict] | None
|
The dataset represented as a dictionary on the form {"hf subset": {"split": Dataset}} where "split" is the dataset split (e.g. "test") and Dataset is a datasets.Dataset objedct. "hf subset" is the data subset on Huggingface typically used to denote the language e.g. datasets.load_dataset("data", "en"). If the dataset does not have a subset this is simply "default". |
seed |
The random seed used for reproducibility. |
|
hf_subsets |
list[HFSubset]
|
The list of Huggingface subsets to use. |
data_loaded |
bool
|
Denotes if the dataset is loaded or not. This is used to avoid loading the dataset multiple times. |
abstask_prompt |
str | None
|
The potential prompt of the abstask |
superseded_by |
str | None
|
Denotes the task that this task is superseeded by. Used to issue warning to users of outdated datasets, while maintaining reproducibility of existing benchmarks. |
fast_loading |
bool
|
Deprecated. Denotes if the task should be loaded using the fast loading method. This is only possible if the dataset have a "default" config. We don't recommend to use this method, and suggest to use different subsets for loading datasets. This was used only for historical reasons and will be removed in the future. |
Source code in mteb/abstasks/AbsTask.py
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 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 |
|
is_aggregate
property
¶
Whether the task is an aggregate of multiple tasks.
languages
property
¶
Returns the languages of the task.
modalities
property
¶
Returns the modalities of the task.
__init__(seed=42, **kwargs)
¶
The init function. This is called primarily to set the seed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed
|
int
|
An integer seed. |
42
|
kwargs
|
Any
|
arguments passed to subclasses. |
{}
|
Source code in mteb/abstasks/AbsTask.py
94 95 96 97 98 99 100 101 102 103 |
|
calculate_descriptive_statistics(overwrite_results=False)
¶
Calculates descriptive statistics from the dataset.
Source code in mteb/abstasks/AbsTask.py
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 |
|
check_if_dataset_is_superseded()
¶
Check if the dataset is superseded by a newer version.
Source code in mteb/abstasks/AbsTask.py
105 106 107 108 109 110 |
|
dataset_transform()
¶
A transform operations applied to the dataset after loading.
This method is useful when the dataset from Huggingface is not in an mteb
compatible format.
Override this method if your dataset requires additional transformation.
Source code in mteb/abstasks/AbsTask.py
112 113 114 115 116 117 118 |
|
evaluate(model, split='test', subsets_to_run=None, *, encode_kwargs, prediction_folder=None, **kwargs)
¶
Evaluates an MTEB compatible model on the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
MTEBModels
|
MTEB compatible model. Implements a encode(sentences) method, that encodes sentences and returns an array of embeddings |
required |
split
|
str
|
Which split (e.g. "test") to be used. |
'test'
|
subsets_to_run
|
list[HFSubset] | None
|
List of huggingface subsets (HFSubsets) to evaluate. If None, all subsets are evaluated. |
None
|
encode_kwargs
|
dict[str, Any]
|
Additional keyword arguments that are passed to the model's |
required |
prediction_folder
|
Path | None
|
Folder to save model predictions |
None
|
kwargs
|
Any
|
Additional keyword arguments that are passed to the _evaluate_subset method. |
{}
|
Source code in mteb/abstasks/AbsTask.py
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 |
|
fast_load()
¶
Deprecated. Load all subsets at once, then group by language. Using fast loading has two requirements:
- Each row in the dataset should have a 'lang' feature giving the corresponding language/language pair
- The datasets must have a 'default' config that loads all the subsets of the dataset (see more here)
Source code in mteb/abstasks/AbsTask.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
filter_eval_splits(eval_splits)
¶
Filter the evaluation splits of the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eval_splits
|
list[str] | None
|
A list of evaluation splits to keep. If None, all splits are kept. |
required |
Returns:
Type | Description |
---|---|
AbsTask
|
The filtered task |
Source code in mteb/abstasks/AbsTask.py
418 419 420 421 422 423 424 425 426 427 428 |
|
filter_languages(languages, script=None, hf_subsets=None, exclusive_language_filter=False)
¶
Filter the languages of the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
languages
|
list[str] | None
|
list of languages to filter the task by can be either a 3-letter langauge code (e.g. "eng") or also include the script (e.g. "eng-Latn") |
required |
script
|
list[str] | None
|
A list of scripts to filter the task by. Will be ignored if language code specified the script. If None, all scripts are included. If the language code does not specify the script the intersection of the language and script will be used. |
None
|
hf_subsets
|
list[HFSubset] | None
|
A list of huggingface subsets to filter on. This is useful if a dataset have multiple subsets containing the desired language, but you only want to test on one. An example is STS22 which e.g. have both "en" and "de-en" which both contains English. |
None
|
exclusive_language_filter
|
bool
|
Some datasets contains more than one language e.g. for STS22 the subset "de-en" contain eng and deu. If exclusive_language_filter is set to False both of these will be kept, but if set to True only those that contains all the languages specified will be kept. |
False
|
Returns:
Type | Description |
---|---|
AbsTask
|
The filtered task |
Source code in mteb/abstasks/AbsTask.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 494 495 496 497 498 499 |
|
filter_modalities(modalities, exclusive_modality_filter=False)
¶
Filter the modalities of the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
modalities
|
list[str] | None
|
A list of modalities to filter by. If None, the task is returned unchanged. |
required |
exclusive_modality_filter
|
bool
|
If True, only keep tasks where all filter modalities are included in the task's modalities and ALL task modalities are in filter modalities (exact match). If False, keep tasks if any of the task's modalities match the filter modalities. |
False
|
Returns:
Type | Description |
---|---|
AbsTask
|
The filtered task |
Source code in mteb/abstasks/AbsTask.py
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 |
|
load_data()
¶
Loads dataset from HuggingFace hub
This is the main loading function for Task. Do not overwrite this, instead we recommend using dataset_transform
, which is called after the
dataset is loaded using datasets.load_dataset
.
Source code in mteb/abstasks/AbsTask.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
push_dataset_to_hub(repo_name)
¶
Push the dataset to the HuggingFace Hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_name
|
str
|
The name of the repository to push the dataset to. |
required |
Examples:
>>> import mteb
>>> task = mteb.get_task("Caltech101")
>>> repo_name = f"myorg/{task.metadata.name}"
>>> # Push the dataset to the Hub
>>> task.push_dataset_to_hub(repo_name)
Source code in mteb/abstasks/AbsTask.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
|
stratified_subsampling(dataset_dict, seed, splits=['test'], label='label', n_samples=2048)
staticmethod
¶
Subsamples the dataset with stratification by the supplied label. Returns a datasetDict object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_dict
|
DatasetDict
|
the DatasetDict object. |
required |
seed
|
int
|
the random seed. |
required |
splits
|
list[str]
|
the splits of the dataset. |
['test']
|
label
|
str
|
the label with which the stratified sampling is based on. |
'label'
|
n_samples
|
int
|
Optional, number of samples to subsample. Default is max_n_samples. |
2048
|
Source code in mteb/abstasks/AbsTask.py
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 |
|
unload_data()
¶
Unloads the dataset from memory
Source code in mteb/abstasks/AbsTask.py
601 602 603 604 605 606 607 608 609 610 |
|