π SquadΒΆ
Note
ID: metrics.squad | Type: MetricPipeline
{
"__type__": "metric_pipeline",
"main_score": "f1",
"metric": {
"__type__": "squad"
},
"preprocess_steps": [
{
"__type__": "add_id"
},
{
"__type__": "set",
"fields": {
"prediction_template": {
"id": "ID",
"prediction_text": "PRED"
},
"reference_template": {
"answers": {
"answer_start": [
-1
],
"text": "REF"
},
"id": "ID"
}
},
"use_deepcopy": true
},
{
"__type__": "copy",
"field_to_field": [
[
"references",
"reference_template/answers/text"
],
[
"prediction",
"prediction_template/prediction_text"
],
[
"id",
"prediction_template/id"
],
[
"id",
"reference_template/id"
]
]
},
{
"__type__": "copy",
"field_to_field": [
[
"reference_template",
"references"
],
[
"prediction_template",
"prediction"
]
]
}
]
}
Explanation about AddIDΒΆ
Stores a unique id value in the designated βid_field_nameβ field of the given instance.
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 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.
Read more about catalog usage here.