Detect Anatomical Structures (Single Entity - embeddings_clinical)

Description

An NER model to extract all types of anatomical references in text using “embeddings_clinical” embeddings. It is a single entity model and generalizes all anatomical references to a single entity.

Predicted Entities

Anatomy

Live Demo Open in Colab Download

How to use

Use as part of an nlp pipeline with the following stages: DocumentAssembler, SentenceDetector, Tokenizer, WordEmbeddingsModel, NerDLModel. Add the NerConverter to the end of the pipeline to convert entity tokens into full entity chunks.


clinical_ner = NerDLModel.pretrained("ner_anatomy_coarse", "en", "clinical/models") \
  .setInputCols(["sentence", "token", "embeddings"]) \
  .setOutputCol("ner")

nlpPipeline = Pipeline(stages=[clinical_ner])

empty_data = spark.createDataFrame([["content in the lung tissue"]]).toDF("text")

model = nlpPipeline.fit(empty_data)

results = model.transform(data)


val ner = NerDLModel.pretrained("ner_anatomy_coarse", "en", "clinical/models") \
  .setInputCols(["sentence", "token", "embeddings"]) \
  .setOutputCol("ner")

val pipeline = new Pipeline().setStages(Array(ner))

val result = pipeline.fit(Seq.empty["content in the lung tissue"].toDS.toDF("text")).transform(data)


Results

The output is a dataframe with a sentence per row and a “ner” column containing all of the entity labels in the sentence, entity character indices, and other metadata. To get only the tokens and entity labels, without the metadata, select “token.result” and “ner.result” from your output dataframe or add the “Finisher” to the end of your pipeline.me:

|    | ner_chunk         | entity    |
|---:|:------------------|:----------|
|  0 | lung tissue       | Anatomy   |

Model Information

Model Name: ner_anatomy_coarse
Type: NerDLModel
Compatibility: Spark NLP 2.6.1 +
Edition: Official
License: Licensed
Input Labels: [sentence, token, embeddings]
Output Labels: [ner]
Language: [en]
Case sensitive: false

Data Source

Trained on a custom dataset using ‘embeddings_clinical’.

Benchmarking

|    | label         |    tp |    fp |    fn |     prec |      rec |       f1 |
|---:|:--------------|------:|------:|------:|---------:|---------:|---------:|
|  0 | B-Anatomy     |  2568 |   165 |   158 | 0.939627 | 0.94204  | 0.940832 |
|  1 | I-Anatomy     |  1692 |    89 |   169 | 0.950028 | 0.909189 | 0.92916  |
|  2 | Macro-average | 4260  |  254  |   327 | 0.944827 | 0.925614 | 0.935122 |
|  3 | Micro-average | 4260  |  254  |   327 | 0.943731 | 0.928712 | 0.936161 |