๐ 8Kยถ
Tags: region:us
Note
ID: cards.ffqa_filtered.8k | Type: TaskCard
{
"__description__": "The WikiQA task is the task of answering a question based on the information given in a Wikipedia document. We have built upon the short answer format data in Google Natural Questions to construct our QA task. It is formatted as a document and a question. We ensure the answer to the question is a short answer which is either a single word or a small sentence directly cut pasted from the document. Having the task structured as such, we canโฆ See the full description on the dataset page: https://huggingface.co/datasets/abacusai/WikiQA-Free_Form_QA.",
"__tags__": {
"region": "us"
},
"__type__": "task_card",
"loader": {
"__type__": "load_hf",
"path": "abacusai/WikiQA-Free_Form_QA"
},
"preprocess_steps": [
{
"__type__": "copy",
"field_to_field": {
"conversations/0/tok_len": "inputs_len",
"conversations/0/value": "inputs",
"conversations/1/value": "answer"
}
},
{
"__type__": "list_field_values",
"fields": [
"answer"
],
"to_field": "answers"
},
{
"__type__": "filter_by_condition",
"condition": "lt",
"values": {
"inputs_len": 8800
}
},
{
"__type__": "execute_expression",
"expression": "re.search(r\"Document:\\s(.*)(\\n\\n|$)\", inputs).group(1)",
"imports_list": [
"re"
],
"to_field": "context"
},
{
"__type__": "execute_expression",
"expression": "re.search(r\"Question:\\s(.*)(\\n\\n|$)\", inputs).group(1)",
"imports_list": [
"re"
],
"to_field": "question"
},
{
"__type__": "set",
"fields": {
"context_type": "document"
}
},
{
"__type__": "split_random_mix",
"mix": {
"test": "8k[10%]",
"train": "8k[80%]",
"validation": "8k[10%]"
}
}
],
"task": "tasks.qa.with_context.extractive",
"templates": "templates.qa.with_context.all"
}
Explanation about TaskCardยถ
TaskCard delineates the phases in transforming the source dataset into a model-input, and specifies the metrics for evaluation of model-output.
- Attributes:
loader: specifies the source address and the loading operator that can access that source and transform it into a unitxt multistream.
preprocess_steps: list of unitxt operators to process the data source into a model-input.
task: specifies the fields (of the already (pre)processed instance) making the inputs, the fields making the outputs, and the metrics to be used for evaluating the model output.
templates: format strings to be applied on the input fields (specified by the task) and the output fields. The template also carries the instructions and the list of postprocessing steps, to be applied to the model output.
Explanation about FilterByConditionยถ
Filters a stream, yielding only instances in which the values in required fields follow the required condition operator.
Raises an error if a required field name is missing from the input instance.
- Args:
values (Dict[str, Any]): Field names and respective Values that instances must match according the condition, to be included in the output. condition: the name of the desired condition operator between the specified (sub) fieldโs value and the provided constant value. Supported conditions are (โgtโ, โgeโ, โltโ, โleโ, โneโ, โeqโ, โinโ,โnot inโ) error_on_filtered_all (bool, optional): If True, raises an error if all instances are filtered out. Defaults to True.
- Examples:
FilterByCondition(values = {โaโ:4}, condition = โgtโ) will yield only instances where field โaโ contains a value > 4 FilterByCondition(values = {โaโ:4}, condition = โleโ) will yield only instances where โaโ<=4 FilterByCondition(values = {โaโ:[4,8]}, condition = โinโ) will yield only instances where โaโ is 4 or 8 FilterByCondition(values = {โaโ:[4,8]}, condition = โnot inโ) will yield only instances where โaโ different from 4 or 8 FilterByCondition(values = {โa/bโ:[4,8]}, condition = โnot inโ) will yield only instances where โaโ is
a dict in which key โbโ is mapped to a value that is neither 4 nor 8
- FilterByCondition(values = {โa[2]โ:4}, condition = โleโ) will yield only instances where โaโ is a list whose 3-rd
element is <= 4
Explanation about LoadHFยถ
Loads datasets from the Huggingface Hub.
It supports loading with or without streaming, and can filter datasets upon loading.
- Args:
path: The path or identifier of the dataset on the Huggingface Hub. name: An optional dataset name. data_dir: Optional directory to store downloaded data. split: Optional specification of which split to load. data_files: Optional specification of particular data files to load. streaming: Bool indicating if streaming should be used. filtering_lambda: A lambda function for filtering the data after loading. num_proc: Optional integer to specify the number of processes to use for parallel dataset loading.
- Example:
Loading glueโs mrpc dataset
load_hf = LoadHF(path='glue', name='mrpc')
Explanation about ListFieldValuesยถ
Concatenates values of multiple fields into a list, and assigns it to a new field.
Explanation about Copyยถ
Copies values from specified fields to specified fields.
- Args (of parent class):
field_to_field (Union[List[List], Dict[str, str]]): A list of lists, where each sublist contains the source field and the destination field, or a dictionary mapping source fields to destination fields.
- Examples:
An input instance {โaโ: 2, โbโ: 3}, when processed by Copy(field_to_field={โaโ: โbโ} would yield {โaโ: 2, โbโ: 2}, and when processed by Copy(field_to_field={โaโ: โcโ} would yield {โaโ: 2, โbโ: 3, โcโ: 2}
with field names containing / , we can also copy inside the field: Copy(field=โa/0โ,to_field=โaโ) would process instance {โaโ: [1, 3]} into {โaโ: 1}
Explanation about SplitRandomMixยถ
Splits a multistream into new streams (splits), whose names, source input stream, and amount of instances, are specified by arg โmixโ.
The keys of arg โmixโ, are the names of the new streams, the values are of the form: โname-of-source-stream[percentage-of-source-stream]โ Each input instance, of any input stream, is selected exactly once for inclusion in any of the output streams.
Examples: When processing a multistream made of two streams whose names are โtrainโ and โtestโ, by SplitRandomMix(mix = { โtrainโ: โtrain[99%]โ, โvalidationโ: โtrain[1%]โ, โtestโ: โtestโ }) the output is a multistream, whose three streams are named โtrainโ, โvalidationโ, and โtestโ. Output stream โtrainโ is made of randomly selected 99% of the instances of input stream โtrainโ, output stream โvalidationโ is made of the remaining 1% instances of input โtrainโ, and output stream โtestโ is made of the whole of input stream โtestโ.
When processing the above input multistream by SplitRandomMix(mix = { โtrainโ: โtrain[50%]+test[0.1]โ, โvalidationโ: โtrain[50%]+test[0.2]โ, โtestโ: โtest[0.7]โ }) the output is a multistream, whose three streams are named โtrainโ, โvalidationโ, and โtestโ. Output stream โtrainโ is made of randomly selected 50% of the instances of input stream โtrainโ + randomly selected 0.1 (i.e., 10%) of the instances of input stream โtestโ. Output stream โvalidationโ is made of the remaining 50% instances of input โtrainโ+ randomly selected 0.2 (i.e., 20%) of the original instances of input โtestโ, that were not selected for output โtrainโ, and output stream โtestโ is made of the remaining instances of input โtestโ.
Explanation about ExecuteExpressionยถ
Compute an expression, specified as a string to be eval-uated, over the instanceโs fields, and store the result in field to_field.
Raises an error if a field mentioned in the query is missing from the instance.
- Args:
expression (str): an expression to be evaluated over the fields of the instance to_field (str): the field where the result is to be stored into imports_list (List[str]): names of imports needed for the eval of the query (e.g. โreโ, โjsonโ)
- Examples:
When instance {โaโ: 2, โbโ: 3} is process-ed by operator ExecuteExpression(expression=โa+bโ, to_field = โcโ) the result is {โaโ: 2, โbโ: 3, โcโ: 5}
When instance {โaโ: โhelloโ, โbโ: โworldโ} is process-ed by operator ExecuteExpression(expression = โa+โ โ+bโ, to_field = โcโ) the result is {โaโ: โhelloโ, โbโ: โworldโ, โcโ: โhello worldโ}
Explanation about Setยถ
Adds specified fields to each instance in a given stream or all streams (default) If fields exist, updates them.
- Args:
- fields (Dict[str, object]): The fields to add to each instance.
Use โ/โ to access inner fields
use_deepcopy (bool) : Deep copy the input value to avoid later modifications
- Examples:
# Add a โclassesโ field with a value of a list โpositiveโ and โnegativeโ to all streams Set(fields={โclassesโ: [โpositiveโ,โnegativesโ]})
# Add a โstartโ field under the โspanโ field with a value of 0 to all streams Set(fields={โspan/startโ: 0}
# Add a โclassesโ field with a value of a list โpositiveโ and โnegativeโ to โtrainโ stream Set(fields={โclassesโ: [โpositiveโ,โnegativesโ], apply_to_stream=[โtrainโ]})
# Add a โclassesโ field on a given list, prevent modification of original list # from changing the instance. Set(fields={โclassesโ: alist}), use_deepcopy=True) # if now alist is modified, still the instances remain intact.
References: templates.qa.with_context.all, tasks.qa.with_context.extractive
Read more about catalog usage here.