Is there a way to detect entities using two trained models in AWS comprehend?

208 views Asked by At

I have two trained entity recognizer models which detect different entity types, I have created endpoints for both models but I can't seem to find a usage where I can implement both the models to detect entity's from a simple string text.

One model detects clients(like "Nike") and other metrics(like "sales") from text[Shown below].

text="find net sales of Nike"
comprehend.detect_entities(Text=text,LanguageCode="en",EndpointArn='arn:aws:comprehend:xyz-1:760825412989:entity-recognizer-endpoint/xyz-1')

Is there a way to implement both models using endpoints on a given text?

1

There are 1 answers

0
abhinavatAWS On

Comprehend supports inference against one model per request. If you have multiple models, you can chain the inference requests within a lambda and call the models sequentially.

Using your sample code above:

text="find net sales of Nike"
comprehend.detect_entities(Text=text,LanguageCode="en",EndpointArn='arn:aws:comprehend:region:760825412989:entity-recognizer-endpoint/xyz-1')
comprehend.detect_entities(Text=text,LanguageCode="en",EndpointArn='arn:aws:comprehend:region:760825412989:entity-recognizer-endpoint/xyz-2')