[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-08 UTC."],[],[],null,["# tflite_support.task.text.TextSearcher\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/text_searcher.py#L50-L138) |\n\nClass to performs text search. \n\n tflite_support.task.text.TextSearcher(\n options: ../../../tflite_support/task/text/TextSearcherOptions,\n cpp_searcher: _CppTextSearcher\n ) -\u003e None\n\nIt works by performing embedding extraction on text, followed by\nnearest-neighbor search in an index of embeddings through ScaNN.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------|---------------|\n| `options` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `create_from_file`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/text_searcher.py#L64-L87) \n\n @classmethod\n create_from_file(\n model_file_path: str, index_file_path: Optional[str] = None\n ) -\u003e 'TextSearcher'\n\nCreates the `TextSearcher` object from a TensorFlow Lite model.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `model_file_path` | Path to the model. |\n| `index_file_path` | Path to the index. Only required if the index is not attached to the output tensor metadata as an AssociatedFile with type SCANN_INDEX_FILE. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| `TextSearcher` object that's created from `options`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------|----------------------------------------------------------------------------------------|\n| `ValueError` | If failed to create `TextSearcher` object from the provided file such as invalid file. |\n| `RuntimeError` | If other types of error occurred. |\n\n\u003cbr /\u003e\n\n### `create_from_options`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/text_searcher.py#L89-L106) \n\n @classmethod\n create_from_options(\n options: ../../../tflite_support/task/text/TextSearcherOptions\n ) -\u003e 'TextSearcher'\n\nCreates the `TextSearcher` object from text searcher options.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|-------------------------------------|\n| `options` | Options for the text searcher task. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| `TextSearcher` object that's created from `options`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------|-------------------------------------------------------------------------------------------------|\n| `ValueError` | If failed to create `TextSearcher` object from `TextSearcherOptions` such as missing the model. |\n| `RuntimeError` | If other types of error occurred. |\n\n\u003cbr /\u003e\n\n### `get_user_info`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/text_searcher.py#L127-L134) \n\n get_user_info() -\u003e str\n\nGets the user info stored in the index file.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| Opaque user info stored in the index file (if any), in raw binary form. Returns an empty string if the index doesn't contain user info. ||\n\n\u003cbr /\u003e\n\n### `search`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/text/text_searcher.py#L108-L125) \n\n search(\n text: str\n ) -\u003e ../../../tflite_support/task/processor/SearchResult\n\nSearch for text with similar semantic meaning.\n\nThis method performs actual feature extraction on the provided text input,\nfollowed by nearest-neighbor search in the index.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------------------------------------------------------|------------------------------------------------------|\n| [`text`](https://www.tensorflow.org/text/api_docs/python/text) | the input text, used to extract the feature vectors. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| search result. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------|-----------------------------------------------|\n| `ValueError` | If any of the input arguments is invalid. |\n| `RuntimeError` | If failed to perform nearest-neighbor search. |\n\n\u003cbr /\u003e"]]