tensorflow/lite/g3doc/api_docs/java/org/tensorflow/lite/task/text/searcher/TextSearcher.html
public final class TextSearcher
Performs similarity search on text string.
The API expects a TFLite model with optional, but strongly recommended, TFLite Model Metadata..
The API expects a TFLite model with metadata populated. The metadata should contain the following information:
For Bert based TFLite model:
For Regex based TFLite model:
1 input tensor.
input_process_units for RegexTokenizer Tokenizer
exactly one output tensor of type kTfLiteFloat32
For Universal Sentence Encoder based TFLite model:
3 input tensors with names "inp_text", "res_context" and "res_text"
2 output tensors with names "query_encoding" and "response_encoding" of type kTfLiteFloat32
TODO(b/180502532): add pointer to example model.
TODO(b/222671076): add factory create methods without options, such as createFromFile, once the single file format (index file packed in the model) is supported.
| class | TextSearcher.TextSearcherOptions | Options for setting up an TextSearcher. |
| static TextSearcher |
createFromBufferAndOptions(ByteBuffer modelBuffer, TextSearcher.TextSearcherOptions options)
Creates an TextSearcher instance with a model buffer and TextSearcher.TextSearcherOptions.
|
| static TextSearcher |
createFromBufferAndOptionsImpl(ByteBuffer modelBuffer, TextSearcher.TextSearcherOptions options, int indexFd)
|
| static TextSearcher |
createFromFileAndOptions(File modelFile, TextSearcher.TextSearcherOptions options)
Creates an TextSearcher instance.
|
| static TextSearcher |
createFromFileAndOptions(Context context, String modelPath, TextSearcher.TextSearcherOptions options)
Creates an TextSearcher instance from TextSearcher.TextSearcherOptions.
| | List<NearestNeighbor> | search(String text) Performs embedding extraction on the provided string input, followed by nearest-neighbor search in the index.
|
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 java.lang.AutoCloseable
| abstract void | close() |
Creates an TextSearcher instance with a model buffer and TextSearcher.TextSearcherOptions.
| modelBuffer | a direct ByteBuffer or a MappedByteBuffer of the search model |
| options | |
| IllegalArgumentException | if the model buffer is not a direct ByteBuffer or a MappedByteBuffer |
| IOException | if an I/O error occurs when loading the index file |
| IllegalStateException | if there is an internal error |
| RuntimeException | if there is an otherwise unspecified error |
| modelBuffer | | | options | | | indexFd | |
Creates an TextSearcher instance.
| modelFile | the search model File instance |
| options | |
| IOException | if an I/O error occurs when loading the tflite model or the index file | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates an TextSearcher instance from TextSearcher.TextSearcherOptions.
| context | | | modelPath | path of the search model with metadata in the assets | | options | |
| IOException | if an I/O error occurs when loading the tflite model or the index file | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Performs embedding extraction on the provided string input, followed by nearest-neighbor search in the index.
| text | input text query to the model |