transformer_qa
allennlp_models.rc.predictors.transformer_qa
TransformerQAPredictor#
@Predictor.register("transformer_qa")
class TransformerQAPredictor(Predictor):
| def __init__(
| self,
| model: Model,
| dataset_reader: DatasetReader
| ) -> None
Predictor for the TransformerQA
model,
and any other model that takes a question and passage as input.
predict#
class TransformerQAPredictor(Predictor):
| ...
| def predict(self, question: str, passage: str) -> JsonDict
Make a machine comprehension prediction on the supplied input. See https://rajpurkar.github.io/SQuAD-explorer/ for more information about the machine comprehension task.
Parameters¶
-
question :
str
A question about the content in the supplied paragraph. -
passage :
str
A paragraph of information relevant to the question.
Returns¶
JsonDict
A dictionary that represents the prediction made by the system. The answer string will be under the"best_span_str"
key.
predict_json#
class TransformerQAPredictor(Predictor):
| ...
| def predict_json(self, inputs: JsonDict) -> JsonDict
predictions_to_labeled_instances#
class TransformerQAPredictor(Predictor):
| ...
| def predictions_to_labeled_instances(
| self,
| instance: Instance,
| outputs: Dict[str, numpy.ndarray]
| ) -> List[Instance]
predict_batch_json#
class TransformerQAPredictor(Predictor):
| ...
| def predict_batch_json(self, inputs: List[JsonDict]) -> List[JsonDict]
predict_batch_instance#
class TransformerQAPredictor(Predictor):
| ...
| def predict_batch_instance(
| self,
| instances: List[Instance]
| ) -> List[JsonDict]