Brute force retrieval.

Inherits From: TopK

Used in the notebooks

Used in the tutorials

query_model Optional Keras model for representing queries. If provided, will be used to transform raw features into query embeddings when querying the layer. If not provided, the layer will expect to be given query embeddings as inputs.
k Default k.
name Name of the layer.



View source

Query the index.

queries Query features. If query_model was provided in the constructor, these can be raw query features that will be processed by the query model before performing retrieval. If query_model was not provided, these should be pre-computed query embeddings.
k The number of candidates to retrieve. If not supplied, defaults to the k value supplied in the constructor.

Tuple of (top candidate scores, top candidate identifiers).

ValueError if index has not been called.


View source

Builds the retrieval index.

When called multiple times the existing index will be dropped and a new one created.

candidates Matrix (or dataset) of candidate embeddings.
identifiers Optional tensor (or dataset) of candidate identifiers. If given these will be return to identify top candidates when performing searches. If not given, indices into the candidates tensor will be given instead.