search_with_threshold
Function
Retrieves vectors similar to the passed vector in a database and filters them based on the threshold.
Prototype
def search_with_threshold(embeddings, k, threshold, filter_dict)
Parameters
Parameter |
Data Type |
Required/Optional |
Description |
|---|---|---|---|
embeddings |
Union[ndarray, List[Dict[int, float]]] |
Required |
Dense or sparse vector. For a dense vector, the data type is ndarray; for a sparse vector, the data type is List[Dict[int, float]]. |
k |
Integer |
Optional |
Number of returned similar vectors. The default value is 3. The value range is (0, 10000]. |
threshold |
Float |
Optional |
Score threshold. The default value is 0.1. The value range is [0.0, 1.0]. |
filter_dict |
Dict |
Optional |
Dictionary consisting of retrieval criteria. Currently, only document IDs can be filtered. The filtered document IDs are passed in a list. The length of the ID list cannot exceed 1000 × 1000. For example, if you need to filter the documents whose IDs are 1, 2, and 4, the input dictionary is {"document_id": [1, 2, 4]}. |
Return Value
Data Type |
Description |
|---|---|
List[List[float]], List[List[int]] |
Scores and IDs of the most similar k vectors. |