Skip to content

Commit 53d31b5

Browse files
lingyinwcopybara-github
authored andcommitted
feat: add support for per_crowding_attribute_num_neighbors approx_num_neighborsto MatchingEngineIndexEndpoint match()
PiperOrigin-RevId: 578927417
1 parent 54f90a5 commit 53d31b5

File tree

2 files changed

+0
-19
lines changed

2 files changed

+0
-19
lines changed

google/cloud/aiplatform/matching_engine/matching_engine_index_endpoint.py

-13
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,6 @@ def match(
10711071
self,
10721072
deployed_index_id: str,
10731073
queries: List[List[float]],
1074-
per_crowding_attribute_num_neighbors: int,
1075-
approx_num_neighbors: int,
10761074
num_neighbors: int = 1,
10771075
filter: Optional[List[Namespace]] = [],
10781076
) -> List[List[MatchNeighbor]]:
@@ -1083,15 +1081,6 @@ def match(
10831081
Required. The ID of the DeployedIndex to match the queries against.
10841082
queries (List[List[float]]):
10851083
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.
10951084
num_neighbors (int):
10961085
Required. The number of nearest neighbors to be retrieved from database for
10971086
each query.
@@ -1134,8 +1123,6 @@ def match(
11341123
num_neighbors=num_neighbors,
11351124
deployed_index_id=deployed_index_id,
11361125
float_val=query,
1137-
per_crowding_attribute_num_neighbors=per_crowding_attribute_num_neighbors,
1138-
approx_num_neighbors=approx_num_neighbors,
11391126
)
11401127
for namespace in filter:
11411128
restrict = match_service_pb2.Namespace()

tests/unit/aiplatform/test_matching_engine_index_endpoint.py

-6
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@
232232
Namespace(name="class", allow_tokens=["token_1"], deny_tokens=["token_2"])
233233
]
234234
_TEST_IDS = ["123", "456", "789"]
235-
_TEST_PER_CROWDING_ATTRIBUTE_NUM_NEIGHBOURS = 3
236-
_TEST_APPROX_NUM_NEIGHBORS = 2
237235

238236

239237
def uuid_mock():
@@ -868,8 +866,6 @@ def test_index_endpoint_match_queries(self, index_endpoint_match_queries_mock):
868866
queries=_TEST_QUERIES,
869867
num_neighbors=_TEST_NUM_NEIGHBOURS,
870868
filter=_TEST_FILTER,
871-
per_crowding_attribute_num_neighbors=_TEST_PER_CROWDING_ATTRIBUTE_NUM_NEIGHBOURS,
872-
approx_num_neighbors=_TEST_APPROX_NUM_NEIGHBORS,
873869
)
874870

875871
batch_request = match_service_pb2.BatchMatchRequest(
@@ -888,8 +884,6 @@ def test_index_endpoint_match_queries(self, index_endpoint_match_queries_mock):
888884
deny_tokens=["token_2"],
889885
)
890886
],
891-
per_crowding_attribute_num_neighbors=_TEST_PER_CROWDING_ATTRIBUTE_NUM_NEIGHBOURS,
892-
approx_num_neighbors=_TEST_APPROX_NUM_NEIGHBORS,
893887
)
894888
],
895889
)

0 commit comments

Comments
 (0)