Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
899 views
in Technique[技术] by (71.8m points)

merge - Merging spans is very slow when using the model "en_core_web_md" of Spacy

Thank spacy for providing the very nice library. I found a question: merging span very slow(about 200ms) when using the model "en_core_web_md". The code is as follows:

 import spacy
 import time

 nlp = spacy.load("en_core_web_md")
 doc = nlp("I need to speak with one of your technicians")

 st = time.time()
 with doc.retokenize() as retokenizer:
     retokenizer.merge(doc[0:4])

 print(time.time() - st)
 print([w.text for w in doc]) 
    

This is fast(about 12ms) while using the model:"en_core_web_sm" or "en_core_web_lg".
The environment:

      spacy                    2.3.2
      en-core-web-md           2.3.1
      Python                   3.8.6 
      Ubuntu                   16.04.7 LTS

I tried to add:

   doc.tensor = None

before retokenize according to here, but it did not work. Anyone can help me. Thanks in advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...