Google I/O is a wrap! Catch up on TensorFlow sessions View sessions

tflite_model_maker.searcher.Searcher

Creates the similarity search model with ScaNN.

Used in the notebooks

Used in the tutorials

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

"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

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 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.