@@ -1071,6 +1071,8 @@ def match(
1071
1071
self ,
1072
1072
deployed_index_id : str ,
1073
1073
queries : List [List [float ]],
1074
+ per_crowding_attribute_num_neighbors : int ,
1075
+ approx_num_neighbors : int ,
1074
1076
num_neighbors : int = 1 ,
1075
1077
filter : Optional [List [Namespace ]] = [],
1076
1078
) -> List [List [MatchNeighbor ]]:
@@ -1081,6 +1083,15 @@ def match(
1081
1083
Required. The ID of the DeployedIndex to match the queries against.
1082
1084
queries (List[List[float]]):
1083
1085
Required. A list of queries. Each query is a list of floats, representing a single embedding.
1086
+ per_crowding_attribute_num_neighbors (int):
1087
+ Optional. Crowding is a constraint on a neighbor list produced by nearest neighbor
1088
+ search requiring that no more than some value k' of the k neighbors
1089
+ returned have the same value of crowding_attribute.
1090
+ It's used for improving result diversity.
1091
+ This field is the maximum number of matches with the same crowding tag.
1092
+ approx_num_neighbors (int):
1093
+ The number of neighbors to find via approximate search before exact reordering is performed.
1094
+ If not set, the default value from scam config is used; if set, this value must be > 0.
1084
1095
num_neighbors (int):
1085
1096
Required. The number of nearest neighbors to be retrieved from database for
1086
1097
each query.
@@ -1123,6 +1134,8 @@ def match(
1123
1134
num_neighbors = num_neighbors ,
1124
1135
deployed_index_id = deployed_index_id ,
1125
1136
float_val = query ,
1137
+ per_crowding_attribute_num_neighbors = per_crowding_attribute_num_neighbors ,
1138
+ approx_num_neighbors = approx_num_neighbors ,
1126
1139
)
1127
1140
for namespace in filter :
1128
1141
restrict = match_service_pb2 .Namespace ()
0 commit comments