python-crfsuite icon indicating copy to clipboard operation
python-crfsuite copied to clipboard

Can I predict with crf model using multiple processes? I tried, But I got errors -_-!

Open huwen2117 opened this issue 6 years ago • 1 comments

I tried, and I got Error: File "stringsource", line 2, in pycrfsuite._pycrfsuite.Tagger.reduce_cython TypeError: self.c_tagger cannot be converted to a Python object for pickling

my plan like this:

model_list = [model_1,model_2, ... ,model_n]

def do_tagging(args):
    model ,sent = args
    tagger = crfs.Tagger()
    tagger.open(model)
    labels = tagger.tag(sent)

with Pool(processes=num_proc) as p:
    predict_result = p.map(do_tagging, zip(model_list, repeat(sent))))

huwen2117 avatar Aug 20 '19 07:08 huwen2117

Open the model within the process rather than passing the model in.

DomHudson avatar Mar 09 '20 14:03 DomHudson