createFromFile static method

BertQuestionAnswerer createFromFile(
  1. File modelFile
)

Generic API to create the QuestionAnswerer for bert models with metadata populated. The API expects a Bert based TFLite model with metadata containing the following information:

  • input_process_units for Wordpiece/Sentencepiece Tokenizer - Wordpiece Tokenizer can be used for a MobileBert model, Sentencepiece Tokenizer Tokenizer can be used for an Albert model.
  • 3 input tensors with names "ids", "mask" and "segment_ids".
  • 2 output tensors with names "end_logits" and "start_logits".

Create BertQuestionAnswerer from modelFile.

throws FileSystemException If model file fails to load.

Implementation

static BertQuestionAnswerer createFromFile(File modelFile) {
  return create(modelFile.path);
}