Creates the similarity search model with ScaNN.
tflite_model_maker.searcher.Searcher(
serialized_scann_path: str,
metadata: List[AnyStr],
embedder_path: Optional[str] = None
) -> None
Used in the notebooks
Args |
serialized_scann_path
|
Path to the dir that contains the ScaNN's
artifacts.
|
metadata
|
The metadata for each of the embeddings in the database. Passed
in the same order as the embeddings in ScaNN.
|
embedder_path
|
Path to the TFLite Embedder model file.
|
Methods
create_from_data
View source
@classmethod
create_from_data(
data: tflite_model_maker.searcher.DataLoader
,
scann_options: tflite_model_maker.searcher.ScaNNOptions
,
cache_dir: Optional[str] = None
) -> 'Searcher'
"Creates the instance from data.
Args |
data
|
Data used to create scann.
|
scann_options
|
Options to build the ScaNN index file.
|
cache_dir
|
The cache directory to save serialized ScaNN and/or the tflite
model. When cache_dir is not set, a temporary folder will be created and
will not be removed automatically which makes it can be used later.
|
Returns |
A Searcher instance.
|
create_from_server_scann
View source
@classmethod
create_from_server_scann(
serialized_scann_path: str,
metadata: List[AnyStr],
embedder_path: Optional[str] = None
) -> 'Searcher'
Creates the instance from the serialized serving scann directory.
Args |
serialized_scann_path
|
Path to the dir that contains the ScaNN's
artifacts.
|
metadata
|
The metadata for each of the embeddings in the database. Passed
in the same order as the embeddings in ScaNN.
|
embedder_path
|
Path to the TFLite Embedder model file.
|
Returns |
A Searcher instance.
|
export
View source
export(
export_format: tflite_model_maker.searcher.ExportFormat
,
export_filename: str,
userinfo: AnyStr,
compression: bool = True
)
Export the searcher model.
Args |
export_format
|
Export format that could be tflite or on-device ScaNN index
file, must be ExportFormat.TFLITE or ExportFormat.SCANN_INDEX_FILE .
|
export_filename
|
File name to save the exported file. The exported file
can be TFLite model or on-device ScaNN index file.
|
userinfo
|
A special field in the index file that can be an arbitrary
string supplied by the user.
|
compression
|
Whether to snappy compress the index file.
|