π normalized_sacrebleuΒΆ
Note
ID: metrics.normalized_sacrebleu | Type: MetricPipeline
{
"main_score": "sacrebleu",
"metric": {
"type": "normalized_sacrebleu"
},
"preprocess_steps": [
{
"field_to_field": [
[
"task_data/target_language",
"task_data/tokenize"
]
],
"get_default": "en",
"not_exist_ok": true,
"type": "copy_fields"
},
{
"mappers": {
"task_data/tokenize": {
"Arabic": "intl",
"French": null,
"German": null,
"Japanese": "ja-mecab",
"Korean": "ko-mecab",
"Portuguese": null,
"Spanish": null,
"ar": "intl",
"de": null,
"deutch": null,
"en": null,
"english": null,
"es": null,
"fr": null,
"french": null,
"ja": "ja-mecab",
"japanese": "ja-mecab",
"ko": "ko-mecab",
"pt": null,
"romanian": null
}
},
"strict": true,
"type": "map_instance_values"
}
],
"type": "metric_pipeline"
}
Explanation about CopyFieldsΒΆ
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 CopyField(field_to_field={βaβ: βbβ} would yield {βaβ: 2, βbβ: 2}, and when processed by CopyField(field_to_field={βaβ: βcβ} would yield {βaβ: 2, βbβ: 3, βcβ: 2}
with field names containing / , we can also copy inside the field: CopyFields(field_to_field={βa/0β: βaβ}) would process instance {βaβ: [1, 3]} into {βaβ: 1}
Explanation about MapInstanceValuesΒΆ
A class used to map instance values into other values.
This class is a type of StreamInstanceOperator, it maps values of instances in a stream using predefined mappers.
- Attributes:
- mappers (Dict[str, Dict[str, str]]): The mappers to use for mapping instance values.
Keys are the names of the fields to be mapped, and values are dictionaries that define the mapping from old values to new values.
- strict (bool): If True, the mapping is applied strictly. That means if a value
does not exist in the mapper, it will raise a KeyError. If False, values that are not present in the mapper are kept as they are.
- process_every_value (bool): If True, all fields to be mapped should be lists, and the mapping
is to be applied to their individual elements. If False, mapping is only applied to a field containing a single value.
- Examples:
MapInstanceValues(mappers={βaβ: {β1β: βhiβ, β2β: βbyeβ}}) replaces β1β with βhiβ and β2β with βbyeβ in field βaβ in all instances of all streams: instance {βaβ:β1β, βbβ: 2} becomes {βaβ:βhiβ, βbβ: 2}.
MapInstanceValues(mappers={βaβ: {β1β: βhiβ, β2β: βbyeβ}}, process_every_element=True) Assuming field βaβ is a list of values, potentially including β1β-s and β2β-s, this replaces each such β1β with βhiβ and β2β β with βbyeβ in all instances of all streams: instance {βaβ: [β1β, β2β], βbβ: 2} becomes {βaβ: [βhiβ, βbyeβ], βbβ: 2}.
MapInstanceValues(mappers={βaβ: {β1β: βhiβ, β2β: βbyeβ}}, strict=True) To ensure that all values of field βaβ are mapped in every instance, use strict=True. Input instance {βaβ:β3β, βbβ: 2} will raise an exception per the above call, because β3β is not a key in the mapper of βaβ.
MapInstanceValues(mappers={βaβ: {str([1,2,3,4]): βAllβ, str([]): βNoneβ}}, strict=True) replaces a list [1,2,3,4] with the string βAllβ and an empty list by string βNoneβ. Note that mapped values are defined by their string representation, so mapped values must be converted to strings.
Read more about catalog usage here.