Skip to content

Commit 61e8077

Browse files
authored
updated md card (#1194)
1 parent e4c3680 commit 61e8077

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

docs/_posts/akrztrk/2024-05-07-biolordresolve_snomed_findings_aux_concepts_en.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ This model maps clinical entities and concepts to SNOMED codes using `mpnet_embe
3535
{% include programmingLanguageSelectScalaPythonNLU.html %}
3636

3737
```python
38-
3938
documentAssembler = DocumentAssembler()\
4039
.setInputCol("text")\
4140
.setOutputCol("document")
@@ -70,35 +69,33 @@ chunk2doc = Chunk2Doc()\
7069
.setInputCols("ner_jsl_chunk")\
7170
.setOutputCol("ner_chunk_doc")
7271

73-
sbert_embedder = BertSentenceEmbeddings.pretrained("sbiobert_base_cased_mli","en","clinical/models")\
74-
.setInputCols(["ner_chunk_doc"])\
75-
.setOutputCol("sbert_embeddings")\
76-
.setCaseSensitive(False)
72+
embeddings = MPNetEmbeddings.pretrained("mpnet_embeddings_biolord_2023_c","en")\
73+
.setInputCols(["ner_chunk_doc"])\
74+
.setOutputCol("mpnet_embeddings")\
75+
.setCaseSensitive(False)
7776

7877
snomed_resolver = SentenceEntityResolverModel.pretrained("biolordresolve_snomed_findings_aux_concepts", "en", "clinical/models")\
79-
.setInputCols(["sbert_embeddings"])\
78+
.setInputCols(["mpnet_embeddings"])\
8079
.setOutputCol("snomed_code")\
8180
.setDistanceFunction("EUCLIDEAN")
8281

83-
nlpPipeline= Pipeline(stages=[
82+
resolver_pipeline= Pipeline(stages=[
8483
documentAssembler,
8584
sentenceDetector,
8685
tokenizer,
8786
word_embeddings,
8887
ner_jsl,
8988
ner_jsl_converter,
9089
chunk2doc,
91-
sbert_embedder,
90+
embeddings,
9291
snomed_resolver
9392
])
9493

9594
data = spark.createDataFrame([["""This is an 82-year-old male with a history of prior tobacco use, hypertension, chronic renal insufficiency, COPD, gastritis, and TIA. He initially presented to Braintree with a nonspecific ST-T abnormality and was transferred to St. Margaret’s Center. He underwent cardiac catheterization because of occlusion of the mid left anterior descending coronary artery lesion, which was complicated by hypotension and bradycardia. He required atropine, IV fluids, and dopamine, possibly secondary to a vagal reaction. He was subsequently transferred to the CCU for close monitoring. He was hemodynamically stable at the time of admission to the CCU."""]]).toDF("text")
9695

9796
result = resolver_pipeline.fit(data).transform(data)
98-
9997
```
10098
```scala
101-
10299
val documentAssembler = new DocumentAssembler()
103100
.setInputCol("text")
104101
.setOutputCol("document")
@@ -133,32 +130,31 @@ val chunk2doc = new Chunk2Doc()
133130
.setInputCols("ner_jsl_chunk")
134131
.setOutputCol("ner_chunk_doc")
135132

136-
val sbert_embedder = BertSentenceEmbeddings.pretrained("sbiobert_base_cased_mli","en","clinical/models")
137-
.setInputCols(["ner_chunk_doc"])
138-
.setOutputCol("sbert_embeddings")
139-
.setCaseSensitive(False)
133+
val embeddings = MPNetEmbeddings.pretrained("mpnet_embeddings_biolord_2023_c","en")\
134+
.setInputCols(["ner_chunk_doc"])\
135+
.setOutputCol("mpnet_embeddings")\
136+
.setCaseSensitive(False)
140137

141-
val snomed_resolver = SentenceEntityResolverModel.pretrained("biolordresolve_snomed_findings_aux_concepts", "en", "clinical/models")
142-
.setInputCols(["sbert_embeddings"])
143-
.setOutputCol("snomed_code")
138+
val snomed_resolver = SentenceEntityResolverModel.pretrained("biolordresolve_snomed_findings_aux_concepts", "en", "clinical/models")\
139+
.setInputCols(["mpnet_embeddings"])\
140+
.setOutputCol("snomed_code")\
144141
.setDistanceFunction("EUCLIDEAN")
145142

146-
val nlpPipeline= new Pipeline(stages=[
143+
val resolver_pipeline= new PipelineModel().setStages(Array(
147144
documentAssembler,
148145
sentenceDetector,
149146
tokenizer,
150147
word_embeddings,
151148
ner_jsl,
152149
ner_jsl_converter,
153150
chunk2doc,
154-
sbert_embedder,
151+
embeddings,
155152
snomed_resolver
156153
])
157154

158155
val data = Seq([["""This is an 82-year-old male with a history of prior tobacco use, hypertension, chronic renal insufficiency, COPD, gastritis, and TIA. He initially presented to Braintree with a nonspecific ST-T abnormality and was transferred to St. Margaret’s Center. He underwent cardiac catheterization because of occlusion of the mid left anterior descending coronary artery lesion, which was complicated by hypotension and bradycardia. He required atropine, IV fluids, and dopamine, possibly secondary to a vagal reaction. He was subsequently transferred to the CCU for close monitoring. He was hemodynamically stable at the time of admission to the CCU."""]]).toDF("text")
159156

160157
val result = resolver_pipeline.fit(data).transform(data)
161-
162158
```
163159
</div>
164160

0 commit comments

Comments
 (0)