Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Vertex Matching Engine deny list tokens

How does the Vertex matching engine deny list work?

Let's say I have a class fruit which will ONLY have deny list tokens (no allow) such as "apple", "mango", etc. How do I filter out "mango" in the query (search all fruits except mango)? I have tried the following method but it does not work as expected:

json

{"id": "1", "embedding":[0.002792,0.000492], "restricts": [{"namespace": "fruit", "deny": ["mango"]}]}

query
deny_namespace = match_service_pb2.Namespace()
deny_namespace.name = "fruit"
deny_namespace.deny_tokens.append("mango")
request.restricts.append(deny_namespace)

I have coded this similar to allow list which has worked for me but with deny tokens it does not seem to skip deny tokens even after completely overwriting the index. 

1 4 708
4 REPLIES 4

Based on the documentation that you shared about the filters and the code you are sharing, it looks like there’s a formatting error on your code, based on the doc the JSON should look like the example I’m providing you below.

{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}

@Eduardo_Ortiz Thanks for looking into this!
Yes this is for allow list, but I'm specifically asking for deny list. When I changed the "deny" to "allow" it seems to work but it fails for "deny". Can you or someone from the team please help me with this?

Did you try to add deny tokens onto your case?

Hello @Eduardo_Ortiz ,

I tried what you said but it does not work anyway. For a more details, I opened an issue on github:  https://github.com/GoogleCloudPlatform/vertex-ai-samples/issues/1230