<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/bert_question_answerer.py#L32-L103) |

Class that performs Bert question answering on text.

    tflite_support.task.text.BertQuestionAnswerer(
        options: https://developers.google.com/edge/api/tflite/python/tflite_support/task/text/BertQuestionAnswererOptions,
        cpp_bert_question_answerer: _CppBertQuestionAnswerer
    ) -> None

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `options` | <br /> <br /> |

<br />

## Methods

### `answer`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/bert_question_answerer.py#L79-L99)

    answer(
        context: str, question: str
    ) -> https://developers.google.com/edge/api/tflite/python/tflite_support/task/processor/QuestionAnswererResult

Answers question based on the context.

Could be empty if no answer was
found from the given context.

<br />

<br />

<br />

| Args ||
|---|---|
| `context` | Context the question bases on. |
| `question` | Question to ask. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| Question answerer result. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If any of the input arguments is invalid. |
| `RuntimeError` | If failed to calculate the embedding vector. |

<br />

### `create_from_file`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/bert_question_answerer.py#L42-L58)

    @classmethod
    create_from_file(
        file_path: str
    ) -> 'BertQuestionAnswerer'

Creates the `BertQuestionAnswerer` object from a TensorFlow Lite model.

<br />

<br />

<br />

| Args ||
|---|---|
| `file_path` | Path to the model. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `BertQuestionAnswerer` object that's created from the model file. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If failed to create `BertQuestionAnswerer` object from the provided file such as invalid file. |
| `RuntimeError` | If other types of error occurred. |

<br />

### `create_from_options`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/bert_question_answerer.py#L60-L77)

    @classmethod
    create_from_options(
        options: https://developers.google.com/edge/api/tflite/python/tflite_support/task/text/BertQuestionAnswererOptions
    ) -> 'BertQuestionAnswerer'

Creates the `BertQuestionAnswerer` object from the options.

<br />

<br />

<br />

| Args ||
|---|---|
| `options` | Options for the Bert question answerer task. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `BertQuestionAnswerer` object that's created from `options`. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If failed to create `BertQuestionAnswerer` object from `BertQuestionAnswererOptions` such as missing the model. |
| `RuntimeError` | If other types of error occurred. |

<br />