tensorflow/lite/g3doc/api_docs/java/org/tensorflow/lite/task/text/qa/BertQuestionAnswerer.html
public class BertQuestionAnswerer
Returns the most possible answers on a given question for QA models (BERT, Albert, etc.).
The API expects a Bert based TFLite model with metadata containing the following information:
| class | BertQuestionAnswerer.BertQuestionAnswererOptions | Options for setting up a BertQuestionAnswerer. |
| List<QaAnswer> |
answer(String context, String question)
Answers question based on context, and returns a list of possible QaAnswers.
|
| static BertQuestionAnswerer |
createAlbertQuestionAnswererFromFile(Context context, String modelPath, String sentencePieceModelPath)
Creates a BertQuestionAnswerer instance with an Albert model and a sentence piece model file.
|
| static BertQuestionAnswerer |
createBertQuestionAnswererFromFile(Context context, String modelPath, String vocabPath)
Creates a BertQuestionAnswerer instance with a Bert model and a vocabulary file.
|
| static BertQuestionAnswerer |
createFromFile(Context context, String modelPath)
Creates a BertQuestionAnswerer instance from the default BertQuestionAnswerer.BertQuestionAnswererOptions.
|
| static BertQuestionAnswerer |
createFromFile(File modelFile)
Creates a BertQuestionAnswerer instance from the default BertQuestionAnswerer.BertQuestionAnswererOptions.
|
| static BertQuestionAnswerer |
createFromFileAndOptions(File modelFile, BertQuestionAnswerer.BertQuestionAnswererOptions options)
Creates a BertQuestionAnswerer instance from BertQuestionAnswerer.BertQuestionAnswererOptions.
|
| static BertQuestionAnswerer |
createFromFileAndOptions(Context context, String modelPath, BertQuestionAnswerer.BertQuestionAnswererOptions options)
Creates a BertQuestionAnswerer instance from BertQuestionAnswerer.BertQuestionAnswererOptions.
|
From class org.tensorflow.lite.task.core.BaseTaskApi
| synchronized void | close() Release the memory allocated from C++ and deregister the library from the static holder.
| | long | getNativeHandle() | | boolean | isClosed() |
From class java.lang.Object
| boolean | equals(Object arg0) | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |
From interface java.io.Closeable
| abstract void | close() |
From interface org.tensorflow.lite.task.text.qa.QuestionAnswerer
| abstract List<QaAnswer> |
answer(String context, String question)
Answers question based on context, and returns a list of possible QaAnswers.
|
From interface java.lang.AutoCloseable
| abstract void | close() |
Answers question based on context, and returns a list of possible QaAnswers. Could be empty if no answer was found from the given context.
| context | context the question bases on | | question | question to ask |
QaAnswerCreates a BertQuestionAnswerer instance with an Albert model and a sentence piece model file.
One suitable model is: https://tfhub.dev/tensorflow/lite-model/albert\_lite\_base/squadv1/1
| context | android context | | modelPath | file path to the Albert model. Note: The model should not be compressed | | sentencePieceModelPath | file path to the sentence piece model file. Note: The model should not be compressed |
BertQuestionAnswerer instance| IOException | If model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates a BertQuestionAnswerer instance with a Bert model and a vocabulary file.
One suitable model is: https://tfhub.dev/tensorflow/lite-model/mobilebert/1/default/1
| context | android context | | modelPath | file path to the Bert model. Note: The model should not be compressed | | vocabPath | file path to the vocabulary file. Note: The file should not be compressed |
BertQuestionAnswerer instance| IOException | If model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates a BertQuestionAnswerer instance from the default BertQuestionAnswerer.BertQuestionAnswererOptions.
| context | android context | | modelPath | file path to the model with metadata. Note: The model should not be compressed |
BertQuestionAnswerer instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates a BertQuestionAnswerer instance from the default BertQuestionAnswerer.BertQuestionAnswererOptions.
| modelFile | a File object of the model |
BertQuestionAnswerer instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates a BertQuestionAnswerer instance from BertQuestionAnswerer.BertQuestionAnswererOptions.
| modelFile | a File object of the model |
| options | |
BertQuestionAnswerer instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates a BertQuestionAnswerer instance from BertQuestionAnswerer.BertQuestionAnswererOptions.
| context | android context | | modelPath | file path to the model with metadata. Note: The model should not be compressed | | options | |
BertQuestionAnswerer instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |