Skip to content

Commit

Permalink
feat: Add hybrid query example to vector search sample.
Browse files Browse the repository at this point in the history
FUTURE_COPYBARA_INTEGRATE_REVIEW=#3932 from googleapis:release-please--branches--main 346f4c0
PiperOrigin-RevId: 642658354
  • Loading branch information
lingyinw authored and copybara-github committed Jun 12, 2024
1 parent 374340a commit 04f2cd2
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,33 @@ def vector_search_find_neighbors(
)
print(resp)

# Query hybrid datapoints, sparse-only datapoints, and dense-only datapoints.
hybrid_queries = [
aiplatform.matching_engine.matching_engine_index_endpoint.HybridQuery(
dense_embedding=[1, 2, 3],
sparse_embedding_dimensions=[10, 20, 30],
sparse_embedding_values=[1.0, 1.0, 1.0],
rrf_ranking_alpha=0.5,
),
aiplatform.matching_engine.matching_engine_index_endpoint.HybridQuery(
dense_embedding=[1, 2, 3],
sparse_embedding_dimensions=[10, 20, 30],
sparse_embedding_values=[0.1, 0.2, 0.3],
),
aiplatform.matching_engine.matching_engine_index_endpoint.HybridQuery(
sparse_embedding_dimensions=[10, 20, 30],
sparse_embedding_values=[0.1, 0.2, 0.3],
),
aiplatform.matching_engine.matching_engine_index_endpoint.HybridQuery(
dense_embedding=[1, 2, 3]
),
]

hybrid_resp = my_index_endpoint.find_neighbors(
deployed_index_id=deployed_index_id,
num_neighbors=2,
return_full_datapoint=True,
queries=hybrid_queries)
print(hybrid_resp)

# [END aiplatform_sdk_vector_search_find_neighbors_sample]

0 comments on commit 04f2cd2

Please sign in to comment.