Skip to content

babi

allennlp.data.dataset_readers.babi

[SOURCE]


BabiReader

@DatasetReader.register("babi")
class BabiReader(DatasetReader):
 | def __init__(
 |     self,
 |     keep_sentences: bool = False,
 |     token_indexers: Dict[str, TokenIndexer] = None,
 |     **kwargs
 | ) -> None

Reads one single task in the bAbI tasks format as formulated in Towards AI-Complete Question Answering: A Set of Prerequisite Toy Tasks (https://arxiv.org/abs/1502.05698). Since this class handle a single file, if one wants to load multiple tasks together it has to merge them into a single file and use this reader.

Registered as a DatasetReader with name "babi".

Parameters

  • keep_sentences : bool, optional (default = False)
    Whether to keep each sentence in the context or to concatenate them. Default is False that corresponds to concatenation.
  • token_indexers : Dict[str, TokenIndexer], optional (default = {"tokens": SingleIdTokenIndexer()})
    We use this to define the input representation for the text. See TokenIndexer.

text_to_instance

class BabiReader(DatasetReader):
 | ...
 | def text_to_instance(
 |     self,
 |     context: List[List[str]],
 |     question: List[str],
 |     answer: str,
 |     supports: List[int]
 | ) -> Instance

apply_token_indexers

class BabiReader(DatasetReader):
 | ...
 | def apply_token_indexers(self, instance: Instance) -> None