QA モデル (BERT、Albert など) の特定の質問に対して可能な限り多くの回答を返します。
API は、次の情報を含むメタデータを含む Bert ベースの TFLite モデルを想定しています。
- ワードピース/センテンスピース トークナイザーの input_process_units - ワードピース トークナイザーはMobileBertモデルに使用でき、センテンスピース トークナイザー トークナイザーはAlbertモデルに使用できます。
- 「ids」、「mask」、「segment_ids」という名前を持つ 3 つの入力テンソル。
- 「end_logits」と「start_logits」という名前の 2 つの出力テンソル。
ネストされたクラス
クラス | BertQuestionAnswerer.BertQuestionAnswererOptions | BertQuestionAnswerer を設定するためのオプション。 |
パブリックメソッド
一覧< QaAnswer > | |
静的BertQuestionAnswerer | createAlbertQuestionAnswererFromFile (コンテキスト context、文字列モデルパス、文字列文章ピースモデルパス) Albert モデルと文章モデル ファイルを使用して BertQuestionAnswerer インスタンスを作成します。 |
静的BertQuestionAnswerer | createBertQuestionAnswererFromFile (Context context、 String modelPath、 String vocabPath) Bert モデルと語彙ファイルを使用して BertQuestionAnswerer インスタンスを作成します。 |
静的BertQuestionAnswerer | createFromFile (コンテキスト context、文字列モデルパス) デフォルトの BertQuestionAnswerer.BertQuestionAnswererOptions からBertQuestionAnswerer インスタンスを作成します。 |
静的BertQuestionAnswerer | createFromFile (ファイルモデルファイル) デフォルトの BertQuestionAnswerer.BertQuestionAnswererOptions からBertQuestionAnswerer インスタンスを作成します。 |
静的BertQuestionAnswerer | |
静的BertQuestionAnswerer | createFromFileAndOptions (コンテキスト コンテキスト、文字列モデルパス、 BertQuestionAnswerer.BertQuestionAnswererOptionsオプション) |
継承されたメソッド
パブリックメソッド
public static BertQuestionAnswerer createAlbertQuestionAnswererFromFile (コンテキスト context、文字列モデルパス、文字列文ピースモデルパス)
Albert モデルと文章モデル ファイルを使用してBertQuestionAnswerer
インスタンスを作成します。
適切なモデルの 1 つは次のとおりです: https://tfhub.dev/tensorflow/lite-model/albert_lite_base/squadv1/1
パラメーター
コンテクスト | アンドロイドコンテキスト |
---|---|
モデルパス | Albert モデルへのファイル パス。注: モデルは圧縮しないでください。 |
文ピースモデルパス | センテンスピースモデルファイルへのファイルパス。注: モデルは圧縮しないでください。 |
戻り値
BertQuestionAnswerer
インスタンス
投げる
IO例外 | モデルファイルの読み込みに失敗した場合 |
---|---|
IllegalArgumentException | 引数が無効な場合 |
IllegalStateException | 内部エラーがある場合 |
ランタイム例外 | 他に特定されていないエラーがある場合 |
public static BertQuestionAnswerer createBertQuestionAnswererFromFile (Context context、 String modelPath、 String vocabPath)
Bert モデルと語彙ファイルを使用してBertQuestionAnswerer
インスタンスを作成します。
適切なモデルの 1 つは次のとおりです: https://tfhub.dev/tensorflow/lite-model/mobilebert/1/default/1
パラメーター
コンテクスト | アンドロイドコンテキスト |
---|---|
モデルパス | Bert モデルへのファイル パス。注: モデルは圧縮しないでください。 |
語彙パス | 語彙ファイルへのファイルパス。注: ファイルは圧縮しないでください。 |
戻り値
BertQuestionAnswerer
インスタンス
投げる
IO例外 | モデルファイルの読み込みに失敗した場合 |
---|---|
IllegalArgumentException | 引数が無効な場合 |
IllegalStateException | 内部エラーがある場合 |
ランタイム例外 | 他に特定されていないエラーがある場合 |
public static BertQuestionAnswerer createFromFile (Context context, String modelPath)
デフォルトのBertQuestionAnswerer.BertQuestionAnswererOptions
からBertQuestionAnswerer
インスタンスを作成します。
パラメーター
コンテクスト | アンドロイドコンテキスト |
---|---|
モデルパス | メタデータを含むモデルへのファイル パス。注: モデルは圧縮しないでください。 |
戻り値
BertQuestionAnswerer
インスタンス
投げる
IO例外 | モデルファイルのロードに失敗した場合 |
---|---|
IllegalArgumentException | 引数が無効な場合 |
IllegalStateException | 内部エラーがある場合 |
ランタイム例外 | 他に特定されていないエラーがある場合 |
public static BertQuestionAnswerer createFromFile (ファイルモデルファイル)
デフォルトのBertQuestionAnswerer.BertQuestionAnswererOptions
からBertQuestionAnswerer
インスタンスを作成します。
パラメーター
モデルファイル | モデルのFile オブジェクト |
---|
戻り値
BertQuestionAnswerer
インスタンス
投げる
IO例外 | モデルファイルのロードに失敗した場合 |
---|---|
IllegalArgumentException | 引数が無効な場合 |
IllegalStateException | 内部エラーがある場合 |
ランタイム例外 | 他に特定されていないエラーがある場合 |
public static BertQuestionAnswerer createFromFileAndOptions (ファイルモデルファイル、 BertQuestionAnswerer.BertQuestionAnswererOptionsオプション)
パラメーター
モデルファイル | モデルのFile オブジェクト |
---|---|
オプション |
戻り値
BertQuestionAnswerer
インスタンス
投げる
IO例外 | モデルファイルのロードに失敗した場合 |
---|---|
IllegalArgumentException | 引数が無効な場合 |
IllegalStateException | 内部エラーがある場合 |
ランタイム例外 | 他に特定されていないエラーがある場合 |
public static BertQuestionAnswerer createFromFileAndOptions (コンテキスト コンテキスト、文字列モデルパス、 BertQuestionAnswerer.BertQuestionAnswererOptionsオプション)
パラメーター
コンテクスト | アンドロイドコンテキスト |
---|---|
モデルパス | メタデータを含むモデルへのファイル パス。注: モデルは圧縮しないでください。 |
オプション |
戻り値
BertQuestionAnswerer
インスタンス
投げる
IO例外 | モデルファイルのロードに失敗した場合 |
---|---|
IllegalArgumentException | 引数が無効な場合 |
IllegalStateException | 内部エラーがある場合 |
ランタイム例外 | 他に特定されていないエラーがある場合 |