需先装 Java 8 或 11(Spark 3.x)或 Java 17(Spark 4.x),否则 Spark 无法启动;spark-nlp 包版本必须与 PySpark/Spark 主版本及 Scala 版本对应,选错包会加载失败;预训练 pipeline 首次使用需联网下载模型,离线场景要提前按官方文档配置。
spark-nlp
JohnSnowLabsApache-2.0活跃维护基于 Spark 的分布式 NLP 库,把 BERT、LLM、ONNX 等模型封装成可直接调用的流水线,在集群上批量做命名实体识别、分词、翻译等任务。
State of the Art Natural Language Processing
pip install spark-nlp==7.0.0 pyspark==3.5.1README 未说明具体显存要求;可通过 sparknlp.start(gpu=True) 启用 GPU,通过 apple_silicon=True 支持 macOS M1/M2,并提供 AArch64 Linux 与 GPU 专用包。
基于 Apache Spark 的分布式 NLP 与 LLM 库,让大规模文本标注和 Transformer 推理能在集群上运行
基于 Spark 的分布式 NLP 库,把 BERT、LLM、ONNX 等模型封装成可直接调用的流水线,在集群上批量做命名实体识别、分词、翻译等任务。
核心能力
- 原生扩展 Apache Spark,支持 Python、R、Java、Scala、Kotlin
- 内置 10 万+ 预训练 pipeline 与模型,覆盖 200+ 语言
- 支持 BERT、RoBERTa、Llama-2、Mistral、Whisper 等 Transformer
- 可导入 TensorFlow、ONNX、OpenVINO、GGUF 格式模型
- 覆盖分词、NER、翻译、摘要、问答、语音识别等任务
容易踩的坑
- 7.0.0最新正式版2026-09-24 · 2026-09-24 04:10 UTC
📢 Spark NLP 7.0.0: Welcome, Apache Spark 4! New support for Spark 4.x alongside Spark 3.x
Spark NLP is taking a major step forward with 7.0.0: support for Apache Spark 4.x and Scala 2.13, while preserving the Spark 3.x / Scala 2.12 line. This is more than a version-number update. The Spark 4 work covers build profiles, annotation and UDF compatibility, annotator behavior, Python package selection, CI, and deployment guidance. If your team is moving to Spark 4, Spark NLP now has a dedicated path for you; teams staying on Spark 3 retain their own build line.
And there is more to explore: compare embedding pairs, rerank text with a cross-encoder, write expressive token-matching rules, summarize long documents, or translate documents with GGUF models. These additions make 7.0.0 a significant update for both existing Spark NLP pipelines and new Spark 4 projects. 🎉
🔥 Highlights
- Apache Spark 4.x support is the headline. Spark 4 / Scala 2.13 has its own build and artifact path, without dropping the Spark 3 / Scala 2.12 path. A distinct Spark 4.0.0 build handles an upstream binary-compatibility difference; choosing the right artifact matters. See the Spark 4 support spotlight below.
PairwiseVectorSimilarityandCrossEncoder. Score pairs of embeddings with cosine, dot product, or negative Euclidean distance, or use an ONNX cross-encoder to score a document/query pair together for reranking workflows. PairwiseVectorSimilarity / Spark 4 counterpart; CrossEncoder / Spark 4 counterpart.RuleBasedMatcher. Match token spans using rules over text and optional linguistic annotations, withCHUNKoutput for downstream pipeline stages. Spark 3 PR / Spark 4 PR.- Summarization and translation. A new
Summarizationestimator offers LLM, encoder–decoder, and extractive modes;DocumentTranslatorcombines document reading, sentence segmentation, and GGUF-based translation in a pipeline stage. Summarization / Spark 4 counterpart; DocumentTranslator / Spark 4 counterpart. - Reliability work. Corrections cover actual multi-row batching in optimized annotators, batched
ZeroShotNerdecoding, model runtime handling, and package selection. These are targeted changes, not a claim of universal performance or compatibility improvements.
🌟 Spotlight: Apache Spark 4.x support alongside Spark 3.x
The defining change in 7.0.0 is an additional Spark 4 / Scala 2.13 support line. This required more than recompilation: the branch updates annotation/UDF encoder paths and annotators, introduces distinct Spark 4 build profiles, adjusts Python Maven-coordinate selection, and adds Spark 4 CI and setup documentation. Spark 3 / Scala 2.12 remains a separate line; this release is about adding a choice, not replacing one. Spark 4 encoder work · annotator fixes · build profiles · CI work.
Why two Spark 4 artifacts?
The regular Spark 4 / Scala 2.13 profile compiles against Spark 4.0.1. A second
spark400profile targets unpatched Spark 4.0.0, which differs in the binary shape of Spark'sParamclass. According to the project's [Spark 4 migration guide](https://github.com/JohnSnowLabs/spark-nlp/blob/migration/scal - 6.4.22026-06-24 · 2026-06-24 17:49 UTC
查看更新说明
📢 Spark NLP 6.4.2: BM25 Retrieval, SaT Sentence Detection, and Model Conversion Workflows
Spark NLP 6.4.2 is a feature and reliability release focused on strengthening retrieval, sentence segmentation, model conversion, and release infrastructure. This release introduces
BM25ApproachandBM25Modelfor Okapi BM25 lexical retrieval, addsSentenceDetectorSaTModelfor transformer-based sentence boundary detection with SaT / Segment any Text models, and expands model conversion examples with new Hugging Face to Spark NLP notebooks for ONNX, OpenVINO, and GGUF workflows.In addition, this release improves production robustness by properly closing resource streams and file systems during local resource copying, which avoids leak warnings that can affect dependent pipelines. It also updates
jsl-llamacppto 2.0.3.🔥 Highlights
BM25Approach+BM25Model: New Okapi BM25 lexical retrieval annotators implemented as a fit-once, query-many Estimator/Model pair. They complement semantic retrieval components such asDocumentSimilarityRankerwith a fast, corpus-statistics-based lexical ranking option.SentenceDetectorSaTModel: New sentence detector based on SaT / Segment any Text transformer models. It uses ONNX-backed XLM-R SentencePiece models to produce sentence spans from per-token boundary probabilities and supports long documents through overlapping token windows.- Model conversion notebooks: New end-to-end notebooks demonstrate Hugging Face to Spark NLP conversion flows for ONNX, OpenVINO, and GGUF models.
🚀 New Features & Enhancements
BM25 Lexical Retrieval
Spark NLP 6.4.2 introduces BM25 lexical document retrieval through a two-stage Spark ML design. This implements SPARKNLP-1145 and adds a purely lexical ranking option that complements semantic retrieval components such as
DocumentSimilarityRanker.BM25Approachscans the tokenized corpus duringfit()and learns corpus-level statistics: document count, per-term document frequency, average document length, and inverse document frequency.BM25Modelreuses those learned statistics at transform time to score each document against a query.
This design is necessary because BM25 scores depend on corpus-level statistics that are only known after fitting over the full dataset. Once fitted, the model can be reused across many queries without rescanning the corpus.
Key capabilities:
- Emits
BM25_RANKINGSannotations. - Adds
bm25_score,num_query_terms_matched,query, anddoc_lenmetadata. - Supports range-validated
k1,b,minDocFreq, andcaseSensitiveparameters. - Uses the non-negative Lucene / Elasticsearch-style IDF variant.
- Supports
setQuery(...)for raw query strings. - Supports
setQueryTokens(...)for pre-analyzed query terms when the corpus pipeline includes normalization, stemming, lemmatization, or other token transformations. - Makes
caseSensitiveread-only on fittedBM25Modelto avoid corrupting scores after the IDF vocabulary has been built. - Includes Scala and Python tests for ranking, save/load, exact-score verification, query reuse, parameter propagation, analyzer symmetry, and invalid parameter handling.
from sparknlp.base import DocumentAssembler from sparknlp.annotator import Tokenizer, StopWordsCleaner, BM25Approach from pyspark.ml import Pipeline from pyspark.sql.functions import col, explode corpus = spark.createDataFrame([ (1, "Apples are a great source of dietary fiber and vitamin C."), (2, "Machine learning uses neural networks and statistical models."), (3, "Vitamin C deficiency can affect the immune system."), ], ["id", "text"]) document = DocumentAssembler() \ .setInputCol("text") \ .setOutputCol("document") tokenizer = Tokenizer() \ .setInputCols(["document"]) \ .setOutputCol("token") stop_words = StopWordsCleaner() \ .setIn - 6.4.12026-05-25 · 2026-05-25 21:01 UTC
查看更新说明
📢 Spark NLP 6.4.1: Late Chunking, Multimodal Embeddings, and Smarter Pretrained Workflows
Spark NLP 6.4.1 is a feature-rich follow-up release that expands retrieval and multimodal capabilities while improving pretrained model loading and production robustness. This release introduces two powerful new annotators:
LateChunkEmbeddingsfor context-aware chunk embeddings andBiEncoderMultimodalEmbeddingsfor dual-encoder text-image retrieval workflows.In addition,
VectorDBConnectornow supports multimodal image indexing, pretrained model resolution becomes smarter with preferred engine selection, and document ingestion workflows gain important reliability fixes for HTML readers and cloud-backed pretrained caches.For a deeper walkthrough of the major additions in this release, see our Medium post: Spark NLP 6.4.1: Context-Aware Retrieval, Engine Control, and Multimodal Indexing.
🔥 Highlights
LateChunkEmbeddings: A new annotator that applies the late chunking technique so chunk embeddings are computed from token embeddings generated over the full document context rather than embedding each chunk independently.BiEncoderMultimodalEmbeddings: A new multimodal dual-encoder annotator for generating aligned text and image embeddings for retrieval, search, and indexing workflows.- Multimodal
VectorDBConnector:VectorDBConnectornow supports indexing image embeddings in addition to text embeddings, enabling multimodal vector database pipelines. - Smarter
.pretrained()resolution: Pretrained model loading now supports a preferredengineparameter and resolves duplicate model names more reliably by filtering first by annotator class. - Improved production robustness: Fixes for cloud-backed pretrained caches and HTML reader header handling make Spark NLP more reliable in serverless and cloud-storage-based workflows.
🚀 New Features & Enhancements
LateChunkEmbeddings
Spark NLP 6.4.1 introduces
LateChunkEmbeddings, a new annotator based on the Late Chunking approach. Unlike traditional chunk embedding approaches that embed each chunk in isolation, this annotator assumes the upstream embedding model has already encoded the full document in a single pass. It then pools token embeddings corresponding to each chunk span, allowing every chunk embedding to retain broader document context.This is especially valuable for:
- Retrieval-augmented generation (RAG)
- Semantic search over long documents
- Chunk retrieval where local spans depend on earlier context
A follow-up improvement in this same release adds
sentenceAwareFiltering, which is enabled by default. This restricts pooling to token embeddings within the chunk’s sentence boundary, reducing noise from overlapping tokens across adjacent sentences.late_chunk = LateChunkEmbeddings() \ .setInputCols(["document", "chunk", "token", "embeddings"]) \ .setOutputCol("chunk_embeddings")See the LateChunkEmbeddings example notebook for a full walkthrough and practical usage examples. You can also read our Medium article for a broader explanation of why late chunking improves retrieval quality over naive chunk-first embedding pipelines.
BiEncoderMultimodalEmbeddings
This release adds
BiEncoderMultimodalEmbeddings, a new annotator for multimodal dual-encoder workflows. It accepts alignedDOCUMENTandIMAGEannotations and emits two embedding outputs:<outputCol>_doc_embeddings<outputCol>_image_embeddings
This enables use cas
- 6.4.02026-04-07 · 2026-04-07 21:20 UTC
查看更新说明
📢 Spark NLP 6.4.0: LLM-Powered Entity Extraction, Expanded Document Readers, and Pipeline Robustness
Spark NLP 6.4.0 is a feature-rich release focused on bringing LLM-powered extraction into standard NLP pipelines, dramatically expanding the document reader ecosystem, and hardening production ingestion workflows. This release introduces
LLMEntityExtractor, a new annotator that leverages on-device GGUF LLMs to extract named entities from text using flexible few-shot prompting, no fine-tuning required. We also introduceDocumentTitleSplitter, a semantic chunker for reader-based pipelines, and extend the document reader stack with native support for four new file formats: ODT, EPUB, TSV, and RTF. Finally, reader pipelines gain significant production robustness improvements including graceful error handling for HTML and image fetch failures.🔥 Highlights
LLMEntityExtractor: Use any GGUF-based LLM to extract named entities from text with configurable few-shot examples, no model fine-tuning needed. Returns results as standardCHUNKannotations compatible with the rest of the Spark NLP ecosystem.DocumentTitleSplitter: A new semantic annotator that splits element-level reader output into coherent chunks using title boundaries, designed to work alongsideReader2Docin element mode across Word, PDF, HTML, PowerPoint, ODT, and Markdown files.- Expanded Reader Format Support: ODT, EPUB, TSV, and RTF files are now first-class citizens in the Spark NLP reader stack, joinng the existing support for Word, PDF, HTML, PowerPoint, Markdown, CSV, and more.
- Resilient Reader Pipelines:
HTMLReaderandReader2Imagenow degrade gracefully on unreachable URLs and broken remote images rather than failing the entire Spark job critical for large-scale batch processing and ETL workflows. - Databricks Unity Catalog Volume support: Documentation and instructions added for loading pretrained models from Databricks Unity Catalog Volumes.
🚀 New Features & Enhancements
LLMEntityExtractor
Teams that need flexible entity extraction without model fine-tuning can now use
LLMEntityExtractorto leverage on-device GGUF models (viaAutoGGUFModel) for NER-style extraction. The annotator uses structured prompts (optionally enhanced with few-shot examples) to identify and extract entities from input text, returning them as standardCHUNKannotations.Key capabilities:
- Works with any GGUF-format LLM supported by
AutoGGUFModel - Supports configurable few-shot examples via
FewShotExampleobjects - Reasoning budget is set to 0 by default to minimize latency
- Includes partial JSON recovery for robustness against malformed LLM outputs
- Fully integrated into Python and Scala APIs, including
.pretrained()and.loadSavedModel()
llm_extractor = LLMEntityExtractor.pretrained() \ .setInputCols(["document"]) \ .setOutputCol("entities")See the LLMEntityExtractor example notebook for full usage including few-shot configuration.
DocumentTitleSplitter
Reader pipelines that use
Reader2Docin element mode produce structured output withelementTypemetadata (e.g.,Title,NarrativeText).DocumentTitleSplittercloses a key gap by turning this element sequence into semantic, title-bounded chunks that downstream annotators like sentence embedders and LLMs can consume coherently.Key parameters:
setSplitOnPageBreak(bool): Also enforce chunk boundaries on page breakssetJoinDelimiter(str): Delimiter used when joining narrative text within a chunksetMaxChunkLength(int): Overflow splitting for oversized title sections
Supported document types include Word, PDF, HTML, PowerPoint, ODT, and Markdown any format for which
Reader2Docextracts title metadata - 6.3.32026-03-10 · 2026-03-10 15:06 UTC
查看更新说明
📢 Spark NLP 6.3.3: ModernBERT Embeddings, Vector DB Integration, and Layout-Aware Document Processing
Spark NLP 6.3.3 is a feature-packed release aimed at practitioners building modern NLP and multimodal document pipelines. This release introduces
ModernBertEmbeddingsfor dramatically faster and more memory-efficient text embeddings,VectorDBConnectorto close the gap between embedding pipelines and vector search infrastructure.Moreover, we introduce a new suite of document-understanding annotators:
LayoutAlignerForVisionandLayoutAlignerForTextwhich together enable coherent end-to-end multimodal pipelines over complex documents like PDFs and PowerPoint files. To gain an in-depth walkthrough on how to build use your own pipelines and documents, please see our Medium blog post at Efficient Document Ingestion with Layout Aware Annotators: A Case Study on Mixed-Type Documents.In addition, a new
MultiColumnAssemblercan merge multiple annotation column into one andLightPipelinealso gains metadata column support for more powerful batch inference workflows.🔥 Highlights
ModernBertEmbeddings: A state-of-the-art encoder that is 8x faster and uses 5x less memory than traditional BERT, with native support for sequences up to 8192 tokens which is ideal for long-document NLP tasks.VectorDBConnector: Bridges Spark NLP embedding pipelines with external vector databases (initially Pinecone), so teams building semantic search and RAG systems no longer need custom glue code to store embeddings.LayoutAlignerForVisionandLayoutAlignerForText: New annotators for multimodal document pipelines that spatially align text and images from complex documents, giving downstream Vision-Language Models (VLMs) the coherent context they need to produce better results.MultiColumnAssembler: Closes a common pipeline gap when ReaderAssembler splits document content across multiple columns (text, table, image captions). This annotator merges them back into a single column that downstream annotators likeAutoGGUFVisionModelexpect.- Enhanced
LightPipelinewith metadata column support for richer, context-aware inference workflows.
🚀 New Features & Enhancements
ModernBertEmbeddings
Teams working with long documents, code, or large-scale embedding workloads will benefit from
ModernBertEmbeddings, which brings the latest generation of bidirectional encoder models to Spark NLP. Based on the paper Smarter, Better, Faster, Longer, ModernBERT was trained on 2 trillion tokens with a native sequence length of up to 8,192 tokens (eight times the limit of classic BERT) enabling faster, cheaper embeddings for longer sequences without truncation.- Default pretrained model:
"modernbert-base"(English) - 768-dimensional token-level
WORD_EMBEDDINGSoutput
embeddings = ModernBertEmbeddings.pretrained() \ .setInputCols(["document", "token"]) \ .setOutputCol("modernbert_embeddings")See the ModernBertEmbeddings notebook for extended examples, including how to import custom HuggingFace ModernBERT models via ONNX.
VectorDBConnector
For teams building semantic search, retrieval-augmented generation (RAG), or similarity-based recommendation systems, manually bridging Spark NLP with a vector database has historically required custom integration code.
VectorDBConnectoreliminates this gap by letting you store embeddings from any Spark NLP embedding annotator directly into a vector database as part of the pipeline. It initially supports Pinecone, with more providers planned
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Spark NLP: State-of-the-Art Natural Language Processing & LLMs Library
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 environment.
Spark NLP comes with 100000+ pretrained pipelines and models in more than 200+ languages. 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.
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, 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.
Model Importing Support
Spark NLP provides easy support for importing models from various popular frameworks:
- TensorFlow
- ONNX
- OpenVINO
- Llama.cpp (GGUF)
This wide range of support allows you to seamlessly integrate models from different sources into your Spark NLP workflows, enhancing flexibility and compatibility with existing machine learning ecosystems.
Project's website
Take a look at our official Spark NLP page: https://sparknlp.org/ for user documentation and examples
Features
- Text Preprocessing
- Parsing and Analysis
- Sentiment and Classification
- Embeddings
- Classification and Question Answering
- Machine Translation and Generation
- Image and Speech
- Integration and Interoperability (ONNX, OpenVINO)
- Pre-trained Models (36000+ in +200 languages)
- Multi-lingual Support
Quick Start
This is a quick example of how to use a Spark NLP pre-trained pipeline in Python and PySpark:
$ java -version
# Java 8 or 11 for Apache Spark 3.x, Java 17 for Apache Spark 4.x
$ conda create -n sparknlp python=3.9 -y
$ conda activate sparknlp
# Apache Spark 3.x (Scala 2.12) -> spark-nlp_2.12
$ pip install spark-nlp==7.0.0 pyspark==3.5.1
# Apache Spark 4.0.0 (Scala 2.13) -> spark-nlp-spark400_2.13
$ pip install spark-nlp==7.0.0 pyspark==4.0.0
# Apache Spark 4.0.1 and later validated Spark 4 versions (Scala 2.13) -> spark-nlp_2.13
$ pip install spark-nlp==7.0.0 pyspark==4.0.1
In Python console or Jupyter Python3 kernel:
# 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']
For more examples, you can visit our dedicated examples to showcase all Spark NLP use cases!
Packages Cheatsheet
This is a cheatsheet for corresponding Spark NLP Maven package to Apache Spark / PySpark major version:
| Apache Spark (Scala) | Spark NLP on CPU | Spark NLP on GPU | Spark NLP on AArch64 (linux) | Spark NLP on Apple Silicon |
|---|---|---|---|---|
| 3.0/3.1/3.2/3.3/3.4/3.5 (2.12) | spark-nlp | spark-nlp-gpu | spark-nlp-aarch64 | spark-nlp-silicon |
| 4.0.0 (2.13) | spark-nlp-spark400 | spark-nlp-gpu-spark400 | spark-nlp-aarch64-spark400 | spark-nlp-silicon-spark400 |
| 4.0.1/4.1.0/4.1.1/4.1.2 (2.13) | spark-nlp | spark-nlp-gpu | spark-nlp-aarch64 | spark-nlp-silicon |
| Start Function | sparknlp.start() | sparknlp.start(gpu=True) | sparknlp.start(aarch64=True) | sparknlp.start(apple_silicon=True) |
Append the Scala binary version to the artifact name for the Maven coordinate — for example
spark-nlp_2.12 on Apache Spark 3.x, spark-nlp-spark400_2.13 on Apache Spark 4.0.0, and
spark-nlp_2.13 on Apache Spark 4.0.1 and later validated Spark 4 versions. See the
install documentation for the full artifact table.
NOTE: M1/M2 and AArch64 are under experimental support. Access and support to these architectures are limited by the
community and we had to build most of the dependencies by ourselves to make them compatible. We support these two
architectures, however, they may not work in some environments.
Pipelines and Models
For a quick example of using pipelines and models take a look at our official documentation
Please check out our Models Hub for the full list of pre-trained models with examples, demo, benchmark, and more
Platform and Ecosystem Support
Apache Spark Support
Spark NLP 7.0.0 supports both Apache Spark 3.x (Scala 2.12) and the validated Apache Spark 4 versions
(Scala 2.13). Apache Spark 4.0.0 ships a separate artifact because of a binary-incompatible Param change,
so there are three artifact lanes:
| Apache Spark runtime | Scala | Maven artifact |
|---|---|---|
| 3.0.x - 3.5.x | 2.12 | spark-nlp_2.12 |
| 4.0.0 | 2.13 | spark-nlp-spark400_2.13 |
| 4.0.1, 4.1.0, 4.1.1, 4.1.2 | 2.13 | spark-nlp_2.13 |
Choose the artifact that matches your Spark distribution.
Apache Spark 3.x (Scala 2.12)
| 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 |
|---|---|---|---|---|---|---|---|---|
| 7.0.x | YES | YES | YES | YES | YES | YES | NO | NO |
| 6.x.x | YES | YES | YES | YES | YES | YES | NO | NO |
| 5.5.x | YES | YES | YES | YES | YES | YES | NO | NO |
| 5.4.x | YES | YES | YES | YES | YES | YES | NO | NO |
| 5.3.x | YES | YES | YES | YES | YES | YES | NO | NO |
| 5.2.x | YES | YES | YES | YES | YES | YES | NO | NO |
| 5.1.x | Partially | YES | YES | YES | YES | YES | NO | NO |
| 5.0.x | YES | YES | YES | YES | YES | YES | NO | NO |
Apache Spark 4 (Scala 2.13)
| Spark NLP | Apache Spark 4.0.0 (spark400 artifact) | Apache Spark 4.0.1 / 4.1.0 / 4.1.1 / 4.1.2 (default _2.13 artifact) |
|---|---|---|
| 7.0.x | YES | YES |
Find out more about Spark NLP versions from our release notes.
Scala and Python Support
Apache Spark 3.x (Scala 2.12)
| Spark NLP | Python 3.6 | Python 3.7 | Python 3.8 | Python 3.9 | Python 3.10 | Scala 2.11 | Scala 2.12 |
|---|---|---|---|---|---|---|---|
| 7.0.x | NO | YES | YES | YES | YES | NO | YES |
| 6.0.x | NO | YES | YES | YES | YES | NO | YES |
| 5.5.x | NO | YES | YES | YES | YES | NO | YES |
| 5.4.x | NO | YES | YES | YES | YES | NO | YES |
| 5.3.x | NO | YES | YES | YES | YES | NO | YES |
| 5.2.x | NO | YES | YES | YES | YES | NO | YES |
| 5.1.x | NO | YES | YES | YES | YES | NO | YES |
| 5.0.x | NO | YES | YES | YES | YES | NO | YES |
Apache Spark 4.x (Scala 2.13)
| Spark NLP | Python 3.9 | Python 3.10 | Python 3.11 | Python 3.12 | Scala 2.13 |
|---|---|---|---|---|---|
| 7.0.x | YES | YES | YES | YES | YES |
Find out more about SparkNLP versions in our official documentation
Databricks Support
Spark NLP is compatible with the following runtimes:
| CPU | GPU |
|---|---|
| 14.1 / 14.1 ML | 14.1 ML & GPU |
| 14.2 / 14.2 ML | 14.2 ML & GPU |
| 14.3 / 14.3 ML | 14.3 ML & GPU |
| 15.0 / 15.0 ML | 15.0 ML & GPU |
| 15.1 / 15.1 ML | 15.1 ML & GPU |
| 15.2 / 15.2 ML | 15.2 ML & GPU |
| 15.3 / 15.3 ML | 15.3 ML & GPU |
| 15.4 / 15.4 ML | 15.4 ML & GPU |
| 16.4 / 16.4 ML | 16.4 ML & GPU |
We are compatible with older runtimes. For a full list check databricks support in our official documentation
EMR Support
Spark NLP is compatible with the following Amazon EMR 6.x and 7.x releases:
| EMR Release |
|---|
| 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-7.3.0 |
| emr-7.4.0 |
| emr-7.5.0 |
| emr-7.6.0 |
| emr-7.7.0 |
| emr-7.8.0 |
Spark NLP includes a Spark 4 / Scala 2.13 lane. The EMR Serverless setup is compatible with the following Amazon EMR 8 release:
| EMR release | Spark | Scala | Java | Spark NLP artifact |
|---|---|---|---|---|
emr-spark-8.0.0 | 4.0.2-amzn-0 | 2.13 | 17 | spark-nlp_2.13 |
emr-spark-8.0.0 is a separate Spark-focused release label, not emr-8.0.0. Create a separate EMR Serverless application for this lane; an existing EMR 7.x application remains on Spark 3 / Scala 2.12.
We are compatible with older EMR releases. For a full list check EMR support in our official documentation
Full list of Amazon EMR 6.x releases Full list of Amazon EMR 7.x releases Amazon EMR Spark 8.0.0 release details
NOTE: The EMR 6.1.0 and 6.1.1 are not supported.
Installation
Command line (requires internet connection)
To install spark-nlp packages through command line follow these instructions from our official documentation
Scala
Spark NLP 7.0.0 supports Scala 2.12 with Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x, and Scala 2.13
with Apache Spark 4.0.0 (spark-nlp-spark400_2.13) and Apache Spark 4.0.1, 4.1.0, 4.1.1, and 4.1.2
(spark-nlp_2.13). Our packages are
deployed to Maven central. To add any of our packages as a dependency in your application you can follow these instructions
from our official documentation.
If you are interested, there is a simple SBT project for Spark NLP to guide you on how to use it in your projects Spark NLP Starter
Python
Spark NLP supports Python 3.7.x and above depending on your major PySpark version. Check all available installations for Python in our official documentation
Compiled JARs
To compile the jars from source follow these instructions from our official documentation
Platform-Specific Instructions
For detailed instructions on how to use Spark NLP on supported platforms, please refer to our official documentation:
| Platform | Supported Language(s) |
|---|---|
| Apache Zeppelin | Scala, Python |
| Jupyter Notebook | Python |
| Google Colab Notebook | Python |
| Kaggle Kernel | Python |
| Databricks Cluster | Scala, Python |
| EMR Cluster | Scala, Python |
| EMR Serverless | Python |
| GCP Dataproc Cluster | Scala, Python |
Offline
Spark NLP library and all the pre-trained models/pipelines can be used entirely offline with no access to the Internet. Please check these instructions from our official documentation to use Spark NLP offline.
Advanced Settings
You can change Spark NLP configurations via Spark properties configuration. Please check these instructions from our official documentation.
S3 Integration
In Spark NLP we can define S3 locations to:
- Export log files of training models
- Store tensorflow graphs used in
NerDLApproach
Please check these instructions from our official documentation.
Documentation
Examples
Need more examples? Check out our dedicated Spark NLP Examples repository to showcase all Spark NLP use cases!
Also, don't forget to check Spark NLP in Action built by Streamlit.
All examples: spark-nlp/examples
FAQ
Check our Articles and Videos page here
Citation
We have published a paper that you can cite for the Spark NLP library:
@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.}
}
}
Community support
- Slack For live discussion with the Spark NLP community and the team
- GitHub Bug reports, feature requests, and contributions
- Discussions Engage with other community members, share ideas, and show off how you use Spark NLP!
- Medium Spark NLP articles
- YouTube Spark NLP video tutorials
Contributing
We appreciate any sort of contributions:
- ideas
- feedback
- documentation
- bug reports
- NLP training and testing corpora
- Development and testing
Clone the repo and submit your pull-requests! Or directly create issues in this repo.