[ allennlp.data.fields.metadata_field ]
class MetadataField(Field[DataArray], Mapping[str, Any]): | def __init__(self, metadata: Any) -> None
MetadataField is a
Field that does not get converted into tensors. It just carries
side information that might be needed later on, for computing some third-party metric, or
outputting debugging information, or whatever else you need. We use this in the BiDAF model,
for instance, to keep track of question IDs and passage token offsets, so we can more easily
use the official evaluation script to compute metrics.
We don't try to do any kind of smart combination of this field for batched input - when you use
Field in a model, you'll get a list of metadata objects, one for each instance in the
- metadata :
Some object containing the metadata that you want to store. It's likely that you'll want this to be a dictionary, but it could be anything you want.
| @overrides | def get_padding_lengths(self) -> Dict[str, int]
| @overrides | def as_tensor(self, padding_lengths: Dict[str, int]) -> DataArray
| @overrides | def empty_field(self) -> "MetadataField"
| @overrides | def batch_tensors( | self, | tensor_list: List[DataArray] | ) -> List[DataArray]