π coedit_gecΒΆ
Note
ID: cards.coedit_gec | 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"
},
{
"field_to_field": {
"src": "original_text"
},
"type": "rename_fields"
},
{
"fields": [
"tgt"
],
"to_field": "corrected_texts",
"type": "list_field_values"
}
],
"task": "tasks.grammatical_error_correction",
"templates": [
"templates.grammatical_error_correction.simple"
],
"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 RenameFieldsΒΆ
Renames fields.
Move value from one field to another, potentially, if βuse_queryβ=True, from one branch into another. Remove the from field, potentially part of it in case of use_query.
- Examples:
RenameFields(field_to_field={βbβ: βcβ}) will change inputs [{βaβ: 1, βbβ: 2}, {βaβ: 2, βbβ: 3}] to [{βaβ: 1, βcβ: 2}, {βaβ: 2, βcβ: 3}]
RenameFields(field_to_field={βbβ: βc/dβ}, use_query=True) will change inputs [{βaβ: 1, βbβ: 2}, {βaβ: 2, βbβ: 3}] to [{βaβ: 1, βcβ: {βdβ: 2}}, {βaβ: 2, βcβ: {βdβ: 3}}]
RenameFields(field_to_field={βbβ: βb/dβ}, use_query=True) will change inputs [{βaβ: 1, βbβ: 2}, {βaβ: 2, βbβ: 3}] to [{βaβ: 1, βbβ: {βdβ: 2}}, {βaβ: 2, βbβ: {βdβ: 3}}]
RenameFields(field_to_field={βb/c/eβ: βb/dβ}, use_query=True) will change inputs [{βaβ: 1, βbβ: {βcβ: {βeβ: 2, βfβ: 20}}}] to [{βaβ: 1, βbβ: {βcβ: {βfβ: 20}, βdβ: 2}}]
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 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: tasks.grammatical_error_correction, templates.grammatical_error_correction.simple, splitters.small_no_test
Read more about catalog usage here.