【问题标题】:Kernel Died when running Neuralcoref运行 Neuralcoref 时内核死亡
【发布时间】:2021-07-09 00:48:42
【问题描述】:

我正在尝试安装神经核并按照here 给出的说明进行操作。

我创建了一个 jupyter notebook 并尝试运行以下代码。

# Load your usual SpaCy model (one of SpaCy English models)
import spacy
nlp = spacy.load('en')

# Add neural coref to SpaCy's pipe
import neuralcoref
neuralcoref.add_to_pipe(nlp)

# You're done. You can now use NeuralCoref as you usually manipulate a SpaCy 
document annotations.
doc = nlp(u'My sister has a dog. She loves him.')

doc._.has_coref
doc._.coref_clusters

我从 jupyter 收到一条错误消息,内核死了。即使我尝试在 python 文件中运行,但仍然无法正常工作。

操作系统 - Windows 10 内存:16GB

注意:我确实尝试过更新 numpy,但仍然没有成功。

谁能帮我解决这个问题。珍惜你的时间。 谢谢

【问题讨论】:

    标签: jupyter-notebook spacy


    【解决方案1】:

    在这里:https://github.com/huggingface/neuralcoref/issues/189

    如果你将 Spacy 降级到 2.1.0,你可以让它正常工作。

    pip uninstall spacy 
    pip uninstall neuralcoref
    pip install spacy==2.1.0 
    pip install neuralcoref --no-binary neuralcoref
    

    曾为他人工作,包括我自己。笔记本现在运行良好。

    【讨论】:

      【解决方案2】:

      根本不需要降级spacy。从源代码构建,因为与 pip 一起安装的 neuralcoref 是针对 spacy==2.1.0 构建的。

      证明:

      构建:

      git clone https://github.com/huggingface/neuralcoref.git
      cd neuralcoref
      pip install -r requirements.txt # correct for the desired versions of Cython and SpaCy
      python setup.py install
      

      测试:

      import spacy
      import neuralcoref
      nlp = spacy.load('en_core_web_md')
      neuralcoref.add_to_pipe(nlp)
      print(spacy.__version__)
      doc = nlp(u'My sister has a dog. She loves him.')
      print(doc._.has_coref)
      print(doc._.coref_clusters)
      2.3.2
      True
      [My sister: [My sister, She], a dog: [a dog, him]]
      

      【讨论】:

      • 是的。不幸的是, --no-binary 神经核似乎不起作用。幸运的是,从源代码构建!