Spark NLP是建立在Apache Spark頂部的最先進的自然語言處理庫。它為機器學習管道提供了簡單,性能和準確的NLP註釋,可在分佈式環境中輕鬆擴展。
Spark NLP配備了超過200多種語言的83000多個預算管道和型號。 It also offers tasks such as Tokenization , Word Segmentation , Part-of-Speech Tagging , Word and Sentence Embeddings , Named Entity Recognition , Dependency Parsing , Spell Checking , Text Classification , Sentiment Analysis , Token Classification , Machine Translation (+180 languages), Summarization , Question Answering , Table Question Answering , Text Generation , Image Classification , Image to Text (captioning) , Automatic Speech Recognition , Zero-Shot Learning , and many more NLP任務。
Spark NLP is the only open-source NLP library in production that offers state-of-the-art transformers such as BERT , CamemBERT , ALBERT , ELECTRA , XLNet , DistilBERT , RoBERTa , DeBERTa , XLM-RoBERTa , Longformer , ELMO , Universal Sentence Encoder , Llama-2 , M2M100 , BART , Instructor , E5 , Google T5 , MarianMT , OpenAI GPT2 , Vision Transformers ( VIT) , Openai Whisper , Llama , Mistral , Phi , Qwen2等,不僅對Python和R ,而且還可以通過自然擴展Apache來擴展Apache 。
Spark NLP為從各種流行框架中導入模型提供了簡單的支持:
這種廣泛的支持使您可以將不同源的模型無縫整合到Spark NLP工作流程中,從而增強了與現有機器學習生態系統的靈活性和兼容性。
查看我們的官方Spark NLP頁面:https://sparknlp.org/獲取用戶文檔和示例
這是如何在Python和Pyspark中使用Spark NLP預訓練的管道的快速示例:
$ java -version
# should be Java 8 or 11 (Oracle or OpenJDK)
$ conda create -n sparknlp python=3.7 -y
$ conda activate sparknlp
# spark-nlp by default is based on pyspark 3.x
$ pip install spark-nlp==5.5.2 pyspark==3.3.1在Python控制台或Jupyter Python3內核中:
# Import Spark NLP
from sparknlp . base import *
from sparknlp . annotator import *
from sparknlp . pretrained import PretrainedPipeline
import sparknlp
# Start SparkSession with Spark NLP
# start() functions has 3 parameters: gpu, apple_silicon, and memory
# sparknlp.start(gpu=True) will start the session with GPU support
# sparknlp.start(apple_silicon=True) will start the session with macOS M1 & M2 support
# sparknlp.start(memory="16G") to change the default driver memory in SparkSession
spark = sparknlp . start ()
# Download a pre-trained pipeline
pipeline = PretrainedPipeline ( 'explain_document_dl' , lang = 'en' )
# Your testing dataset
text = """
The Mona Lisa is a 16th century oil painting created by Leonardo.
It's held at the Louvre in Paris.
"""
# Annotate your testing dataset
result = pipeline . annotate ( text )
# What's in the pipeline
list ( result . keys ())
Output : [ 'entities' , 'stem' , 'checked' , 'lemma' , 'document' ,
'pos' , 'token' , 'ner' , 'embeddings' , 'sentence' ]
# Check the results
result [ 'entities' ]
Output : [ 'Mona Lisa' , 'Leonardo' , 'Louvre' , 'Paris' ]有關更多示例,您可以訪問我們的專用示例以展示所有Spark NLP用例!
這是一個備忘單,用於相應的Spark NLP Maven軟件包,apache spark / pyspark專業版本:
| Apache Spark | 在CPU上激發NLP | 在GPU上激發NLP | 在Aarch64(Linux)上激發NLP | 蘋果矽上的火花NLP |
|---|---|---|---|---|
| 3.0/3.1/3.2/3.3/3.4/3.5 | spark-nlp | spark-nlp-gpu | spark-nlp-aarch64 | spark-nlp-silicon |
| 啟動功能 | sparknlp.start() | sparknlp.start(gpu=True) | sparknlp.start(aarch64=True) | sparknlp.start(apple_silicon=True) |
注意: M1/M2和AArch64在experimental支持下。對這些體系結構的訪問和支持受社區的限制,我們必須自己建立大多數依賴項,以使它們兼容。我們支持這兩個架構,但是它們可能在某些環境中無法使用。
有關使用管道和模型的快速示例,請查看我們的官方文檔
Spark NLP 5.5.2已建立在Apache Spark 3.4的頂部,而完全支持Apache Spark 3.0.x,3.1.x,3.2.x,3.3.3.3.x,3.4.4.x和3.5.5.x
| 火花NLP | Apache Spark 3.5.x | Apache Spark 3.4.x | Apache Spark 3.3.x | Apache Spark 3.2.x | Apache Spark 3.1.x | Apache Spark 3.0.x | Apache Spark 2.4.x | Apache Spark 2.3.x |
|---|---|---|---|---|---|---|---|---|
| 5.5.x | 是的 | 是的 | 是的 | 是的 | 是的 | 是的 | 不 | 不 |
| 5.4.x | 是的 | 是的 | 是的 | 是的 | 是的 | 是的 | 不 | 不 |
| 5.3.x | 是的 | 是的 | 是的 | 是的 | 是的 | 是的 | 不 | 不 |
| 5.2.x | 是的 | 是的 | 是的 | 是的 | 是的 | 是的 | 不 | 不 |
| 5.1.x | 部分 | 是的 | 是的 | 是的 | 是的 | 是的 | 不 | 不 |
| 5.0.x | 是的 | 是的 | 是的 | 是的 | 是的 | 是的 | 不 | 不 |
從我們的發行說明中了解有關Spark NLP版本的更多信息。
| 火花NLP | Python 3.6 | Python 3.7 | Python 3.8 | Python 3.9 | Python 3.10 | Scala 2.11 | Scala 2.12 |
|---|---|---|---|---|---|---|---|
| 5.5.x | 不 | 是的 | 是的 | 是的 | 是的 | 不 | 是的 |
| 5.4.x | 不 | 是的 | 是的 | 是的 | 是的 | 不 | 是的 |
| 5.3.x | 不 | 是的 | 是的 | 是的 | 是的 | 不 | 是的 |
| 5.2.x | 不 | 是的 | 是的 | 是的 | 是的 | 不 | 是的 |
| 5.1.x | 不 | 是的 | 是的 | 是的 | 是的 | 不 | 是的 |
| 5.0.x | 不 | 是的 | 是的 | 是的 | 是的 | 不 | 是的 |
在我們的官方文檔中找到有關4.x SparkNLP版本的更多信息
Spark NLP 5.5.2已進行了測試,並且與以下運行時間兼容:
| 中央處理器 | GPU |
|---|---|
| 14.1 / 14.1毫升 | 14.1 ML和GPU |
| 14.2 / 14.2毫升 | 14.2 ML和GPU |
| 14.3 / 14.3毫升 | 14.3 ML和GPU |
| 15.0 / 15.0毫升 | 15.0 ML和GPU |
| 15.1 / 15.0毫升 | 15.1 ML和GPU |
| 15.2 / 15.0毫升 | 15.2 ML和GPU |
| 15.3 / 15.0毫升 | 15.3 ML和GPU |
| 15.4 / 15.0毫升 | 15.4 ML和GPU |
我們與較舊的運行時間兼容。有關完整列表,請在我們的官方文檔中查看數據支持
Spark NLP 5.5.2已進行了測試,並且與以下EMR版本兼容:
| EMR釋放 |
|---|
| EMR-6.13.0 |
| EMR-6.14.0 |
| EMR-6.15.0 |
| EMR-7.0.0 |
| EMR-7.1.0 |
| EMR-7.2.0 |
我們與較舊的EMR版本兼容。有關完整列表,請在我們的官方文檔中查看EMR支持
Amazon EMR 6.x版本的完整列表,Amazon EMR 7.x版本的完整列表
注意:不支持EMR 6.1.0和6.1.1。
通過命令行安裝SPARK-NLP軟件包,請遵循我們的官方文檔中的這些說明
Spark NLP支持Scala 2.12.15如果您使用的是Apache Spark 3.0.x,3.1.x,3.2.x,3.3.3.x和3.4.x版本。我們的軟件包被部署到Maven Central。要在您的應用程序中添加我們的任何軟件包作為依賴性,您可以按照我們的官方文檔中的這些說明進行操作。
如果您有興趣,Spark NLP有一個簡單的SBT項目,可以指導您如何在項目中使用它Spark NLP NLP S5.5.5.2R
Spark NLP根據您的主要Pyspark版本支持Python 3.7.x及以上。在我們的官方文檔中檢查所有可用安裝的python
從源頭編譯罐子遵循我們的正式文檔中的這些說明
有關如何在受支持平台上使用Spark NLP的詳細說明,請參閱我們的官方文檔:
| 平台 | 支持的語言 |
|---|---|
| Apache Zeppelin | Scala,Python |
| Jupyter筆記本 | Python |
| Google Colab筆記本 | Python |
| Kaggle內核 | Python |
| Databricks群集 | Scala,Python |
| EMR群集 | Scala,Python |
| GCP DataProc群集 | Scala,Python |
Spark NLP庫和所有預訓練的模型/管道都可以完全離線使用,而無需訪問Internet。請從我們的官方文檔中檢查這些說明,以使用Spark NLP離線。
您可以通過Spark Properties配置更改Spark NLP配置。請從我們的官方文檔中檢查這些說明。
在Spark NLP中,我們可以將S3位置定義為:
NerDLApproach中使用的TensorFlow圖請從我們的官方文檔中檢查這些說明。
需要更多例子嗎?查看我們專用的Spark NLP示例存儲庫,以展示所有Spark NLP用例!
另外,不要忘記檢查由簡化構建的動作中的Spark NLP。
在此處查看我們的文章和視頻頁面
我們發表了一篇論文,您可以為Spark NLP庫引用:
@article { KOCAMAN2021100058 ,
title = { Spark NLP: Natural language understanding at scale } ,
journal = { Software Impacts } ,
pages = { 100058 } ,
year = { 2021 } ,
issn = { 2665-9638 } ,
doi = { https://doi.org/10.1016/j.simpa.2021.100058 } ,
url = { https://www.sciencedirect.com/science/article/pii/S2665963.2.300063 } ,
author = { Veysel Kocaman and David Talby } ,
keywords = { Spark, Natural language processing, Deep learning, Tensorflow, Cluster } ,
abstract = { Spark NLP is a Natural Language Processing (NLP) library built on top of Apache Spark ML. It provides simple, performant & accurate NLP annotations for machine learning pipelines that can scale easily in a distributed environment. Spark NLP comes with 1100+ pretrained pipelines and models in more than 192+ languages. It supports nearly all the NLP tasks and modules that can be used seamlessly in a cluster. Downloaded more than 2.7 million times and experiencing 9x growth since January 2020, Spark NLP is used by 54% of healthcare organizations as the world’s most widely used NLP library in the enterprise. }
}
}5.5.2 我們感謝任何貢獻:
克隆倉庫,提交您的套客!或直接在此存儲庫中創建問題。
http://johnsnowlabs.com