inception-project / inception

INCEpTION provides a semantic annotation platform offering intelligent annotation assistance and knowledge management.
https://inception-project.github.io
Apache License 2.0
593 stars 151 forks source link

An external recommender cannot set a confidence score for NER prediction #1004

Closed Apollo-XI closed 3 years ago

Apollo-XI commented 5 years ago

An external recommender cannot set a confidence score. So, active learning is useless when external recommenders are used.

The method getScoreFeature in the class ExternalRecommender returns a Optional.empty(). (line 303 in ExternalRecommeder class). I think that it if a "score" feature is present should return it as OpenNLP NER Recommender does (line 115 of OpenNlpNerRecommender).

Update: External recommender can now specify their confidence by using a feature called ${feature}_score, e.g. for named entities value_score. The documentation needs to be adjusted to reflect that.

reckart commented 5 years ago

For the internal recommenders, we use the PredictedSpan type. For external recommenders, we use the target layer type.

I guess we have kind of two options now:

@jcklie @Apollo-XI any opinions?

Apollo-XI commented 5 years ago

First of all, I don't know much about INCEpTION code.

If PredictedSpan is something internal of INCEpTION, I wouldn't use it. However, if UIMA CAS defines a PredictedSpan type and it is easier to implement by external recommenders, I think it's a the best option. INCEpTION wouldn't treat differently an external or internal recommender. In case that using PredictedSpan makes harder to integrate an external recommender, I would avoid it.

The score feature seems fine to me if I can be set separately to each feature in the layer. Some layers could have more than one feature and the external recommender could assign different confidence scores to each one.

jcklie commented 5 years ago

@Apollo-XI PredictedSpan is INCEpTION internal, but I think that exposing it or using another custom Annotation just for external recommender would be the simplest solution. We consider to add a score feature to DKPro types in the future, but that is far away.

reckart commented 5 years ago

@jcklie I guess this can be addressed now that #1206 has been merged?

jcklie commented 5 years ago

Yes, we will work on that now.

jcklie commented 5 years ago

External recommender can now specify their confidence by using a feature called ${feature}_score, e.g. for named entities value_score.

reckart commented 5 years ago

@jcklie so should we mark this issue as resolved now? Does the documentation for the external recommender already reflect what you described in your comment above?

jcklie commented 5 years ago

The documentation does not yet reflect it, so I would leave it open.

reckart commented 5 years ago

Should we push it to 0.11.0 or could you update the documentation and resolve it?

jcklie commented 5 years ago

We right now do not have any real documentation on how to add a external recommender, only how the API looks, so I would push it.

reckart commented 3 years ago

We have the functionality and the documentation these days - so closing this one.

goodcheer commented 2 years ago

@reckart from which document can i find how to add score to external recommender? I'm now looking at implementing external recommender using python (spacy) and could'nt find one.

reckart commented 2 years ago

I think this should work

for cas_token, spacy_token in zip(cas.select(TOKEN_TYPE), doc):
            prediction = create_prediction(cas, layer, feature, cas_token.begin, cas_token.end, spacy_token.tag_)
            prediction.set(f"{feature}_score", YOUR_SCORE_VALUE)
            prediction.set(f"{feature}_score_explanation", SOME_STRING_WITH_ADDITIONAL_INFORMATION_OPTIONAL)
            cas.add_annotation(prediction)