๐Ÿ“„ 8Kยถ

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

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.