Curstom Recommender Issue

13 views
Skip to first unread message

Richard Noriega

unread,
Oct 11, 2021, 4:05:45 PM10/11/21
to inception-users
Hello,

I'm using my own UIMA NLP tool to take text documents and pre-annotate them with certain keywords. I want to implement this into Inception, within a custom recommender's predict() function. However, because my tool creates its own CAS object, I am not sure how to implement this. I would appreciate any guidance.

Thank you,
-Richard

Richard Eckart de Castilho

unread,
Oct 11, 2021, 6:29:32 PM10/11/21
to incepti...@googlegroups.com
Hi,

> On 11. Oct 2021, at 22:05, Richard Noriega <noriegar...@gmail.com> wrote:
>
> I'm using my own UIMA NLP tool to take text documents and pre-annotate them with certain keywords. I want to implement this into Inception, within a custom recommender's predict() function. However, because my tool creates its own CAS object, I am not sure how to implement this. I would appreciate any guidance.

Ok, this is far from being the optimal solution - but this is a potential approach:

* implement a custom recommender (cf. [1])
* let getTrainingCapability() return TRAINING_NOT_SUPPORTED
* in the predict method, extract the text from the given CAS and pass it to your tool
* take the CAS that your tool creates back and then copy all the stuff that you want have displayed as recommendations from your CAS and into the CAS that was passed to the predict method - make sure you only fill in the types/features for the specific recommender configuration (again cf. [1]):

// Add predictions to the CAS
Type predictedType = getPredictedType(aCas);
Feature scoreFeature = getScoreFeature(aCas);
Feature scoreExplanationFeature = getScoreExplanationFeature(aCas);
Feature predictedFeature = getPredictedFeature(aCas);
Feature isPredictionFeature = getIsPredictionFeature(aCas);

That should work then.

A better approach would of course be to modify your existing UIMA NLP tool code and let it fill in the types/features mentioned above directly into the CAS that is given to predict instead of letting the tool create its own CAS.

Cheers,

-- Richard

[1] https://github.com/inception-project/inception/tree/main/inception/inception-example-imls-data-majority

Richard Noriega

unread,
Nov 4, 2021, 11:49:57 AM11/4/21
to inception-users
Hi Richard,

Thank you for the advice, I believe I've managed to follow it. I've recently upgraded the code to the latest version of Inception, and I have another question. In Dynamic Assignment Workload, I want to trigger Training and Predicting only on the next document to be loaded, and only once the annotator presses the 'Finish Button'. The training may take a couple of seconds (which is based on my external tool that I described earlier), so I'm hoping to find a way so that the suggestions appear once the next document is loaded. Is there some way to accomplish this with the tools already present?

Thank you,
-Richard

Richard Eckart de Castilho

unread,
Nov 4, 2021, 11:54:07 AM11/4/21
to inception-users
Hi,

> On 4. Nov 2021, at 16:49, Richard Noriega <noriegar...@gmail.com> wrote:
>
> Thank you for the advice, I believe I've managed to follow it. I've recently upgraded the code to the latest version of Inception, and I have another question. In Dynamic Assignment Workload, I want to trigger Training and Predicting only on the next document to be loaded, and only once the annotator presses the 'Finish Button'. The training may take a couple of seconds (which is based on my external tool that I described earlier), so I'm hoping to find a way so that the suggestions appear once the next document is loaded. Is there some way to accomplish this with the tools already present?

I guess it is possible but not via the external recommender API alone.

INCEpTION has a webhook concept where you can configure webhooks to be notified e.g. when a document is finished. If you build your external recommender such that it can react to such a webhook and use it for training, then I guess it would work.

https://inception-project.github.io/releases/21.1/docs/admin-guide.html#sect_remote_api_webhooks

Cheers,

-- Richard
Reply all
Reply to author
Forward
0 new messages