Detect Genes/Proteins (BC2GM) in Medical Texts

Description

Named Entity recognition annotator allows for a generic model to be trained by utilizing a deep learning algorithm (Char CNNs - BiLSTM - CRF - word embeddings) inspired on a former state of the art model for NER: Chiu & Nicols, Named Entity Recognition with Bidirectional LSTM,CNN.

This model has been trained to extract genes/proteins from a medical text for PySpark 2.4.x users.

Predicted Entities

GENE_PROTEIN

Open in Colab Download

How to use

document_assembler = DocumentAssembler()\
	.setInputCol("text")\
	.setOutputCol("document")


sentenceDetectorDL = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare", "en", "clinical/models")\
	.setInputCols(["document"])\
	.setOutputCol("sentence")

  
tokenizer = Tokenizer()\
	.setInputCols(["sentence"])\
	.setOutputCol("token")

  
word_embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical" ,"en", "clinical/models")\
	.setInputCols(["sentence","token"])\
	.setOutputCol("embeddings")


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

ner_converter = NerConverter()\
	.setInputCols(["sentence", "token", "ner"])\
	.setOutputCol("ner_chunk")

  
nlpPipeline = Pipeline(stages=[
	document_assembler,
	sentenceDetectorDL,
	tokenizer,
	word_embeddings,
	ner,
	ner_converter])

  
data = spark.createDataFrame([["Immunohistochemical staining was positive for S-100 in all 9 cases stained, positive for HMB-45 in 9 (90%) of 10, and negative for cytokeratin in all 9 cases in which myxoid melanoma remained in the block after previous sections."]]).toDF("text")

result = nlpPipeline.fit(data).transform(data)
val document_assembler = new DocumentAssembler()
	.setInputCol("text")
	.setOutputCol("document")


val sentenceDetectorDL =
SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare", "en", "clinical/models")
	.setInputCols("document")
	.setOutputCol("sentence")

  
val tokenizer = new Tokenizer()
	.setInputCols("sentence")
	.setOutputCol("token")


val word_embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical" ,"en", "clinical/models")
	.setInputCols(Array("document","token"))
	.setOutputCol("word_embeddings")


val ner = MedicalNerModel.pretrained("ner_biomedical_bc2gm", "en", "clinical/models")
	.setInputCols(Array("sentence", "token", "word_embeddings"))
	.setOutputCol("ner")


val ner_converter = new NerConverter()
	.setInputCols(Array("sentence", "token", "ner"))
    .setOutputCol("ner_chunk")


val pipeline = new Pipeline().setStages(Array(
	document_assembler, 
	sentenceDetectorDL, 
	tokenizer, 
	word_embeddings, 
	ner, 
	ner_converter))


val data = Seq("Immunohistochemical staining was positive for S-100 in all 9 cases stained, positive for HMB-45 in 9 (90%) of 10, and negative for cytokeratin in all 9 cases in which myxoid melanoma remained in the block after previous sections.").toDS.toDF("text")

val result = pipeline.fit(data).transform(data)

Results

+-----------+------------+
|chunk      |ner_label   |
+-----------+------------+
|S-100      |GENE_PROTEIN|
|HMB-45     |GENE_PROTEIN|
|cytokeratin|GENE_PROTEIN|
+-----------+------------+

Model Information

Model Name: ner_biomedical_bc2gm
Compatibility: Spark NLP for Healthcare 3.5.1+
License: Licensed
Edition: Official
Input Labels: [sentence, token, embeddings]
Output Labels: [ner]
Language: en
Size: 14.6 MB

References

Created by Smith et al. at 2008, the BioCreative II Gene Mention Recognition (BC2GM) Dataset contains data where participants are asked to identify a gene mention in a sentence by giving its start and end characters. The training set consists of a set of sentences, and for each sentence a set of gene mentions (GENE annotations).

Benchmarking

        label precision recall f1-score support
 GENE_PROTEIN      0.83   0.82     0.82    6325
    micro-avg      0.83   0.82     0.82    6325
    macro-avg      0.83   0.82     0.82    6325
 weighted-avg      0.83   0.82     0.82    6325