I am using ner-model-2020.02.10.tar.gz model and i would like to predict.
but when i use the allen nlp object in loop then its behaviour is changing. below is the sample code
import re
from allennlp.predictors.predictor import Predictor
ner_var = Predictor.from_path("/home/dheeraj/Desktop/allenNlp/ner-model-2020.02.10.tar.gz")
org_obj = ner_var
text = [' Client: TechMahindra/UPC, India ',
' Client: TechMahindra/UPC, India ']
for i in text:
org = org_obj.predict(i)
print(org['tags'])
print(org['words'])
`
Output:-
['O', 'O', 'U-LOC', 'O', 'O', 'O', 'U-LOC']
['Client', ':', 'TechMahindra', '/', 'UPC', ',', 'India']
['O', 'O', 'O', 'O', 'O', 'O', 'U-LOC']
['Client', ':', 'TechMahindra', '/', 'UPC', ',', 'India']
above you can see , for same input , for first line(TechMahindra) tagged as U-LOC but in second line (same line) you can see different output.
So why the behaviour is not consistent. as the output should be same.
please help on this.
This model uses ELMO, which is non-deterministic across runs.
@epwalsh do we have any alternative solution for same , as we need to use the predictor object multiple times in loop and we need consistent prediction.
Then I would recommend either using a different model or using a cache on top of this model.