Thank you! Your solution of appending the score in parenthesis is very good.
Now I have got another issue actually: I tried to adapt the make_tasks function with the logic in this post (Accessing probabilities in NER) to calculate the scores.
Here is the code:
def make_tasks(nlp, stream):
"""Add a 'spans' key to each example, with predicted entities."""
texts = ((eg["text"], eg) for eg in stream)
for doc, eg in nlp.pipe(texts, as_tuples=True):
task = copy.deepcopy(eg)
spans = []
(beams, _) = nlp.entity.beam_parse([doc], beam_width=16, beam_density=0.0001)
for score, ents in nlp.entity.moves.get_beam_parses(beams[0]):
for ent in doc.ents:
if labels and ent.label_ not in labels:
continue
spans.append(
{
"token_start": ent.start,
"token_end": ent.end - 1,
"start": ent.start_char,
"end": ent.end_char,
"text": ent.text,
"label": "{} ({})".format(ent.label_, score),
"source": spacy_model,
"input_hash": eg[INPUT_HASH_ATTR],
}
)
task["spans"] = spans
task = set_hashes(task)
yield task
However, I notice that the model returns always score = 1.0 for all the entities.
I tried some of the models trained by me, plus I tried to run the recipe with the standard “en_core_web_lg-2.0.0” and “en_core_web_sm” models on an english text. Result is always score=1.0.
Am i doing anything wrong in calculating the scores? Or is this expected?
If it is wrong, what can i do to get the model score of each entity prediction?
Thanks
Kasra