π coedit_error_detectionΒΆ
Note
ID: cards.coedit_error_detection | Type: TaskCard
{
"loader": {
"path": "grammarly/coedit",
"streaming": true,
"type": "load_hf"
},
"preprocess_steps": [
{
"condition": "eq",
"type": "filter_by_condition",
"values": {
"task": "gec"
}
},
"splitters.small_no_test",
{
"expression": "': '.join(src.split(': ')[1:])",
"to_field": "src",
"type": "execute_expression"
},
{
"fields": [
"tgt",
"src"
],
"to_field": "correct_and_incorrect",
"type": "list_field_values"
},
{
"field": "correct_and_incorrect",
"to_field": "text",
"type": "duplicate_by_list"
},
{
"index_of": "text",
"search_in": "correct_and_incorrect",
"to_field": "label",
"type": "index_of"
},
{
"fields": {
"class": "Grammatically incorrect",
"text_type": "text"
},
"type": "add_fields"
},
{
"page_size": 9223372036854775807,
"type": "shuffle"
}
],
"task": "tasks.classification.binary[metrics=[metrics.accuracy,metrics.f1_binary,metrics.precision_binary,metrics.recall_binary]]",
"templates": [
"templates.grammatical_error_detection.yes_no"
],
"type": "task_card"
}
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 IndexOfΒΆ
For a given instance, finds the offset of value of field βindex_ofβ, within the value of field βsearch_inβ.
Explanation about AddFieldsΒΆ
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_query (bool) : 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 AddFields(fields={βclassesβ: [βpositiveβ,βnegativesβ]})
# Add a βstartβ field under the βspanβ field with a value of 0 to all streams AddFields(fields={βspan/startβ: 0}
# Add a βclassesβ field with a value of a list βpositiveβ and βnegativeβ to βtrainβ stream AddFields(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. AddFields(fields={βclassesβ: alist}), use_deepcopy=True) # if now alist is modified, still the instances remain intact.
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 ListFieldValuesΒΆ
Concatenates values of multiple fields into a list, and assigns it to a new field.
Explanation about ShuffleΒΆ
Shuffles the order of instances in each page of a stream.
- Args (of superclass):
page_size (int): The size of each page in the stream. Defaults to 1000.
Explanation about FilterByConditionΒΆ
Filters a stream, yielding only instances for which the required values follows the required condition operator.
Raises an error if a required key is missing.
- Args:
values (Dict[str, Any]): Values that instances must match using the condition to be included in the output. condition: the name of the desired condition operator between the key and the value in values (βgtβ, βgeβ, βltβ, βleβ, βneβ, βeqβ) 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 βaβ>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
References: templates.grammatical_error_detection.yes_no, splitters.small_no_test
Read more about catalog usage here.