首页 > 解决方案 > 为什么 spacy 管道不使用多个线程或进程?

问题描述

import spacy

nlp = spacy.blank("en")
nlp.add_pipe(nlp.create_pipe("sentencizer"))
s = [u"This is a sentence. This is another sentence."*500] * 10000
from time import monotonic as m


start = m()
for x in nlp.pipe(s, n_threads=-1):
  c = [c for c in x]


print(m()-start)

为什么在这个代码示例中,spacy 没有使用多线程或处理?

标签: python-3.xspacy

解决方案


推荐阅读