Getting Started#

Healthcare NLP is a commercial extension of Spark NLP for clinical and biomedical text mining. If you don’t have a Healthcare NLP subscription yet, you can request a free trial by clicking on the button below.

Try Free

Features#

Healthcare NLP provides healthcare-specific annotators, pipelines, models, and embeddings for:

  • Clinical Named Entity Recognition (NER) — signs, symptoms, tests, treatments, and hundreds of other clinical entities

  • Assertion Status Detection — present, absent, hypothetical, family history, etc.

  • Relation Extraction — link entities such as drug–dosage or test–result

  • Entity Resolution & Entity Linking — map entities to SNOMED, ICD-10, RxNorm, LOINC, and other terminologies

  • Entity Normalization

  • De-identification — detect, mask, and obfuscate protected health information (PHI)

  • Medical LLMs (MedicalLLM) — run generative healthcare language models on-premise for question answering, summarization, and reasoning

  • LLM Entity Extractor — zero-shot / prompt-based extraction of clinical entities

  • Text Matching & Regex Matching — dictionary- and pattern-based extraction

  • Rule-based Contextual Parsing

  • Spell Checking & Correction

  • Clinical Text Summarization

  • Clinical Text Generation

  • Risk Adjustment (HCC) Module

The library offers access to several clinical and biomedical transformers, such as JSL-BERT-Clinical, BioBERT, ClinicalBERT, GloVe-Med, and GloVe-ICD-O. It also includes over 2000+ pre-trained healthcare models that can recognize the following entities (and many more):

  • Clinical — Signs, Symptoms, Treatments, Procedures, Tests, Labs, Sections

  • Drugs — Name, Dosage, Strength, Route, Duration, Frequency

  • Risk Factors — Smoking, Obesity, Diabetes, Hypertension, Substance Abuse

  • Anatomy — Organ, Subdivision, Cell, Structure, Organism, Tissue, Gene, Chemical

  • Demographics — Age, Gender, Height, Weight, Race, Ethnicity, Marital Status, Vital Signs

  • Sensitive Data — Patient Name, Address, Phone, Email, Dates, Providers, Identifiers

For more information, visit our models hub.

Requirements#

Healthcare NLP is built on top of Apache Spark and supports both the Spark 3.x (Scala 2.12) and the Spark 4.x (Scala 2.13) runtimes. For using Healthcare NLP you need:

  • Java

    • Java 8 or Java 11 for Apache Spark 3.x.x

    • Java 17 (or later) for Apache Spark 4.x.x

  • Apache Spark

    • Apache Spark 3.x.x (Scala 2.12)

    • Apache Spark 4.x.x (Scala 2.13)

  • Python — 3.8.x, 3.9.x, 3.10.x, and 3.11.x

Note

The correct Scala 2.13 / spark400 artifacts are selected automatically from the installed PySpark version when you use sparknlp_jsl.start(), so the same code works on both Spark 3.x and Spark 4.x without changes.

It is recommended to have basic knowledge of the framework and a working environment before using Healthcare NLP. Please refer to the Spark documentation to get started with Spark.

Version Compatibility#

Healthcare NLP releases are aligned with specific open-source Spark NLP and Apache Spark versions. Before installing, make sure the versions you plan to use are compatible with each other by checking the official compatibility chart:

Spark NLP & Healthcare NLP version compatibility

Installation#

First, let’s make sure the installed Java version is compatible with your Spark runtime (Oracle or OpenJDK):

java -version
# openjdk version "1.8.0_292"   # Java 8/11 for Spark 3.x
# openjdk version "17.0.10"     # Java 17 for Spark 4.x

You can install the Healthcare NLP package by using:

pip install spark-nlp-jsl==${version} --extra-index-url https://pypi.johnsnowlabs.com/${secret.code} --upgrade

{version} is the version part of the {secret.code} ({secret.code}.split('-')[0]) (i.e. 6.x.x).

The {secret.code} is a secret code that is only available to users with a valid/trial license. If you have not received it yet, please contact us at info@johnsnowlabs.com.

Starting a Spark NLP Session from Python#

You can start the Spark session with this simple piece of code. The Scala 2.13 / Spark 4 artifacts are resolved automatically from your installed PySpark version:

import sparknlp_jsl
spark = sparknlp_jsl.start(secret="{secret.code}")

Or use the SparkSession module directly for more flexibility:

from pyspark.sql import SparkSession

spark = SparkSession.builder \
    .appName("Spark NLP Enterprise") \
    .master("local[*]") \
    .config("spark.driver.memory", "16G") \
    .config("spark.driver.maxResultSize", "2G") \
    .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") \
    .config("spark.kryoserializer.buffer.max", "2000M") \
    .config("spark.jars.packages", "com.johnsnowlabs.nlp:spark-nlp_2.12:${version_public}") \
    .config("spark.jars", "https://pypi.johnsnowlabs.com/${secret.code}/spark-nlp-jsl-${version}.jar") \
    .getOrCreate()

Note

The example above targets an Apache Spark 3.x (Scala 2.12) runtime. On Apache Spark 4.x (Scala 2.13), use the Scala 2.13 artifacts instead — for example com.johnsnowlabs.nlp:spark-nlp_2.13:${version_public} and spark-nlp-jsl_2.13-${version}.jar (or the spark400 variants on Spark 4.0.0). Using sparknlp_jsl.start() handles this selection for you.