无法下载 Spark-NLP 库提供的管道



我无法使用 Spark-NLP 库提供的预定义管道"recognize_entities_dl"

我尝试安装不同版本的 PySpark 和 Spark-NLP 库

import sparknlp
from sparknlp.pretrained import PretrainedPipeline
#create or get Spark Session
spark = sparknlp.start()
sparknlp.version()
spark.version
#download, load, and annotate a text by pre-trained pipeline
pipeline = PretrainedPipeline('recognize_entities_dl', lang='en')
result = pipeline.annotate('Harry Potter is a great movie')
2.1.0
recognize_entities_dl download started this may take some time.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-13-b71a0f77e93a> in <module>
11 #download, load, and annotate a text by pre-trained pipeline
12 
---> 13 pipeline = PretrainedPipeline('recognize_entities_dl', 'en')
14 result = pipeline.annotate('Harry Potter is a great movie')
d:python36libsite-packagessparknlppretrained.py in __init__(self, name, lang, remote_loc)
89 
90     def __init__(self, name, lang='en', remote_loc=None):
---> 91         self.model = ResourceDownloader().downloadPipeline(name, lang, remote_loc)
92         self.light_model = LightPipeline(self.model)
93 
d:python36libsite-packagessparknlppretrained.py in downloadPipeline(name, language, remote_loc)
50     def downloadPipeline(name, language, remote_loc=None):
51         print(name + " download started this may take some time.")
---> 52         file_size = _internal._GetResourceSize(name, language, remote_loc).apply()
53         if file_size == "-1":
54             print("Can not find the model to download please check the name!")
AttributeError: module 'sparknlp.internal' has no attribute '_GetResourceSize'

感谢您确认您的 Apache Spark 版本。预训练的管道和模型基于 Apache Spark 和 Spark NLP 版本。必须2.4.x最低的 Apache Spark 版本才能下载预先训练的模型/管道。否则,需要之前为任何版本训练自己的模型/管道。

这是所有管道的列表,它们都适用于Apache Spark 2.4.x: https://nlp.johnsnowlabs.com/docs/en/pipelines

如果查看任何模型或管道的 URL,则可以看到以下信息:

recognize_entities_dl_en_2.1.0_2.4_1562946909722.zip

  • 姓名recognize_entities_dl
  • en
  • Spark NLP:必须等于2.1.0或更大
  • Apache Spark:等于2.4.x或更大

注意:Spark NLP库正在针对Apache Spark2.4.x构建和编译。这就是为什么模型和管道仅适用于2.4.x版本的原因。

注2:由于您使用的是Windows,因此需要使用与Windows兼容的_noncontrib模型和管道:Spark-NLP预训练管道仅适用于Linux系统吗?

我希望这个答案有助于并解决您的问题。

2020 年 4 月更新:显然,在 Apache Spark 2.4.x 上训练和上传的模型和管道也与 Apache Spark 2.3.x 兼容。因此,如果您使用的是Apache Spark 2.3.x,即使无法使用pretrained()进行自动下载,也可以手动下载并改用.load()

所有模型和管道的完整列表以及下载链接:https://github.com/JohnSnowLabs/spark-nlp-models

更新:2.4.0 发布后,所有模型和管道都是跨平台的,无需为任何特定操作系统选择不同的模型/管道: https://github.com/JohnSnowLabs/spark-nlp/releases/tag/2.4.0

对于较新版本:https://github.com/JohnSnowLabs/spark-nlp/releases

如果您想下载可下载的模型以供离线使用或在气隙环境中下载,现在可以在新站点上访问它们:https://nlp.johnsnowlabs.com/models

最新更新