spark-nlp 5.5.0rc1__py2.py3-none-any.whl → 5.5.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spark-nlp might be problematic. Click here for more details.

@@ -1,1357 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: spark-nlp
3
- Version: 5.5.0rc1
4
- Summary: John Snow Labs Spark NLP is a natural language processing library built on top of Apache Spark ML. It provides simple, performant & accurate NLP annotations for machine learning pipelines, that scale easily in a distributed environment.
5
- Home-page: https://github.com/JohnSnowLabs/spark-nlp
6
- Author: John Snow Labs
7
- Keywords: NLP spark vision speech deep learning transformer tensorflow BERT GPT-2 Wav2Vec2 ViT
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Intended Audience :: Information Technology
11
- Classifier: Intended Audience :: Science/Research
12
- Classifier: License :: OSI Approved :: Apache Software License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Operating System :: POSIX :: Linux
15
- Classifier: Operating System :: MacOS :: MacOS X
16
- Classifier: Operating System :: Microsoft :: Windows
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.6
19
- Classifier: Programming Language :: Python :: 3.7
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
24
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
- Classifier: Topic :: Software Development :: Internationalization
26
- Classifier: Topic :: Software Development :: Localization
27
- Classifier: Topic :: Software Development :: Build Tools
28
- Classifier: Topic :: Text Processing :: Linguistic
29
- Classifier: Topic :: Scientific/Engineering
30
- Classifier: Typing :: Typed
31
- Description-Content-Type: text/markdown
32
-
33
- # Spark NLP: State-of-the-Art Natural Language Processing & LLMs Library
34
-
35
- <p align="center">
36
- <a href="https://github.com/JohnSnowLabs/spark-nlp/actions" alt="build">
37
- <img src="https://github.com/JohnSnowLabs/spark-nlp/workflows/build/badge.svg" /></a>
38
- <a href="https://github.com/JohnSnowLabs/spark-nlp/releases" alt="Current Release Version">
39
- <img src="https://img.shields.io/github/v/release/JohnSnowLabs/spark-nlp.svg?style=flat-square&logo=github" /></a>
40
- <a href="https://search.maven.org/artifact/com.johnsnowlabs.nlp/spark-nlp_2.12" alt="Maven Central">
41
- <img src="https://maven-badges.herokuapp.com/maven-central/com.johnsnowlabs.nlp/spark-nlp_2.12/badge.svg" /></a>
42
- <a href="https://badge.fury.io/py/spark-nlp" alt="PyPI version">
43
- <img src="https://badge.fury.io/py/spark-nlp.svg" /></a>
44
- <a href="https://anaconda.org/JohnSnowLabs/spark-nlp" alt="Anaconda-Cloud">
45
- <img src="https://anaconda.org/johnsnowlabs/spark-nlp/badges/version.svg" /></a>
46
- <a href="https://github.com/JohnSnowLabs/spark-nlp/blob/master/LICENSE" alt="License">
47
- <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" /></a>
48
- <a href="https://pypi.org/project/spark-nlp/" alt="PyPi downloads">
49
- <img src="https://static.pepy.tech/personalized-badge/spark-nlp?period=total&units=international_system&left_color=grey&right_color=orange&left_text=pip%20downloads" /></a>
50
- </p>
51
-
52
- Spark NLP is a state-of-the-art Natural Language Processing library built on top of Apache Spark. It provides **simple**, **performant** & **accurate** NLP annotations for machine learning pipelines that **scale** easily in a distributed
53
- environment.
54
- Spark NLP comes with **36000+** pretrained **pipelines** and **models** in more than **200+** languages.
55
- 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 tasks](#features).
56
-
57
- **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**, and many more not only to **Python** and **R**, but also to **JVM** ecosystem (**Java**, **Scala**, and **Kotlin**) at **scale** by extending **Apache Spark** natively.
58
-
59
- ## Project's website
60
-
61
- Take a look at our official Spark NLP page: [https://sparknlp.org/](https://sparknlp.org/) for user
62
- documentation and examples
63
-
64
- ## Community support
65
-
66
- - [Slack](https://join.slack.com/t/spark-nlp/shared_invite/zt-198dipu77-L3UWNe_AJ8xqDk0ivmih5Q) For live discussion with the Spark NLP community and the team
67
- - [GitHub](https://github.com/JohnSnowLabs/spark-nlp) Bug reports, feature requests, and contributions
68
- - [Discussions](https://github.com/JohnSnowLabs/spark-nlp/discussions) Engage with other community members, share ideas,
69
- and show off how you use Spark NLP!
70
- - [Medium](https://medium.com/spark-nlp) Spark NLP articles
71
- - [YouTube](https://www.youtube.com/channel/UCmFOjlpYEhxf_wJUDuz6xxQ/videos) Spark NLP video tutorials
72
-
73
- ## Table of contents
74
-
75
- - [Features](#features)
76
- - [Requirements](#requirements)
77
- - [Quick Start](#quick-start)
78
- - [Apache Spark Support](#apache-spark-support)
79
- - [Scala & Python Support](#scala-and-python-support)
80
- - [Databricks Support](#databricks-support)
81
- - [EMR Support](#emr-support)
82
- - [Using Spark NLP](#usage)
83
- - [Packages Cheatsheet](#packages-cheatsheet)
84
- - [Spark Packages](#spark-packages)
85
- - [Scala](#scala)
86
- - [Maven](#maven)
87
- - [SBT](#sbt)
88
- - [Python](#python)
89
- - [Pip/Conda](#pipconda)
90
- - [Compiled JARs](#compiled-jars)
91
- - [Apache Zeppelin](#apache-zeppelin)
92
- - [Jupyter Notebook](#jupyter-notebook-python)
93
- - [Google Colab Notebook](#google-colab-notebook)
94
- - [Kaggle Kernel](#kaggle-kernel)
95
- - [Databricks Cluster](#databricks-cluster)
96
- - [EMR Cluster](#emr-cluster)
97
- - [GCP Dataproc](#gcp-dataproc)
98
- - [Spark NLP Configuration](#spark-nlp-configuration)
99
- - [Pipelines & Models](#pipelines-and-models)
100
- - [Pipelines](#pipelines)
101
- - [Models](#models)
102
- - [Offline](#offline)
103
- - [Examples](#examples)
104
- - [FAQ](#faq)
105
- - [Citation](#citation)
106
- - [Contributing](#contributing)
107
-
108
- ## Features
109
-
110
- - Tokenization
111
- - Trainable Word Segmentation
112
- - Stop Words Removal
113
- - Token Normalizer
114
- - Document Normalizer
115
- - Document & Text Splitter
116
- - Stemmer
117
- - Lemmatizer
118
- - NGrams
119
- - Regex Matching
120
- - Text Matching
121
- - Chunking
122
- - Date Matcher
123
- - Sentence Detector
124
- - Deep Sentence Detector (Deep learning)
125
- - Dependency parsing (Labeled/unlabeled)
126
- - SpanBertCorefModel (Coreference Resolution)
127
- - Part-of-speech tagging
128
- - Sentiment Detection (ML models)
129
- - Spell Checker (ML and DL models)
130
- - Word Embeddings (GloVe and Word2Vec)
131
- - Doc2Vec (based on Word2Vec)
132
- - BERT Embeddings (TF Hub & HuggingFace models)
133
- - DistilBERT Embeddings (HuggingFace models)
134
- - CamemBERT Embeddings (HuggingFace models)
135
- - RoBERTa Embeddings (HuggingFace models)
136
- - DeBERTa Embeddings (HuggingFace v2 & v3 models)
137
- - XLM-RoBERTa Embeddings (HuggingFace models)
138
- - Longformer Embeddings (HuggingFace models)
139
- - ALBERT Embeddings (TF Hub & HuggingFace models)
140
- - XLNet Embeddings
141
- - ELMO Embeddings (TF Hub models)
142
- - Universal Sentence Encoder (TF Hub models)
143
- - BERT Sentence Embeddings (TF Hub & HuggingFace models)
144
- - RoBerta Sentence Embeddings (HuggingFace models)
145
- - XLM-RoBerta Sentence Embeddings (HuggingFace models)
146
- - INSTRUCTOR Embeddings (HuggingFace models)
147
- - E5 Embeddings (HuggingFace models)
148
- - MPNet Embeddings (HuggingFace models)
149
- - UAE Embeddings (HuggingFace models)
150
- - OpenAI Embeddings
151
- - Sentence & Chunk Embeddings
152
- - Unsupervised keywords extraction
153
- - Language Detection & Identification (up to 375 languages)
154
- - Multi-class & Multi-labe Sentiment analysis (Deep learning)
155
- - Multi-class Text Classification (Deep learning)
156
- - BERT for Token & Sequence Classification & Question Answering
157
- - DistilBERT for Token & Sequence Classification & Question Answering
158
- - CamemBERT for Token & Sequence Classification & Question Answering
159
- - ALBERT for Token & Sequence Classification & Question Answering
160
- - RoBERTa for Token & Sequence Classification & Question Answering
161
- - DeBERTa for Token & Sequence Classification & Question Answering
162
- - XLM-RoBERTa for Token & Sequence Classification & Question Answering
163
- - Longformer for Token & Sequence Classification & Question Answering
164
- - MPnet for Token & Sequence Classification & Question Answering
165
- - XLNet for Token & Sequence Classification
166
- - Zero-Shot NER Model
167
- - Zero-Shot Text Classification by Transformers (ZSL)
168
- - Neural Machine Translation (MarianMT)
169
- - Many-to-Many multilingual translation model (Facebook M2M100)
170
- - Table Question Answering (TAPAS)
171
- - Text-To-Text Transfer Transformer (Google T5)
172
- - Generative Pre-trained Transformer 2 (OpenAI GPT2)
173
- - Seq2Seq for NLG, Translation, and Comprehension (Facebook BART)
174
- - Chat and Conversational LLMs (Facebook Llama-2)
175
- - Vision Transformer (Google ViT)
176
- - Swin Image Classification (Microsoft Swin Transformer)
177
- - ConvNext Image Classification (Facebook ConvNext)
178
- - Vision Encoder Decoder for image-to-text like captioning
179
- - Zero-Shot Image Classification by OpenAI's CLIP
180
- - Automatic Speech Recognition (Wav2Vec2)
181
- - Automatic Speech Recognition (HuBERT)
182
- - Automatic Speech Recognition (OpenAI Whisper)
183
- - Named entity recognition (Deep learning)
184
- - Easy ONNX, OpenVINO, and TensorFlow integrations
185
- - GPU Support
186
- - Full integration with Spark ML functions
187
- - +31000 pre-trained models in +200 languages!
188
- - +6000 pre-trained pipelines in +200 languages!
189
- - Multi-lingual NER models: Arabic, Bengali, Chinese, Danish, Dutch, English, Finnish, French, German, Hebrew, Italian,
190
- Japanese, Korean, Norwegian, Persian, Polish, Portuguese, Russian, Spanish, Swedish, Urdu, and more.
191
-
192
- ## Requirements
193
-
194
- To use Spark NLP you need the following requirements:
195
-
196
- - Java 8 and 11
197
- - Apache Spark 3.5.x, 3.4.x, 3.3.x, 3.2.x, 3.1.x, 3.0.x
198
-
199
- **GPU (optional):**
200
-
201
- Spark NLP 5.5.0-rc1 is built with ONNX 1.17.0 and TensorFlow 2.7.1 deep learning engines. The minimum following NVIDIA® software are only required for GPU support:
202
-
203
- - NVIDIA® GPU drivers version 450.80.02 or higher
204
- - CUDA® Toolkit 11.2
205
- - cuDNN SDK 8.1.0
206
-
207
- ## Quick Start
208
-
209
- This is a quick example of how to use Spark NLP pre-trained pipeline in Python and PySpark:
210
-
211
- ```sh
212
- $ java -version
213
- # should be Java 8 or 11 (Oracle or OpenJDK)
214
- $ conda create -n sparknlp python=3.7 -y
215
- $ conda activate sparknlp
216
- # spark-nlp by default is based on pyspark 3.x
217
- $ pip install spark-nlp==5.5.0-rc1 pyspark==3.3.1
218
- ```
219
-
220
- In Python console or Jupyter `Python3` kernel:
221
-
222
- ```python
223
- # Import Spark NLP
224
- from sparknlp.base import *
225
- from sparknlp.annotator import *
226
- from sparknlp.pretrained import PretrainedPipeline
227
- import sparknlp
228
-
229
- # Start SparkSession with Spark NLP
230
- # start() functions has 3 parameters: gpu, apple_silicon, and memory
231
- # sparknlp.start(gpu=True) will start the session with GPU support
232
- # sparknlp.start(apple_silicon=True) will start the session with macOS M1 & M2 support
233
- # sparknlp.start(memory="16G") to change the default driver memory in SparkSession
234
- spark = sparknlp.start()
235
-
236
- # Download a pre-trained pipeline
237
- pipeline = PretrainedPipeline('explain_document_dl', lang='en')
238
-
239
- # Your testing dataset
240
- text = """
241
- The Mona Lisa is a 16th century oil painting created by Leonardo.
242
- It's held at the Louvre in Paris.
243
- """
244
-
245
- # Annotate your testing dataset
246
- result = pipeline.annotate(text)
247
-
248
- # What's in the pipeline
249
- list(result.keys())
250
- Output: ['entities', 'stem', 'checked', 'lemma', 'document',
251
- 'pos', 'token', 'ner', 'embeddings', 'sentence']
252
-
253
- # Check the results
254
- result['entities']
255
- Output: ['Mona Lisa', 'Leonardo', 'Louvre', 'Paris']
256
- ```
257
-
258
- For more examples, you can visit our dedicated [examples](https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples) to showcase all Spark NLP use cases!
259
-
260
- ## Apache Spark Support
261
-
262
- Spark NLP *5.5.0-rc1* has been built on top of Apache Spark 3.4 while fully supports Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x
263
-
264
- | Spark 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 |
265
- |-----------|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|
266
- | 5.4.x | YES | YES | YES | YES | YES | YES | NO | NO |
267
- | 5.3.x | YES | YES | YES | YES | YES | YES | NO | NO |
268
- | 5.2.x | YES | YES | YES | YES | YES | YES | NO | NO |
269
- | 5.1.x | Partially | YES | YES | YES | YES | YES | NO | NO |
270
- | 5.0.x | YES | YES | YES | YES | YES | YES | NO | NO |
271
- | 4.4.x | YES | YES | YES | YES | YES | YES | NO | NO |
272
- | 4.3.x | NO | NO | YES | YES | YES | YES | NO | NO |
273
- | 4.2.x | NO | NO | YES | YES | YES | YES | NO | NO |
274
- | 4.1.x | NO | NO | YES | YES | YES | YES | NO | NO |
275
- | 4.0.x | NO | NO | YES | YES | YES | YES | NO | NO |
276
-
277
- Find out more about `Spark NLP` versions from our [release notes](https://github.com/JohnSnowLabs/spark-nlp/releases).
278
-
279
- ## Scala and Python Support
280
-
281
- | Spark NLP | Python 3.6 | Python 3.7 | Python 3.8 | Python 3.9 | Python 3.10| Scala 2.11 | Scala 2.12 |
282
- |-----------|------------|------------|------------|------------|------------|------------|------------|
283
- | 5.3.x | NO | YES | YES | YES | YES | NO | YES |
284
- | 5.2.x | NO | YES | YES | YES | YES | NO | YES |
285
- | 5.1.x | NO | YES | YES | YES | YES | NO | YES |
286
- | 5.0.x | NO | YES | YES | YES | YES | NO | YES |
287
- | 4.4.x | NO | YES | YES | YES | YES | NO | YES |
288
- | 4.3.x | YES | YES | YES | YES | YES | NO | YES |
289
- | 4.2.x | YES | YES | YES | YES | YES | NO | YES |
290
- | 4.1.x | YES | YES | YES | YES | NO | NO | YES |
291
- | 4.0.x | YES | YES | YES | YES | NO | NO | YES |
292
-
293
- ## Databricks Support
294
-
295
- Spark NLP 5.5.0-rc1 has been tested and is compatible with the following runtimes:
296
-
297
- **CPU:**
298
-
299
- - 9.1
300
- - 9.1 ML
301
- - 10.1
302
- - 10.1 ML
303
- - 10.2
304
- - 10.2 ML
305
- - 10.3
306
- - 10.3 ML
307
- - 10.4
308
- - 10.4 ML
309
- - 10.5
310
- - 10.5 ML
311
- - 11.0
312
- - 11.0 ML
313
- - 11.1
314
- - 11.1 ML
315
- - 11.2
316
- - 11.2 ML
317
- - 11.3
318
- - 11.3 ML
319
- - 12.0
320
- - 12.0 ML
321
- - 12.1
322
- - 12.1 ML
323
- - 12.2
324
- - 12.2 ML
325
- - 13.0
326
- - 13.0 ML
327
- - 13.1
328
- - 13.1 ML
329
- - 13.2
330
- - 13.2 ML
331
- - 13.3
332
- - 13.3 ML
333
- - 14.0
334
- - 14.0 ML
335
- - 14.1
336
- - 14.1 ML
337
- - 14.2
338
- - 14.2 ML
339
- - 14.3
340
- - 14.3 ML
341
-
342
- **GPU:**
343
-
344
- - 9.1 ML & GPU
345
- - 10.1 ML & GPU
346
- - 10.2 ML & GPU
347
- - 10.3 ML & GPU
348
- - 10.4 ML & GPU
349
- - 10.5 ML & GPU
350
- - 11.0 ML & GPU
351
- - 11.1 ML & GPU
352
- - 11.2 ML & GPU
353
- - 11.3 ML & GPU
354
- - 12.0 ML & GPU
355
- - 12.1 ML & GPU
356
- - 12.2 ML & GPU
357
- - 13.0 ML & GPU
358
- - 13.1 ML & GPU
359
- - 13.2 ML & GPU
360
- - 13.3 ML & GPU
361
- - 14.0 ML & GPU
362
- - 14.1 ML & GPU
363
- - 14.2 ML & GPU
364
- - 14.3 ML & GPU
365
-
366
- ## EMR Support
367
-
368
- Spark NLP 5.5.0-rc1 has been tested and is compatible with the following EMR releases:
369
-
370
- - emr-6.2.0
371
- - emr-6.3.0
372
- - emr-6.3.1
373
- - emr-6.4.0
374
- - emr-6.5.0
375
- - emr-6.6.0
376
- - emr-6.7.0
377
- - emr-6.8.0
378
- - emr-6.9.0
379
- - emr-6.10.0
380
- - emr-6.11.0
381
- - emr-6.12.0
382
- - emr-6.13.0
383
- - emr-6.14.0
384
- - emr-6.15.0
385
- - emr-7.0.0
386
-
387
- Full list of [Amazon EMR 6.x releases](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-release-6x.html)
388
- Full list of [Amazon EMR 7.x releases](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-release-7x.html)
389
-
390
- NOTE: The EMR 6.1.0 and 6.1.1 are not supported.
391
-
392
- ## Usage
393
-
394
- ## Packages Cheatsheet
395
-
396
- This is a cheatsheet for corresponding Spark NLP Maven package to Apache Spark / PySpark major version:
397
-
398
- | Apache Spark | Spark NLP on CPU | Spark NLP on GPU | Spark NLP on AArch64 (linux) | Spark NLP on Apple Silicon |
399
- |-------------------------|--------------------|----------------------------|--------------------------------|--------------------------------------|
400
- | 3.0/3.1/3.2/3.3/3.4/3.5 | `spark-nlp` | `spark-nlp-gpu` | `spark-nlp-aarch64` | `spark-nlp-silicon` |
401
- | Start Function | `sparknlp.start()` | `sparknlp.start(gpu=True)` | `sparknlp.start(aarch64=True)` | `sparknlp.start(apple_silicon=True)` |
402
-
403
- NOTE: `M1/M2` and `AArch64` are under `experimental` support. Access and support to these architectures are limited by the
404
- community and we had to build most of the dependencies by ourselves to make them compatible. We support these two
405
- architectures, however, they may not work in some environments.
406
-
407
- ## Spark Packages
408
-
409
- ### Command line (requires internet connection)
410
-
411
- Spark NLP supports all major releases of Apache Spark 3.0.x, Apache Spark 3.1.x, Apache Spark 3.2.x, Apache Spark 3.3.x, Apache Spark 3.4.x, and Apache Spark 3.5.x
412
-
413
- #### Apache Spark 3.x (3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x - Scala 2.12)
414
-
415
- ```sh
416
- # CPU
417
-
418
- spark-shell --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
419
-
420
- pyspark --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
421
-
422
- spark-submit --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
423
- ```
424
-
425
- The `spark-nlp` has been published to
426
- the [Maven Repository](https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp).
427
-
428
- ```sh
429
- # GPU
430
-
431
- spark-shell --packages com.johnsnowlabs.nlp:spark-nlp-gpu_2.12:5.5.0-rc1
432
-
433
- pyspark --packages com.johnsnowlabs.nlp:spark-nlp-gpu_2.12:5.5.0-rc1
434
-
435
- spark-submit --packages com.johnsnowlabs.nlp:spark-nlp-gpu_2.12:5.5.0-rc1
436
-
437
- ```
438
-
439
- The `spark-nlp-gpu` has been published to
440
- the [Maven Repository](https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-gpu).
441
-
442
- ```sh
443
- # AArch64
444
-
445
- spark-shell --packages com.johnsnowlabs.nlp:spark-nlp-aarch64_2.12:5.5.0-rc1
446
-
447
- pyspark --packages com.johnsnowlabs.nlp:spark-nlp-aarch64_2.12:5.5.0-rc1
448
-
449
- spark-submit --packages com.johnsnowlabs.nlp:spark-nlp-aarch64_2.12:5.5.0-rc1
450
-
451
- ```
452
-
453
- The `spark-nlp-aarch64` has been published to
454
- the [Maven Repository](https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-aarch64).
455
-
456
- ```sh
457
- # M1/M2 (Apple Silicon)
458
-
459
- spark-shell --packages com.johnsnowlabs.nlp:spark-nlp-silicon_2.12:5.5.0-rc1
460
-
461
- pyspark --packages com.johnsnowlabs.nlp:spark-nlp-silicon_2.12:5.5.0-rc1
462
-
463
- spark-submit --packages com.johnsnowlabs.nlp:spark-nlp-silicon_2.12:5.5.0-rc1
464
-
465
- ```
466
-
467
- The `spark-nlp-silicon` has been published to
468
- the [Maven Repository](https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-silicon).
469
-
470
- **NOTE**: In case you are using large pretrained models like UniversalSentenceEncoder, you need to have the following
471
- set in your SparkSession:
472
-
473
- ```sh
474
- spark-shell \
475
- --driver-memory 16g \
476
- --conf spark.kryoserializer.buffer.max=2000M \
477
- --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
478
- ```
479
-
480
- ## Scala
481
-
482
- Spark NLP supports Scala 2.12.15 if you are using Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, and 3.4.x versions. Our packages are
483
- deployed to Maven central. To add any of our packages as a dependency in your application you can follow these
484
- coordinates:
485
-
486
- ### Maven
487
-
488
- **spark-nlp** on Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x:
489
-
490
- ```xml
491
- <!-- https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp -->
492
- <dependency>
493
- <groupId>com.johnsnowlabs.nlp</groupId>
494
- <artifactId>spark-nlp_2.12</artifactId>
495
- <version>5.5.0-rc1</version>
496
- </dependency>
497
- ```
498
-
499
- **spark-nlp-gpu:**
500
-
501
- ```xml
502
- <!-- https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-gpu -->
503
- <dependency>
504
- <groupId>com.johnsnowlabs.nlp</groupId>
505
- <artifactId>spark-nlp-gpu_2.12</artifactId>
506
- <version>5.5.0-rc1</version>
507
- </dependency>
508
- ```
509
-
510
- **spark-nlp-aarch64:**
511
-
512
- ```xml
513
- <!-- https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-aarch64 -->
514
- <dependency>
515
- <groupId>com.johnsnowlabs.nlp</groupId>
516
- <artifactId>spark-nlp-aarch64_2.12</artifactId>
517
- <version>5.5.0-rc1</version>
518
- </dependency>
519
- ```
520
-
521
- **spark-nlp-silicon:**
522
-
523
- ```xml
524
- <!-- https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-silicon -->
525
- <dependency>
526
- <groupId>com.johnsnowlabs.nlp</groupId>
527
- <artifactId>spark-nlp-silicon_2.12</artifactId>
528
- <version>5.5.0-rc1</version>
529
- </dependency>
530
- ```
531
-
532
- ### SBT
533
-
534
- **spark-nlp** on Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x:
535
-
536
- ```sbtshell
537
- // https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp
538
- libraryDependencies += "com.johnsnowlabs.nlp" %% "spark-nlp" % "5.5.0-rc1"
539
- ```
540
-
541
- **spark-nlp-gpu:**
542
-
543
- ```sbtshell
544
- // https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-gpu
545
- libraryDependencies += "com.johnsnowlabs.nlp" %% "spark-nlp-gpu" % "5.5.0-rc1"
546
- ```
547
-
548
- **spark-nlp-aarch64:**
549
-
550
- ```sbtshell
551
- // https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-aarch64
552
- libraryDependencies += "com.johnsnowlabs.nlp" %% "spark-nlp-aarch64" % "5.5.0-rc1"
553
- ```
554
-
555
- **spark-nlp-silicon:**
556
-
557
- ```sbtshell
558
- // https://mvnrepository.com/artifact/com.johnsnowlabs.nlp/spark-nlp-silicon
559
- libraryDependencies += "com.johnsnowlabs.nlp" %% "spark-nlp-silicon" % "5.5.0-rc1"
560
- ```
561
-
562
- Maven
563
- Central: [https://mvnrepository.com/artifact/com.johnsnowlabs.nlp](https://mvnrepository.com/artifact/com.johnsnowlabs.nlp)
564
-
565
- If you are interested, there is a simple SBT project for Spark NLP to guide you on how to use it in your
566
- projects [Spark NLP SBT Starter](https://github.com/maziyarpanahi/spark-nlp-starter)
567
-
568
- ## Python
569
-
570
- Spark NLP supports Python 3.6.x and above depending on your major PySpark version.
571
-
572
- ### Python without explicit Pyspark installation
573
-
574
- ### Pip/Conda
575
-
576
- If you installed pyspark through pip/conda, you can install `spark-nlp` through the same channel.
577
-
578
- Pip:
579
-
580
- ```bash
581
- pip install spark-nlp==5.5.0-rc1
582
- ```
583
-
584
- Conda:
585
-
586
- ```bash
587
- conda install -c johnsnowlabs spark-nlp
588
- ```
589
-
590
- PyPI [spark-nlp package](https://pypi.org/project/spark-nlp/) /
591
- Anaconda [spark-nlp package](https://anaconda.org/JohnSnowLabs/spark-nlp)
592
-
593
- Then you'll have to create a SparkSession either from Spark NLP:
594
-
595
- ```python
596
- import sparknlp
597
-
598
- spark = sparknlp.start()
599
- ```
600
-
601
- or manually:
602
-
603
- ```python
604
- spark = SparkSession.builder
605
- .appName("Spark NLP")
606
- .master("local[*]")
607
- .config("spark.driver.memory", "16G")
608
- .config("spark.driver.maxResultSize", "0")
609
- .config("spark.kryoserializer.buffer.max", "2000M")
610
- .config("spark.jars.packages", "com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1")
611
- .getOrCreate()
612
- ```
613
-
614
- If using local jars, you can use `spark.jars` instead for comma-delimited jar files. For cluster setups, of course,
615
- you'll have to put the jars in a reachable location for all driver and executor nodes.
616
-
617
- **Quick example:**
618
-
619
- ```python
620
- import sparknlp
621
- from sparknlp.pretrained import PretrainedPipeline
622
-
623
- # create or get Spark Session
624
-
625
- spark = sparknlp.start()
626
-
627
- sparknlp.version()
628
- spark.version
629
-
630
- # download, load and annotate a text by pre-trained pipeline
631
-
632
- pipeline = PretrainedPipeline('recognize_entities_dl', 'en')
633
- result = pipeline.annotate('The Mona Lisa is a 16th century oil painting created by Leonardo')
634
- ```
635
-
636
- ## Compiled JARs
637
-
638
- ### Build from source
639
-
640
- #### spark-nlp
641
-
642
- - FAT-JAR for CPU on Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x
643
-
644
- ```bash
645
- sbt assembly
646
- ```
647
-
648
- - FAT-JAR for GPU on Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x
649
-
650
- ```bash
651
- sbt -Dis_gpu=true assembly
652
- ```
653
-
654
- - FAT-JAR for M! on Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x
655
-
656
- ```bash
657
- sbt -Dis_silicon=true assembly
658
- ```
659
-
660
- ### Using the jar manually
661
-
662
- If for some reason you need to use the JAR, you can either download the Fat JARs provided here or download it
663
- from [Maven Central](https://mvnrepository.com/artifact/com.johnsnowlabs.nlp).
664
-
665
- To add JARs to spark programs use the `--jars` option:
666
-
667
- ```sh
668
- spark-shell --jars spark-nlp.jar
669
- ```
670
-
671
- The preferred way to use the library when running spark programs is using the `--packages` option as specified in
672
- the `spark-packages` section.
673
-
674
- ## Apache Zeppelin
675
-
676
- Use either one of the following options
677
-
678
- - Add the following Maven Coordinates to the interpreter's library list
679
-
680
- ```bash
681
- com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
682
- ```
683
-
684
- - Add a path to pre-built jar from [here](#compiled-jars) in the interpreter's library list making sure the jar is
685
- available to driver path
686
-
687
- ### Python in Zeppelin
688
-
689
- Apart from the previous step, install the python module through pip
690
-
691
- ```bash
692
- pip install spark-nlp==5.5.0-rc1
693
- ```
694
-
695
- Or you can install `spark-nlp` from inside Zeppelin by using Conda:
696
-
697
- ```bash
698
- python.conda install -c johnsnowlabs spark-nlp
699
- ```
700
-
701
- Configure Zeppelin properly, use cells with %spark.pyspark or any interpreter name you chose.
702
-
703
- Finally, in Zeppelin interpreter settings, make sure you set properly zeppelin.python to the python you want to use and
704
- install the pip library with (e.g. `python3`).
705
-
706
- An alternative option would be to set `SPARK_SUBMIT_OPTIONS` (zeppelin-env.sh) and make sure `--packages` is there as
707
- shown earlier since it includes both scala and python side installation.
708
-
709
- ## Jupyter Notebook (Python)
710
-
711
- **Recommended:**
712
-
713
- The easiest way to get this done on Linux and macOS is to simply install `spark-nlp` and `pyspark` PyPI packages and
714
- launch the Jupyter from the same Python environment:
715
-
716
- ```sh
717
- $ conda create -n sparknlp python=3.8 -y
718
- $ conda activate sparknlp
719
- # spark-nlp by default is based on pyspark 3.x
720
- $ pip install spark-nlp==5.5.0-rc1 pyspark==3.3.1 jupyter
721
- $ jupyter notebook
722
- ```
723
-
724
- Then you can use `python3` kernel to run your code with creating SparkSession via `spark = sparknlp.start()`.
725
-
726
- **Optional:**
727
-
728
- If you are in different operating systems and require to make Jupyter Notebook run by using pyspark, you can follow
729
- these steps:
730
-
731
- ```bash
732
- export SPARK_HOME=/path/to/your/spark/folder
733
- export PYSPARK_PYTHON=python3
734
- export PYSPARK_DRIVER_PYTHON=jupyter
735
- export PYSPARK_DRIVER_PYTHON_OPTS=notebook
736
-
737
- pyspark --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
738
- ```
739
-
740
- Alternatively, you can mix in using `--jars` option for pyspark + `pip install spark-nlp`
741
-
742
- If not using pyspark at all, you'll have to run the instructions
743
- pointed [here](#python-without-explicit-pyspark-installation)
744
-
745
- ## Google Colab Notebook
746
-
747
- Google Colab is perhaps the easiest way to get started with spark-nlp. It requires no installation or setup other than
748
- having a Google account.
749
-
750
- Run the following code in Google Colab notebook and start using spark-nlp right away.
751
-
752
- ```sh
753
- # This is only to setup PySpark and Spark NLP on Colab
754
- !wget https://setup.johnsnowlabs.com/colab.sh -O - | bash
755
- ```
756
-
757
- This script comes with the two options to define `pyspark` and `spark-nlp` versions via options:
758
-
759
- ```sh
760
- # -p is for pyspark
761
- # -s is for spark-nlp
762
- # -g will enable upgrading libcudnn8 to 8.1.0 on Google Colab for GPU usage
763
- # by default they are set to the latest
764
- !wget https://setup.johnsnowlabs.com/colab.sh -O - | bash /dev/stdin -p 3.2.3 -s 5.5.0-rc1
765
- ```
766
-
767
- [Spark NLP quick start on Google Colab](https://colab.research.google.com/github/JohnSnowLabs/spark-nlp/blob/master/examples/python/quick_start_google_colab.ipynb)
768
- is a live demo on Google Colab that performs named entity recognitions and sentiment analysis by using Spark NLP
769
- pretrained pipelines.
770
-
771
- ## Kaggle Kernel
772
-
773
- Run the following code in Kaggle Kernel and start using spark-nlp right away.
774
-
775
- ```sh
776
- # Let's setup Kaggle for Spark NLP and PySpark
777
- !wget https://setup.johnsnowlabs.com/kaggle.sh -O - | bash
778
- ```
779
-
780
- This script comes with the two options to define `pyspark` and `spark-nlp` versions via options:
781
-
782
- ```sh
783
- # -p is for pyspark
784
- # -s is for spark-nlp
785
- # -g will enable upgrading libcudnn8 to 8.1.0 on Kaggle for GPU usage
786
- # by default they are set to the latest
787
- !wget https://setup.johnsnowlabs.com/colab.sh -O - | bash /dev/stdin -p 3.2.3 -s 5.5.0-rc1
788
- ```
789
-
790
- [Spark NLP quick start on Kaggle Kernel](https://www.kaggle.com/mozzie/spark-nlp-named-entity-recognition) is a live
791
- demo on Kaggle Kernel that performs named entity recognitions by using Spark NLP pretrained pipeline.
792
-
793
- ## Databricks Cluster
794
-
795
- 1. Create a cluster if you don't have one already
796
-
797
- 2. On a new cluster or existing one you need to add the following to the `Advanced Options -> Spark` tab:
798
-
799
- ```bash
800
- spark.kryoserializer.buffer.max 2000M
801
- spark.serializer org.apache.spark.serializer.KryoSerializer
802
- ```
803
-
804
- 3. In `Libraries` tab inside your cluster you need to follow these steps:
805
-
806
- 3.1. Install New -> PyPI -> `spark-nlp==5.5.0-rc1` -> Install
807
-
808
- 3.2. Install New -> Maven -> Coordinates -> `com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1` -> Install
809
-
810
- 4. Now you can attach your notebook to the cluster and use Spark NLP!
811
-
812
- NOTE: Databricks' runtimes support different Apache Spark major releases. Please make sure you choose the correct Spark
813
- NLP Maven package name (Maven Coordinate) for your runtime from
814
- our [Packages Cheatsheet](https://github.com/JohnSnowLabs/spark-nlp#packages-cheatsheet)
815
-
816
- ## EMR Cluster
817
-
818
- To launch EMR clusters with Apache Spark/PySpark and Spark NLP correctly you need to have bootstrap and software
819
- configuration.
820
-
821
- A sample of your bootstrap script
822
-
823
- ```.sh
824
- #!/bin/bash
825
- set -x -e
826
-
827
- echo -e 'export PYSPARK_PYTHON=/usr/bin/python3
828
- export HADOOP_CONF_DIR=/etc/hadoop/conf
829
- export SPARK_JARS_DIR=/usr/lib/spark/jars
830
- export SPARK_HOME=/usr/lib/spark' >> $HOME/.bashrc && source $HOME/.bashrc
831
-
832
- sudo python3 -m pip install awscli boto spark-nlp
833
-
834
- set +x
835
- exit 0
836
-
837
- ```
838
-
839
- A sample of your software configuration in JSON on S3 (must be public access):
840
-
841
- ```.json
842
- [{
843
- "Classification": "spark-env",
844
- "Configurations": [{
845
- "Classification": "export",
846
- "Properties": {
847
- "PYSPARK_PYTHON": "/usr/bin/python3"
848
- }
849
- }]
850
- },
851
- {
852
- "Classification": "spark-defaults",
853
- "Properties": {
854
- "spark.yarn.stagingDir": "hdfs:///tmp",
855
- "spark.yarn.preserve.staging.files": "true",
856
- "spark.kryoserializer.buffer.max": "2000M",
857
- "spark.serializer": "org.apache.spark.serializer.KryoSerializer",
858
- "spark.driver.maxResultSize": "0",
859
- "spark.jars.packages": "com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1"
860
- }
861
- }]
862
- ```
863
-
864
- A sample of AWS CLI to launch EMR cluster:
865
-
866
- ```.sh
867
- aws emr create-cluster \
868
- --name "Spark NLP 5.5.0-rc1" \
869
- --release-label emr-6.2.0 \
870
- --applications Name=Hadoop Name=Spark Name=Hive \
871
- --instance-type m4.4xlarge \
872
- --instance-count 3 \
873
- --use-default-roles \
874
- --log-uri "s3://<S3_BUCKET>/" \
875
- --bootstrap-actions Path=s3://<S3_BUCKET>/emr-bootstrap.sh,Name=custome \
876
- --configurations "https://<public_access>/sparknlp-config.json" \
877
- --ec2-attributes KeyName=<your_ssh_key>,EmrManagedMasterSecurityGroup=<security_group_with_ssh>,EmrManagedSlaveSecurityGroup=<security_group_with_ssh> \
878
- --profile <aws_profile_credentials>
879
- ```
880
-
881
- ## GCP Dataproc
882
-
883
- 1. Create a cluster if you don't have one already as follows.
884
-
885
- At gcloud shell:
886
-
887
- ```bash
888
- gcloud services enable dataproc.googleapis.com \
889
- compute.googleapis.com \
890
- storage-component.googleapis.com \
891
- bigquery.googleapis.com \
892
- bigquerystorage.googleapis.com
893
- ```
894
-
895
- ```bash
896
- REGION=<region>
897
- ```
898
-
899
- ```bash
900
- BUCKET_NAME=<bucket_name>
901
- gsutil mb -c standard -l ${REGION} gs://${BUCKET_NAME}
902
- ```
903
-
904
- ```bash
905
- REGION=<region>
906
- ZONE=<zone>
907
- CLUSTER_NAME=<cluster_name>
908
- BUCKET_NAME=<bucket_name>
909
- ```
910
-
911
- You can set image-version, master-machine-type, worker-machine-type,
912
- master-boot-disk-size, worker-boot-disk-size, num-workers as your needs.
913
- If you use the previous image-version from 2.0, you should also add ANACONDA to optional-components.
914
- And, you should enable gateway.
915
- Don't forget to set the maven coordinates for the jar in properties.
916
-
917
- ```bash
918
- gcloud dataproc clusters create ${CLUSTER_NAME} \
919
- --region=${REGION} \
920
- --zone=${ZONE} \
921
- --image-version=2.0 \
922
- --master-machine-type=n1-standard-4 \
923
- --worker-machine-type=n1-standard-2 \
924
- --master-boot-disk-size=128GB \
925
- --worker-boot-disk-size=128GB \
926
- --num-workers=2 \
927
- --bucket=${BUCKET_NAME} \
928
- --optional-components=JUPYTER \
929
- --enable-component-gateway \
930
- --metadata 'PIP_PACKAGES=spark-nlp spark-nlp-display google-cloud-bigquery google-cloud-storage' \
931
- --initialization-actions gs://goog-dataproc-initialization-actions-${REGION}/python/pip-install.sh \
932
- --properties spark:spark.serializer=org.apache.spark.serializer.KryoSerializer,spark:spark.driver.maxResultSize=0,spark:spark.kryoserializer.buffer.max=2000M,spark:spark.jars.packages=com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
933
- ```
934
-
935
- 2. On an existing one, you need to install spark-nlp and spark-nlp-display packages from PyPI.
936
-
937
- 3. Now, you can attach your notebook to the cluster and use the Spark NLP!
938
-
939
- ## Spark NLP Configuration
940
-
941
- You can change the following Spark NLP configurations via Spark Configuration:
942
-
943
- | Property Name | Default | Meaning |
944
- |---------------------------------------------------------|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
945
- | `spark.jsl.settings.pretrained.cache_folder` | `~/cache_pretrained` | The location to download and extract pretrained `Models` and `Pipelines`. By default, it will be in User's Home directory under `cache_pretrained` directory |
946
- | `spark.jsl.settings.storage.cluster_tmp_dir` | `hadoop.tmp.dir` | The location to use on a cluster for temporarily files such as unpacking indexes for WordEmbeddings. By default, this locations is the location of `hadoop.tmp.dir` set via Hadoop configuration for Apache Spark. NOTE: `S3` is not supported and it must be local, HDFS, or DBFS |
947
- | `spark.jsl.settings.annotator.log_folder` | `~/annotator_logs` | The location to save logs from annotators during training such as `NerDLApproach`, `ClassifierDLApproach`, `SentimentDLApproach`, `MultiClassifierDLApproach`, etc. By default, it will be in User's Home directory under `annotator_logs` directory |
948
- | `spark.jsl.settings.aws.credentials.access_key_id` | `None` | Your AWS access key to use your S3 bucket to store log files of training models or access tensorflow graphs used in `NerDLApproach` |
949
- | `spark.jsl.settings.aws.credentials.secret_access_key` | `None` | Your AWS secret access key to use your S3 bucket to store log files of training models or access tensorflow graphs used in `NerDLApproach` |
950
- | `spark.jsl.settings.aws.credentials.session_token` | `None` | Your AWS MFA session token to use your S3 bucket to store log files of training models or access tensorflow graphs used in `NerDLApproach` |
951
- | `spark.jsl.settings.aws.s3_bucket` | `None` | Your AWS S3 bucket to store log files of training models or access tensorflow graphs used in `NerDLApproach` |
952
- | `spark.jsl.settings.aws.region` | `None` | Your AWS region to use your S3 bucket to store log files of training models or access tensorflow graphs used in `NerDLApproach` |
953
- | `spark.jsl.settings.onnx.gpuDeviceId` | `0` | Constructs CUDA execution provider options for the specified non-negative device id. |
954
- | `spark.jsl.settings.onnx.intraOpNumThreads` | `6` | Sets the size of the CPU thread pool used for executing a single graph, if executing on a CPU. |
955
- | `spark.jsl.settings.onnx.optimizationLevel` | `ALL_OPT` | Sets the optimization level of this options object, overriding the old setting. |
956
- | `spark.jsl.settings.onnx.executionMode` | `SEQUENTIAL` | Sets the execution mode of this options object, overriding the old setting. |
957
-
958
- ### How to set Spark NLP Configuration
959
-
960
- **SparkSession:**
961
-
962
- You can use `.config()` during SparkSession creation to set Spark NLP configurations.
963
-
964
- ```python
965
- from pyspark.sql import SparkSession
966
-
967
- spark = SparkSession.builder
968
- .master("local[*]")
969
- .config("spark.driver.memory", "16G")
970
- .config("spark.driver.maxResultSize", "0")
971
- .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
972
- .config("spark.kryoserializer.buffer.max", "2000m")
973
- .config("spark.jsl.settings.pretrained.cache_folder", "sample_data/pretrained")
974
- .config("spark.jsl.settings.storage.cluster_tmp_dir", "sample_data/storage")
975
- .config("spark.jars.packages", "com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1")
976
- .getOrCreate()
977
- ```
978
-
979
- **spark-shell:**
980
-
981
- ```sh
982
- spark-shell \
983
- --driver-memory 16g \
984
- --conf spark.driver.maxResultSize=0 \
985
- --conf spark.serializer=org.apache.spark.serializer.KryoSerializer
986
- --conf spark.kryoserializer.buffer.max=2000M \
987
- --conf spark.jsl.settings.pretrained.cache_folder="sample_data/pretrained" \
988
- --conf spark.jsl.settings.storage.cluster_tmp_dir="sample_data/storage" \
989
- --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
990
- ```
991
-
992
- **pyspark:**
993
-
994
- ```sh
995
- pyspark \
996
- --driver-memory 16g \
997
- --conf spark.driver.maxResultSize=0 \
998
- --conf spark.serializer=org.apache.spark.serializer.KryoSerializer
999
- --conf spark.kryoserializer.buffer.max=2000M \
1000
- --conf spark.jsl.settings.pretrained.cache_folder="sample_data/pretrained" \
1001
- --conf spark.jsl.settings.storage.cluster_tmp_dir="sample_data/storage" \
1002
- --packages com.johnsnowlabs.nlp:spark-nlp_2.12:5.5.0-rc1
1003
- ```
1004
-
1005
- **Databricks:**
1006
-
1007
- On a new cluster or existing one you need to add the following to the `Advanced Options -> Spark` tab:
1008
-
1009
- ```bash
1010
- spark.kryoserializer.buffer.max 2000M
1011
- spark.serializer org.apache.spark.serializer.KryoSerializer
1012
- spark.jsl.settings.pretrained.cache_folder dbfs:/PATH_TO_CACHE
1013
- spark.jsl.settings.storage.cluster_tmp_dir dbfs:/PATH_TO_STORAGE
1014
- spark.jsl.settings.annotator.log_folder dbfs:/PATH_TO_LOGS
1015
- ```
1016
-
1017
- NOTE: If this is an existing cluster, after adding new configs or changing existing properties you need to restart it.
1018
-
1019
- ### S3 Integration
1020
-
1021
- In Spark NLP we can define S3 locations to:
1022
-
1023
- - Export log files of training models
1024
- - Store tensorflow graphs used in `NerDLApproach`
1025
-
1026
- **Logging:**
1027
-
1028
- To configure S3 path for logging while training models. We need to set up AWS credentials as well as an S3 path
1029
-
1030
- ```bash
1031
- spark.conf.set("spark.jsl.settings.annotator.log_folder", "s3://my/s3/path/logs")
1032
- spark.conf.set("spark.jsl.settings.aws.credentials.access_key_id", "MY_KEY_ID")
1033
- spark.conf.set("spark.jsl.settings.aws.credentials.secret_access_key", "MY_SECRET_ACCESS_KEY")
1034
- spark.conf.set("spark.jsl.settings.aws.s3_bucket", "my.bucket")
1035
- spark.conf.set("spark.jsl.settings.aws.region", "my-region")
1036
- ```
1037
-
1038
- Now you can check the log on your S3 path defined in *spark.jsl.settings.annotator.log_folder* property.
1039
- Make sure to use the prefix *s3://*, otherwise it will use the default configuration.
1040
-
1041
- **Tensorflow Graphs:**
1042
-
1043
- To reference S3 location for downloading graphs. We need to set up AWS credentials
1044
-
1045
- ```bash
1046
- spark.conf.set("spark.jsl.settings.aws.credentials.access_key_id", "MY_KEY_ID")
1047
- spark.conf.set("spark.jsl.settings.aws.credentials.secret_access_key", "MY_SECRET_ACCESS_KEY")
1048
- spark.conf.set("spark.jsl.settings.aws.region", "my-region")
1049
- ```
1050
-
1051
- **MFA Configuration:**
1052
-
1053
- In case your AWS account is configured with MFA. You will need first to get temporal credentials and add session token
1054
- to the configuration as shown in the examples below
1055
- For logging:
1056
-
1057
- ```bash
1058
- spark.conf.set("spark.jsl.settings.aws.credentials.session_token", "MY_TOKEN")
1059
- ```
1060
-
1061
- An example of a bash script that gets temporal AWS credentials can be
1062
- found [here](https://github.com/JohnSnowLabs/spark-nlp/blob/master/scripts/aws_tmp_credentials.sh)
1063
- This script requires three arguments:
1064
-
1065
- ```bash
1066
- ./aws_tmp_credentials.sh iam_user duration serial_number
1067
- ```
1068
-
1069
- ## Pipelines and Models
1070
-
1071
- ### Pipelines
1072
-
1073
- **Quick example:**
1074
-
1075
- ```scala
1076
- import com.johnsnowlabs.nlp.pretrained.PretrainedPipeline
1077
- import com.johnsnowlabs.nlp.SparkNLP
1078
-
1079
- SparkNLP.version()
1080
-
1081
- val testData = spark.createDataFrame(Seq(
1082
- (1, "Google has announced the release of a beta version of the popular TensorFlow machine learning library"),
1083
- (2, "Donald John Trump (born June 14, 1946) is the 45th and current president of the United States")
1084
- )).toDF("id", "text")
1085
-
1086
- val pipeline = PretrainedPipeline("explain_document_dl", lang = "en")
1087
-
1088
- val annotation = pipeline.transform(testData)
1089
-
1090
- annotation.show()
1091
- /*
1092
- import com.johnsnowlabs.nlp.pretrained.PretrainedPipeline
1093
- import com.johnsnowlabs.nlp.SparkNLP
1094
- 2.5.0
1095
- testData: org.apache.spark.sql.DataFrame = [id: int, text: string]
1096
- pipeline: com.johnsnowlabs.nlp.pretrained.PretrainedPipeline = PretrainedPipeline(explain_document_dl,en,public/models)
1097
- annotation: org.apache.spark.sql.DataFrame = [id: int, text: string ... 10 more fields]
1098
- +---+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
1099
- | id| text| document| token| sentence| checked| lemma| stem| pos| embeddings| ner| entities|
1100
- +---+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
1101
- | 1|Google has announ...|[[document, 0, 10...|[[token, 0, 5, Go...|[[document, 0, 10...|[[token, 0, 5, Go...|[[token, 0, 5, Go...|[[token, 0, 5, go...|[[pos, 0, 5, NNP,...|[[word_embeddings...|[[named_entity, 0...|[[chunk, 0, 5, Go...|
1102
- | 2|The Paris metro w...|[[document, 0, 11...|[[token, 0, 2, Th...|[[document, 0, 11...|[[token, 0, 2, Th...|[[token, 0, 2, Th...|[[token, 0, 2, th...|[[pos, 0, 2, DT, ...|[[word_embeddings...|[[named_entity, 0...|[[chunk, 4, 8, Pa...|
1103
- +---+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
1104
- */
1105
-
1106
- annotation.select("entities.result").show(false)
1107
-
1108
- /*
1109
- +----------------------------------+
1110
- |result |
1111
- +----------------------------------+
1112
- |[Google, TensorFlow] |
1113
- |[Donald John Trump, United States]|
1114
- +----------------------------------+
1115
- */
1116
- ```
1117
-
1118
- #### Showing Available Pipelines
1119
-
1120
- There are functions in Spark NLP that will list all the available Pipelines
1121
- of a particular language for you:
1122
-
1123
- ```scala
1124
- import com.johnsnowlabs.nlp.pretrained.ResourceDownloader
1125
-
1126
- ResourceDownloader.showPublicPipelines(lang = "en")
1127
- /*
1128
- +--------------------------------------------+------+---------+
1129
- | Pipeline | lang | version |
1130
- +--------------------------------------------+------+---------+
1131
- | dependency_parse | en | 2.0.2 |
1132
- | analyze_sentiment_ml | en | 2.0.2 |
1133
- | check_spelling | en | 2.1.0 |
1134
- | match_datetime | en | 2.1.0 |
1135
- ...
1136
- | explain_document_ml | en | 3.1.3 |
1137
- +--------------------------------------------+------+---------+
1138
- */
1139
- ```
1140
-
1141
- Or if we want to check for a particular version:
1142
-
1143
- ```scala
1144
- import com.johnsnowlabs.nlp.pretrained.ResourceDownloader
1145
-
1146
- ResourceDownloader.showPublicPipelines(lang = "en", version = "3.1.0")
1147
- /*
1148
- +---------------------------------------+------+---------+
1149
- | Pipeline | lang | version |
1150
- +---------------------------------------+------+---------+
1151
- | dependency_parse | en | 2.0.2 |
1152
- ...
1153
- | clean_slang | en | 3.0.0 |
1154
- | clean_pattern | en | 3.0.0 |
1155
- | check_spelling | en | 3.0.0 |
1156
- | dependency_parse | en | 3.0.0 |
1157
- +---------------------------------------+------+---------+
1158
- */
1159
- ```
1160
-
1161
- #### Please check out our Models Hub for the full list of [pre-trained pipelines](https://sparknlp.org/models) with examples, demos, benchmarks, and more
1162
-
1163
- ### Models
1164
-
1165
- **Some selected languages:
1166
- ** `Afrikaans, Arabic, Armenian, Basque, Bengali, Breton, Bulgarian, Catalan, Czech, Dutch, English, Esperanto, Finnish, French, Galician, German, Greek, Hausa, Hebrew, Hindi, Hungarian, Indonesian, Irish, Italian, Japanese, Latin, Latvian, Marathi, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Slovak, Slovenian, Somali, Southern Sotho, Spanish, Swahili, Swedish, Tswana, Turkish, Ukrainian, Zulu`
1167
-
1168
- **Quick online example:**
1169
-
1170
- ```python
1171
- # load NER model trained by deep learning approach and GloVe word embeddings
1172
- ner_dl = NerDLModel.pretrained('ner_dl')
1173
- # load NER model trained by deep learning approach and BERT word embeddings
1174
- ner_bert = NerDLModel.pretrained('ner_dl_bert')
1175
- ```
1176
-
1177
- ```scala
1178
- // load French POS tagger model trained by Universal Dependencies
1179
- val french_pos = PerceptronModel.pretrained("pos_ud_gsd", lang = "fr")
1180
- // load Italian LemmatizerModel
1181
- val italian_lemma = LemmatizerModel.pretrained("lemma_dxc", lang = "it")
1182
- ````
1183
-
1184
- **Quick offline example:**
1185
-
1186
- - Loading `PerceptronModel` annotator model inside Spark NLP Pipeline
1187
-
1188
- ```scala
1189
- val french_pos = PerceptronModel.load("/tmp/pos_ud_gsd_fr_2.0.2_2.4_1556531457346/")
1190
- .setInputCols("document", "token")
1191
- .setOutputCol("pos")
1192
- ```
1193
-
1194
- #### Showing Available Models
1195
-
1196
- There are functions in Spark NLP that will list all the available Models
1197
- of a particular Annotator and language for you:
1198
-
1199
- ```scala
1200
- import com.johnsnowlabs.nlp.pretrained.ResourceDownloader
1201
-
1202
- ResourceDownloader.showPublicModels(annotator = "NerDLModel", lang = "en")
1203
- /*
1204
- +---------------------------------------------+------+---------+
1205
- | Model | lang | version |
1206
- +---------------------------------------------+------+---------+
1207
- | onto_100 | en | 2.1.0 |
1208
- | onto_300 | en | 2.1.0 |
1209
- | ner_dl_bert | en | 2.2.0 |
1210
- | onto_100 | en | 2.4.0 |
1211
- | ner_conll_elmo | en | 3.2.2 |
1212
- +---------------------------------------------+------+---------+
1213
- */
1214
- ```
1215
-
1216
- Or if we want to check for a particular version:
1217
-
1218
- ```scala
1219
- import com.johnsnowlabs.nlp.pretrained.ResourceDownloader
1220
-
1221
- ResourceDownloader.showPublicModels(annotator = "NerDLModel", lang = "en", version = "3.1.0")
1222
- /*
1223
- +----------------------------+------+---------+
1224
- | Model | lang | version |
1225
- +----------------------------+------+---------+
1226
- | onto_100 | en | 2.1.0 |
1227
- | ner_aspect_based_sentiment | en | 2.6.2 |
1228
- | ner_weibo_glove_840B_300d | en | 2.6.2 |
1229
- | nerdl_atis_840b_300d | en | 2.7.1 |
1230
- | nerdl_snips_100d | en | 2.7.3 |
1231
- +----------------------------+------+---------+
1232
- */
1233
- ```
1234
-
1235
- And to see a list of available annotators, you can use:
1236
-
1237
- ```scala
1238
- import com.johnsnowlabs.nlp.pretrained.ResourceDownloader
1239
-
1240
- ResourceDownloader.showAvailableAnnotators()
1241
- /*
1242
- AlbertEmbeddings
1243
- AlbertForTokenClassification
1244
- AssertionDLModel
1245
- ...
1246
- XlmRoBertaSentenceEmbeddings
1247
- XlnetEmbeddings
1248
- */
1249
- ```
1250
-
1251
- #### Please check out our Models Hub for the full list of [pre-trained models](https://sparknlp.org/models) with examples, demo, benchmark, and more
1252
-
1253
- ## Offline
1254
-
1255
- Spark NLP library and all the pre-trained models/pipelines can be used entirely offline with no access to the Internet.
1256
- If you are behind a proxy or a firewall with no access to the Maven repository (to download packages) or/and no access
1257
- to S3 (to automatically download models and pipelines), you can simply follow the instructions to have Spark NLP without
1258
- any limitations offline:
1259
-
1260
- - Instead of using the Maven package, you need to load our Fat JAR
1261
- - Instead of using PretrainedPipeline for pretrained pipelines or the `.pretrained()` function to download pretrained
1262
- models, you will need to manually download your pipeline/model from [Models Hub](https://sparknlp.org/models),
1263
- extract it, and load it.
1264
-
1265
- Example of `SparkSession` with Fat JAR to have Spark NLP offline:
1266
-
1267
- ```python
1268
- spark = SparkSession.builder
1269
- .appName("Spark NLP")
1270
- .master("local[*]")
1271
- .config("spark.driver.memory", "16G")
1272
- .config("spark.driver.maxResultSize", "0")
1273
- .config("spark.kryoserializer.buffer.max", "2000M")
1274
- .config("spark.jars", "/tmp/spark-nlp-assembly-5.5.0-rc1.jar")
1275
- .getOrCreate()
1276
- ```
1277
-
1278
- - You can download provided Fat JARs from each [release notes](https://github.com/JohnSnowLabs/spark-nlp/releases),
1279
- please pay attention to pick the one that suits your environment depending on the device (CPU/GPU) and Apache Spark
1280
- version (3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x)
1281
- - If you are local, you can load the Fat JAR from your local FileSystem, however, if you are in a cluster setup you need
1282
- to put the Fat JAR on a distributed FileSystem such as HDFS, DBFS, S3, etc. (
1283
- i.e., `hdfs:///tmp/spark-nlp-assembly-5.5.0-rc1.jar`)
1284
-
1285
- Example of using pretrained Models and Pipelines in offline:
1286
-
1287
- ```python
1288
- # instead of using pretrained() for online:
1289
- # french_pos = PerceptronModel.pretrained("pos_ud_gsd", lang="fr")
1290
- # you download this model, extract it, and use .load
1291
- french_pos = PerceptronModel.load("/tmp/pos_ud_gsd_fr_2.0.2_2.4_1556531457346/")
1292
- .setInputCols("document", "token")
1293
- .setOutputCol("pos")
1294
-
1295
- # example for pipelines
1296
- # instead of using PretrainedPipeline
1297
- # pipeline = PretrainedPipeline('explain_document_dl', lang='en')
1298
- # you download this pipeline, extract it, and use PipelineModel
1299
- PipelineModel.load("/tmp/explain_document_dl_en_2.0.2_2.4_1556530585689/")
1300
- ```
1301
-
1302
- - Since you are downloading and loading models/pipelines manually, this means Spark NLP is not downloading the most
1303
- recent and compatible models/pipelines for you. Choosing the right model/pipeline is on you
1304
- - If you are local, you can load the model/pipeline from your local FileSystem, however, if you are in a cluster setup
1305
- you need to put the model/pipeline on a distributed FileSystem such as HDFS, DBFS, S3, etc. (
1306
- i.e., `hdfs:///tmp/explain_document_dl_en_2.0.2_2.4_1556530585689/`)
1307
-
1308
- ## Examples
1309
-
1310
- Need more **examples**? Check out our dedicated [Spark NLP Examples](https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples)
1311
- repository to showcase all Spark NLP use cases!
1312
-
1313
- Also, don't forget to check [Spark NLP in Action](https://sparknlp.org/demo) built by Streamlit.
1314
-
1315
- ### All examples: [spark-nlp/examples](https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples)
1316
-
1317
- ## FAQ
1318
-
1319
- [Check our Articles and Videos page here](https://sparknlp.org/learn)
1320
-
1321
- ## Citation
1322
-
1323
- We have published a [paper](https://www.sciencedirect.com/science/article/pii/S2665963821000063) that you can cite for
1324
- the Spark NLP library:
1325
-
1326
- ```bibtex
1327
- @article{KOCAMAN2021100058,
1328
- title = {Spark NLP: Natural language understanding at scale},
1329
- journal = {Software Impacts},
1330
- pages = {100058},
1331
- year = {2021},
1332
- issn = {2665-9638},
1333
- doi = {https://doi.org/10.1016/j.simpa.2021.100058},
1334
- url = {https://www.sciencedirect.com/science/article/pii/S2665963.2.300063},
1335
- author = {Veysel Kocaman and David Talby},
1336
- keywords = {Spark, Natural language processing, Deep learning, Tensorflow, Cluster},
1337
- 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.}
1338
- }
1339
- }
1340
- ```
1341
-
1342
- ## Contributing
1343
-
1344
- We appreciate any sort of contributions:
1345
-
1346
- - ideas
1347
- - feedback
1348
- - documentation
1349
- - bug reports
1350
- - NLP training and testing corpora
1351
- - Development and testing
1352
-
1353
- Clone the repo and submit your pull-requests! Or directly create issues in this repo.
1354
-
1355
- ## John Snow Labs
1356
-
1357
- [http://johnsnowlabs.com](http://johnsnowlabs.com)