Spaces:
Sleeping
Sleeping
Update pages/Workflow & Model Overview.py
Browse files- pages/Workflow & Model Overview.py +255 -253
pages/Workflow & Model Overview.py
CHANGED
@@ -1,253 +1,255 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
# Custom CSS for better styling
|
4 |
-
st.markdown("""
|
5 |
-
<style>
|
6 |
-
.main-title {
|
7 |
-
font-size: 36px;
|
8 |
-
color: #4A90E2;
|
9 |
-
font-weight: bold;
|
10 |
-
text-align: center;
|
11 |
-
}
|
12 |
-
.sub-title {
|
13 |
-
font-size: 24px;
|
14 |
-
color: #4A90E2;
|
15 |
-
margin-top: 20px;
|
16 |
-
}
|
17 |
-
.section {
|
18 |
-
background-color: #f9f9f9;
|
19 |
-
padding: 15px;
|
20 |
-
border-radius: 10px;
|
21 |
-
margin-top: 20px;
|
22 |
-
}
|
23 |
-
.section h2 {
|
24 |
-
font-size: 22px;
|
25 |
-
color: #4A90E2;
|
26 |
-
}
|
27 |
-
.section p, .section ul {
|
28 |
-
color: #666666;
|
29 |
-
}
|
30 |
-
.link {
|
31 |
-
color: #4A90E2;
|
32 |
-
text-decoration: none;
|
33 |
-
}
|
34 |
-
</style>
|
35 |
-
""", unsafe_allow_html=True)
|
36 |
-
|
37 |
-
# Main Title
|
38 |
-
st.markdown('<div class="main-title">State-of-the-Art Named Entity Recognition with Spark NLP (German)</div>', unsafe_allow_html=True)
|
39 |
-
|
40 |
-
# Introduction
|
41 |
-
st.markdown("""
|
42 |
-
<div class="section">
|
43 |
-
<p>Named Entity Recognition (NER) is the task of identifying important words in a text and associating them with a category. For example, we may be interested in finding all the personal names in documents, or company names in news articles. Other examples include domain-specific uses such as identifying all disease names in a clinical text, or company trading codes in financial ones.</p>
|
44 |
-
<p>NER can be implemented with many approaches. In this post, we introduce a deep learning-based method using the NerDL model. This approach leverages the scalability of Spark NLP with Python.</p>
|
45 |
-
</div>
|
46 |
-
""", unsafe_allow_html=True)
|
47 |
-
|
48 |
-
# Introduction to Spark NLP
|
49 |
-
st.markdown('<div class="sub-title">Introduction to Spark NLP</div>', unsafe_allow_html=True)
|
50 |
-
st.markdown("""
|
51 |
-
<div class="section">
|
52 |
-
<p>Spark NLP is an open-source library maintained by John Snow Labs. It is built on top of Apache Spark and Spark ML and provides simple, performant & accurate NLP annotations for machine learning pipelines that can scale easily in a distributed environment.</p>
|
53 |
-
<p>To install Spark NLP, you can simply use any package manager like conda or pip. For example, using pip you can simply run <code>pip install spark-nlp</code>. For different installation options, check the official <a href="https://nlp.johnsnowlabs.com/docs/en/install" target="_blank" class="link">documentation</a>.</p>
|
54 |
-
</div>
|
55 |
-
""", unsafe_allow_html=True)
|
56 |
-
|
57 |
-
# Using NerDL Model
|
58 |
-
st.markdown('<div class="sub-title">Using NerDL Model</div>', unsafe_allow_html=True)
|
59 |
-
st.markdown("""
|
60 |
-
<div class="section">
|
61 |
-
<p>The NerDL model in Spark NLP is a deep learning-based approach for NER tasks. It uses a Char CNNs - BiLSTM - CRF architecture that achieves state-of-the-art results in most datasets. The training data should be a labeled Spark DataFrame in the format of CoNLL 2003 IOB with annotation type columns.</p>
|
62 |
-
</div>
|
63 |
-
""", unsafe_allow_html=True)
|
64 |
-
|
65 |
-
# Setup Instructions
|
66 |
-
st.markdown('<div class="sub-title">Setup</div>', unsafe_allow_html=True)
|
67 |
-
st.markdown('<p>To install Spark NLP in Python, use your favorite package manager (conda, pip, etc.). For example:</p>', unsafe_allow_html=True)
|
68 |
-
st.code("""
|
69 |
-
pip install spark-nlp
|
70 |
-
pip install pyspark
|
71 |
-
""", language="bash")
|
72 |
-
|
73 |
-
st.markdown("<p>Then, import Spark NLP and start a Spark session:</p>", unsafe_allow_html=True)
|
74 |
-
st.code("""
|
75 |
-
import sparknlp
|
76 |
-
|
77 |
-
# Start Spark Session
|
78 |
-
spark = sparknlp.start()
|
79 |
-
""", language='python')
|
80 |
-
|
81 |
-
# Example Usage with NerDL Model in Italian
|
82 |
-
st.markdown('<div class="sub-title">Example Usage with NerDL Model in Italian</div>', unsafe_allow_html=True)
|
83 |
-
st.markdown("""
|
84 |
-
<div class="section">
|
85 |
-
<p>Below is an example of how to set up and use the NerDL model for named entity recognition in Italian:</p>
|
86 |
-
</div>
|
87 |
-
""", unsafe_allow_html=True)
|
88 |
-
st.code('''
|
89 |
-
from sparknlp.base import *
|
90 |
-
from sparknlp.annotator import *
|
91 |
-
from pyspark.ml import Pipeline
|
92 |
-
from pyspark.sql.functions import col, expr, round, concat, lit
|
93 |
-
|
94 |
-
# Document Assembler
|
95 |
-
document_assembler = DocumentAssembler() \\
|
96 |
-
.setInputCol("text") \\
|
97 |
-
.setOutputCol("document")
|
98 |
-
|
99 |
-
# Tokenizer
|
100 |
-
tokenizer = Tokenizer() \\
|
101 |
-
.setInputCols(["document"]) \\
|
102 |
-
.setOutputCol("token")
|
103 |
-
|
104 |
-
# Word Embeddings
|
105 |
-
embeddings = WordEmbeddingsModel.pretrained('glove_840B_300', lang='xx') \\
|
106 |
-
.setInputCols(["document", "token"]) \\
|
107 |
-
.setOutputCol("embeddings")
|
108 |
-
|
109 |
-
# NerDL Model
|
110 |
-
ner_model = NerDLModel.pretrained('ner_wikiner_glove_840B_300', 'xx') \\
|
111 |
-
.setInputCols(["document", "token", "embeddings"]) \\
|
112 |
-
.setOutputCol("ner")
|
113 |
-
|
114 |
-
# NER Converter
|
115 |
-
ner_converter = NerConverter() \\
|
116 |
-
.setInputCols(["document", "token", "ner"]) \\
|
117 |
-
.setOutputCol("ner_chunk")
|
118 |
-
|
119 |
-
# Pipeline
|
120 |
-
pipeline = Pipeline(stages=[
|
121 |
-
document_assembler,
|
122 |
-
tokenizer,
|
123 |
-
embeddings,
|
124 |
-
ner_model,
|
125 |
-
ner_converter
|
126 |
-
])
|
127 |
-
|
128 |
-
# Example sentence
|
129 |
-
example = """William Henry Gates III (* 28. Oktober 1955 in London) ist ein US-amerikanischer Geschäftsmann, Softwareentwickler, Investor und Philanthrop. Er ist bekannt als Mitbegründer der Microsoft Corporation. Während seiner Karriere bei Microsoft war Gates Vorsitzender, Chief Executive Officer (CEO), Präsident und Chief Software Architect und bis Mai 2014 der größte Einzelaktionär. Er ist einer der bekanntesten Unternehmer und Pioniere der Mikrocomputer-Revolution der 1970er und 1980er Jahre. Gates wurde in Seattle, Washington, geboren und wuchs dort auf. 1975 gründete er Microsoft zusammen mit seinem Freund aus Kindertagen, Paul Allen, in Albuquerque, New Mexico. Es entwickelte sich zum weltweit größten Unternehmen für Personal-Computer-Software. Gates leitete das Unternehmen als Chairman und CEO, bis er im Januar 2000 als CEO zurücktrat. Er blieb jedoch Chairman und wurde Chief Software Architect. In den späten neunziger Jahren wurde Gates für seine Geschäftstaktiken kritisiert, die als wettbewerbswidrig angesehen wurden. Diese Meinung wurde durch zahlreiche Gerichtsurteile bestätigt. Im Juni 2006 gab Gates bekannt, dass er eine Teilzeitstelle bei Microsoft und eine Vollzeitstelle bei der Bill & Melinda Gates Foundation, der privaten gemeinnützigen Stiftung, die er und seine Frau Melinda Gates im Jahr 2000 gegründet haben, übernehmen wird. [ 9] Er übertrug seine Aufgaben nach und nach auf Ray Ozzie und Craig Mundie. Im Februar 2014 trat er als Vorsitzender von Microsoft zurück und übernahm eine neue Position als Technologieberater, um den neu ernannten CEO Satya Nadella zu unterstützen."""
|
130 |
-
data = spark.createDataFrame([[example]]).toDF("text")
|
131 |
-
|
132 |
-
# Transforming data
|
133 |
-
result = pipeline.fit(data).transform(data)
|
134 |
-
|
135 |
-
# Select the result, entity, and confidence columns
|
136 |
-
result.select(
|
137 |
-
expr("explode(ner_chunk) as ner_chunk")
|
138 |
-
).select(
|
139 |
-
col("ner_chunk.result").alias("result"),
|
140 |
-
col("ner_chunk.metadata").getItem("entity").alias("entity"),
|
141 |
-
concat(
|
142 |
-
round((col("ner_chunk.metadata").getItem("confidence").cast("float") * 100), 2),
|
143 |
-
lit("%")
|
144 |
-
).alias("confidence")
|
145 |
-
).show(truncate=False)
|
146 |
-
''', language="python")
|
147 |
-
|
148 |
-
st.text("""
|
149 |
-
+-------------------------------+------+----------+
|
150 |
-
|result |entity|confidence|
|
151 |
-
+-------------------------------+------+----------+
|
152 |
-
|William Henry Gates III |PER |57.6% |
|
153 |
-
|London |LOC |91.51% |
|
154 |
-
|US-amerikanischer |MISC |99.56% |
|
155 |
-
|Microsoft Corporation |ORG |72.69% |
|
156 |
-
|Microsoft |ORG |98.13% |
|
157 |
-
|Gates |PER |93.14% |
|
158 |
-
|Gates |PER |77.17% |
|
159 |
-
|Seattle |LOC |89.12% |
|
160 |
-
|Washington |LOC |73.5% |
|
161 |
-
|Microsoft |ORG |95.15% |
|
162 |
-
|Paul Allen |PER |85.83% |
|
163 |
-
|Albuquerque |LOC |84.27% |
|
164 |
-
|New Mexico |LOC |67.22% |
|
165 |
-
|Gates |PER |97.12% |
|
166 |
-
|Gates |PER |97.68% |
|
167 |
-
|Gates |PER |98.26% |
|
168 |
-
|Microsoft |ORG |98.1% |
|
169 |
-
|Bill & Melinda Gates Foundation|MISC |42.91% |
|
170 |
-
|Melinda Gates |PER |87.0% |
|
171 |
-
|Ray Ozzie |PER |83.86% |
|
172 |
-
+-------------------------------+------+----------+
|
173 |
-
""")
|
174 |
-
|
175 |
-
# Benchmark Section
|
176 |
-
st.markdown('<div class="sub-title">Benchmark</div>', unsafe_allow_html=True)
|
177 |
-
st.markdown("""
|
178 |
-
<div class="section">
|
179 |
-
<p>Evaluating the performance of NER models is crucial to understanding their effectiveness in real-world applications. Below are the benchmark results for the "ner_wikiner_glove_840B_300" model on Italian text, focusing on various named entity categories. The metrics used include precision, recall, and F1-score, which are standard for evaluating classification models.</p>
|
180 |
-
</div>
|
181 |
-
""", unsafe_allow_html=True)
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
|
187 |
-
|
188 |
-
|
|
189 |
-
|
|
190 |
-
|
|
191 |
-
|
|
192 |
-
|
|
193 |
-
|
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
198 |
-
|
199 |
-
|
|
200 |
-
|
|
201 |
-
|
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
<div class="
|
226 |
-
|
227 |
-
|
228 |
-
""
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
<div class="
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
<li><a class="link" href="https://
|
238 |
-
<li
|
239 |
-
|
240 |
-
</
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
<div class="
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
<li><a class="link" href="https://
|
251 |
-
|
252 |
-
</
|
253 |
-
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Custom CSS for better styling
|
4 |
+
st.markdown("""
|
5 |
+
<style>
|
6 |
+
.main-title {
|
7 |
+
font-size: 36px;
|
8 |
+
color: #4A90E2;
|
9 |
+
font-weight: bold;
|
10 |
+
text-align: center;
|
11 |
+
}
|
12 |
+
.sub-title {
|
13 |
+
font-size: 24px;
|
14 |
+
color: #4A90E2;
|
15 |
+
margin-top: 20px;
|
16 |
+
}
|
17 |
+
.section {
|
18 |
+
background-color: #f9f9f9;
|
19 |
+
padding: 15px;
|
20 |
+
border-radius: 10px;
|
21 |
+
margin-top: 20px;
|
22 |
+
}
|
23 |
+
.section h2 {
|
24 |
+
font-size: 22px;
|
25 |
+
color: #4A90E2;
|
26 |
+
}
|
27 |
+
.section p, .section ul {
|
28 |
+
color: #666666;
|
29 |
+
}
|
30 |
+
.link {
|
31 |
+
color: #4A90E2;
|
32 |
+
text-decoration: none;
|
33 |
+
}
|
34 |
+
</style>
|
35 |
+
""", unsafe_allow_html=True)
|
36 |
+
|
37 |
+
# Main Title
|
38 |
+
st.markdown('<div class="main-title">State-of-the-Art Named Entity Recognition with Spark NLP (German)</div>', unsafe_allow_html=True)
|
39 |
+
|
40 |
+
# Introduction
|
41 |
+
st.markdown("""
|
42 |
+
<div class="section">
|
43 |
+
<p>Named Entity Recognition (NER) is the task of identifying important words in a text and associating them with a category. For example, we may be interested in finding all the personal names in documents, or company names in news articles. Other examples include domain-specific uses such as identifying all disease names in a clinical text, or company trading codes in financial ones.</p>
|
44 |
+
<p>NER can be implemented with many approaches. In this post, we introduce a deep learning-based method using the NerDL model. This approach leverages the scalability of Spark NLP with Python.</p>
|
45 |
+
</div>
|
46 |
+
""", unsafe_allow_html=True)
|
47 |
+
|
48 |
+
# Introduction to Spark NLP
|
49 |
+
st.markdown('<div class="sub-title">Introduction to Spark NLP</div>', unsafe_allow_html=True)
|
50 |
+
st.markdown("""
|
51 |
+
<div class="section">
|
52 |
+
<p>Spark NLP is an open-source library maintained by John Snow Labs. It is built on top of Apache Spark and Spark ML and provides simple, performant & accurate NLP annotations for machine learning pipelines that can scale easily in a distributed environment.</p>
|
53 |
+
<p>To install Spark NLP, you can simply use any package manager like conda or pip. For example, using pip you can simply run <code>pip install spark-nlp</code>. For different installation options, check the official <a href="https://nlp.johnsnowlabs.com/docs/en/install" target="_blank" class="link">documentation</a>.</p>
|
54 |
+
</div>
|
55 |
+
""", unsafe_allow_html=True)
|
56 |
+
|
57 |
+
# Using NerDL Model
|
58 |
+
st.markdown('<div class="sub-title">Using NerDL Model</div>', unsafe_allow_html=True)
|
59 |
+
st.markdown("""
|
60 |
+
<div class="section">
|
61 |
+
<p>The NerDL model in Spark NLP is a deep learning-based approach for NER tasks. It uses a Char CNNs - BiLSTM - CRF architecture that achieves state-of-the-art results in most datasets. The training data should be a labeled Spark DataFrame in the format of CoNLL 2003 IOB with annotation type columns.</p>
|
62 |
+
</div>
|
63 |
+
""", unsafe_allow_html=True)
|
64 |
+
|
65 |
+
# Setup Instructions
|
66 |
+
st.markdown('<div class="sub-title">Setup</div>', unsafe_allow_html=True)
|
67 |
+
st.markdown('<p>To install Spark NLP in Python, use your favorite package manager (conda, pip, etc.). For example:</p>', unsafe_allow_html=True)
|
68 |
+
st.code("""
|
69 |
+
pip install spark-nlp
|
70 |
+
pip install pyspark
|
71 |
+
""", language="bash")
|
72 |
+
|
73 |
+
st.markdown("<p>Then, import Spark NLP and start a Spark session:</p>", unsafe_allow_html=True)
|
74 |
+
st.code("""
|
75 |
+
import sparknlp
|
76 |
+
|
77 |
+
# Start Spark Session
|
78 |
+
spark = sparknlp.start()
|
79 |
+
""", language='python')
|
80 |
+
|
81 |
+
# Example Usage with NerDL Model in Italian
|
82 |
+
st.markdown('<div class="sub-title">Example Usage with NerDL Model in Italian</div>', unsafe_allow_html=True)
|
83 |
+
st.markdown("""
|
84 |
+
<div class="section">
|
85 |
+
<p>Below is an example of how to set up and use the NerDL model for named entity recognition in Italian:</p>
|
86 |
+
</div>
|
87 |
+
""", unsafe_allow_html=True)
|
88 |
+
st.code('''
|
89 |
+
from sparknlp.base import *
|
90 |
+
from sparknlp.annotator import *
|
91 |
+
from pyspark.ml import Pipeline
|
92 |
+
from pyspark.sql.functions import col, expr, round, concat, lit
|
93 |
+
|
94 |
+
# Document Assembler
|
95 |
+
document_assembler = DocumentAssembler() \\
|
96 |
+
.setInputCol("text") \\
|
97 |
+
.setOutputCol("document")
|
98 |
+
|
99 |
+
# Tokenizer
|
100 |
+
tokenizer = Tokenizer() \\
|
101 |
+
.setInputCols(["document"]) \\
|
102 |
+
.setOutputCol("token")
|
103 |
+
|
104 |
+
# Word Embeddings
|
105 |
+
embeddings = WordEmbeddingsModel.pretrained('glove_840B_300', lang='xx') \\
|
106 |
+
.setInputCols(["document", "token"]) \\
|
107 |
+
.setOutputCol("embeddings")
|
108 |
+
|
109 |
+
# NerDL Model
|
110 |
+
ner_model = NerDLModel.pretrained('ner_wikiner_glove_840B_300', 'xx') \\
|
111 |
+
.setInputCols(["document", "token", "embeddings"]) \\
|
112 |
+
.setOutputCol("ner")
|
113 |
+
|
114 |
+
# NER Converter
|
115 |
+
ner_converter = NerConverter() \\
|
116 |
+
.setInputCols(["document", "token", "ner"]) \\
|
117 |
+
.setOutputCol("ner_chunk")
|
118 |
+
|
119 |
+
# Pipeline
|
120 |
+
pipeline = Pipeline(stages=[
|
121 |
+
document_assembler,
|
122 |
+
tokenizer,
|
123 |
+
embeddings,
|
124 |
+
ner_model,
|
125 |
+
ner_converter
|
126 |
+
])
|
127 |
+
|
128 |
+
# Example sentence
|
129 |
+
example = """William Henry Gates III (* 28. Oktober 1955 in London) ist ein US-amerikanischer Geschäftsmann, Softwareentwickler, Investor und Philanthrop. Er ist bekannt als Mitbegründer der Microsoft Corporation. Während seiner Karriere bei Microsoft war Gates Vorsitzender, Chief Executive Officer (CEO), Präsident und Chief Software Architect und bis Mai 2014 der größte Einzelaktionär. Er ist einer der bekanntesten Unternehmer und Pioniere der Mikrocomputer-Revolution der 1970er und 1980er Jahre. Gates wurde in Seattle, Washington, geboren und wuchs dort auf. 1975 gründete er Microsoft zusammen mit seinem Freund aus Kindertagen, Paul Allen, in Albuquerque, New Mexico. Es entwickelte sich zum weltweit größten Unternehmen für Personal-Computer-Software. Gates leitete das Unternehmen als Chairman und CEO, bis er im Januar 2000 als CEO zurücktrat. Er blieb jedoch Chairman und wurde Chief Software Architect. In den späten neunziger Jahren wurde Gates für seine Geschäftstaktiken kritisiert, die als wettbewerbswidrig angesehen wurden. Diese Meinung wurde durch zahlreiche Gerichtsurteile bestätigt. Im Juni 2006 gab Gates bekannt, dass er eine Teilzeitstelle bei Microsoft und eine Vollzeitstelle bei der Bill & Melinda Gates Foundation, der privaten gemeinnützigen Stiftung, die er und seine Frau Melinda Gates im Jahr 2000 gegründet haben, übernehmen wird. [ 9] Er übertrug seine Aufgaben nach und nach auf Ray Ozzie und Craig Mundie. Im Februar 2014 trat er als Vorsitzender von Microsoft zurück und übernahm eine neue Position als Technologieberater, um den neu ernannten CEO Satya Nadella zu unterstützen."""
|
130 |
+
data = spark.createDataFrame([[example]]).toDF("text")
|
131 |
+
|
132 |
+
# Transforming data
|
133 |
+
result = pipeline.fit(data).transform(data)
|
134 |
+
|
135 |
+
# Select the result, entity, and confidence columns
|
136 |
+
result.select(
|
137 |
+
expr("explode(ner_chunk) as ner_chunk")
|
138 |
+
).select(
|
139 |
+
col("ner_chunk.result").alias("result"),
|
140 |
+
col("ner_chunk.metadata").getItem("entity").alias("entity"),
|
141 |
+
concat(
|
142 |
+
round((col("ner_chunk.metadata").getItem("confidence").cast("float") * 100), 2),
|
143 |
+
lit("%")
|
144 |
+
).alias("confidence")
|
145 |
+
).show(truncate=False)
|
146 |
+
''', language="python")
|
147 |
+
|
148 |
+
st.text("""
|
149 |
+
+-------------------------------+------+----------+
|
150 |
+
|result |entity|confidence|
|
151 |
+
+-------------------------------+------+----------+
|
152 |
+
|William Henry Gates III |PER |57.6% |
|
153 |
+
|London |LOC |91.51% |
|
154 |
+
|US-amerikanischer |MISC |99.56% |
|
155 |
+
|Microsoft Corporation |ORG |72.69% |
|
156 |
+
|Microsoft |ORG |98.13% |
|
157 |
+
|Gates |PER |93.14% |
|
158 |
+
|Gates |PER |77.17% |
|
159 |
+
|Seattle |LOC |89.12% |
|
160 |
+
|Washington |LOC |73.5% |
|
161 |
+
|Microsoft |ORG |95.15% |
|
162 |
+
|Paul Allen |PER |85.83% |
|
163 |
+
|Albuquerque |LOC |84.27% |
|
164 |
+
|New Mexico |LOC |67.22% |
|
165 |
+
|Gates |PER |97.12% |
|
166 |
+
|Gates |PER |97.68% |
|
167 |
+
|Gates |PER |98.26% |
|
168 |
+
|Microsoft |ORG |98.1% |
|
169 |
+
|Bill & Melinda Gates Foundation|MISC |42.91% |
|
170 |
+
|Melinda Gates |PER |87.0% |
|
171 |
+
|Ray Ozzie |PER |83.86% |
|
172 |
+
+-------------------------------+------+----------+
|
173 |
+
""")
|
174 |
+
|
175 |
+
# Benchmark Section
|
176 |
+
st.markdown('<div class="sub-title">Benchmark</div>', unsafe_allow_html=True)
|
177 |
+
st.markdown("""
|
178 |
+
<div class="section">
|
179 |
+
<p>Evaluating the performance of NER models is crucial to understanding their effectiveness in real-world applications. Below are the benchmark results for the "ner_wikiner_glove_840B_300" model on Italian text, focusing on various named entity categories. The metrics used include precision, recall, and F1-score, which are standard for evaluating classification models.</p>
|
180 |
+
</div>
|
181 |
+
""", unsafe_allow_html=True)
|
182 |
+
st.markdown("""
|
183 |
+
---
|
184 |
+
#### Classification Report
|
185 |
+
|
186 |
+
| Label | Precision | Recall | F1-Score | Support |
|
187 |
+
|-------|-----------|--------|----------|---------|
|
188 |
+
| B-LOC | 0.85 | 0.87 | 0.86 | 20709 |
|
189 |
+
| I-ORG | 0.82 | 0.82 | 0.82 | 5933 |
|
190 |
+
| I-LOC | 0.77 | 0.79 | 0.78 | 6405 |
|
191 |
+
| I-PER | 0.95 | 0.97 | 0.96 | 8365 |
|
192 |
+
| B-ORG | 0.83 | 0.73 | 0.78 | 6759 |
|
193 |
+
| B-PER | 0.92 | 0.93 | 0.92 | 10647 |
|
194 |
+
|
195 |
+
#### Averages
|
196 |
+
|
197 |
+
| Metric | Precision | Recall | F1-Score | Support |
|
198 |
+
|----------------|-----------|--------|----------|---------|
|
199 |
+
| Micro Average | 0.86 | 0.87 | 0.86 | 58818 |
|
200 |
+
| Macro Average | 0.86 | 0.85 | 0.85 | 58818 |
|
201 |
+
| Weighted Avg | 0.86 | 0.87 | 0.86 | 58818 |
|
202 |
+
|
203 |
+
#### Overall Metrics
|
204 |
+
|
205 |
+
- Processed 349,393 tokens with 46,006 phrases; found: 44,918 phrases; correct: 37,486.
|
206 |
+
- Accuracy (non-O): **83.53%**
|
207 |
+
- Overall Accuracy: **95.57%**
|
208 |
+
- Precision: **83.45%**
|
209 |
+
- Recall: **81.48%**
|
210 |
+
- F1 Score: **82.46**
|
211 |
+
|
212 |
+
#### Entity-Specific Metrics
|
213 |
+
|
214 |
+
| Entity | Precision | Recall | F1-Score | Instances |
|
215 |
+
|--------|-----------|--------|----------|-----------|
|
216 |
+
| LOC | 82.80% | 85.49% | 84.13 | 21382 |
|
217 |
+
| MISC | 77.46% | 66.53% | 71.58 | 6778 |
|
218 |
+
| ORG | 79.88% | 70.72% | 75.02 | 5984 |
|
219 |
+
| PER | 90.50% | 91.58% | 91.04 | 10774 |
|
220 |
+
|
221 |
+
---
|
222 |
+
""", unsafe_allow_html=True)
|
223 |
+
|
224 |
+
# Summary
|
225 |
+
st.markdown('<div class="sub-title">Summary</div>', unsafe_allow_html=True)
|
226 |
+
st.markdown("""
|
227 |
+
<div class="section">
|
228 |
+
<p>In this article, we discussed named entity recognition using a deep learning-based method with the "wikiner_840B_300" model for Italian. We introduced how to perform the task using the open-source Spark NLP library with Python, which can be used at scale in the Spark ecosystem. These methods can be used for natural language processing applications in various fields, including finance and healthcare.</p>
|
229 |
+
</div>
|
230 |
+
""", unsafe_allow_html=True)
|
231 |
+
|
232 |
+
# References
|
233 |
+
st.markdown('<div class="sub-title">References</div>', unsafe_allow_html=True)
|
234 |
+
st.markdown("""
|
235 |
+
<div class="section">
|
236 |
+
<ul>
|
237 |
+
<li><a class="link" href="https://sparknlp.org/api/python/reference/autosummary/sparknlp/annotator/ner/ner_dl/index.html" target="_blank" rel="noopener">NerDLModel</a> annotator documentation</li>
|
238 |
+
<li>Model Used: <a class="link" href="https://sparknlp.org/2021/07/19/ner_wikiner_glove_840B_300_xx.html" target="_blank" rel="noopener">ner_wikiner_glove_840B_300</a></li>
|
239 |
+
<li><a class="link" href="https://nlp.johnsnowlabs.com/recognize_entitie" target="_blank" rel="noopener">Visualization demos for NER in Spark NLP</a></li>
|
240 |
+
<li><a class="link" href="https://www.johnsnowlabs.com/named-entity-recognition-ner-with-bert-in-spark-nlp/">Named Entity Recognition (NER) with BERT in Spark NLP</a></li>
|
241 |
+
</ul>
|
242 |
+
</div>
|
243 |
+
""", unsafe_allow_html=True)
|
244 |
+
|
245 |
+
# Community & Support
|
246 |
+
st.markdown('<div class="sub-title">Community & Support</div>', unsafe_allow_html=True)
|
247 |
+
st.markdown("""
|
248 |
+
<div class="section">
|
249 |
+
<ul>
|
250 |
+
<li><a class="link" href="https://sparknlp.org/" target="_blank">Official Website</a>: Documentation and examples</li>
|
251 |
+
<li><a class="link" href="https://join.slack.com/t/spark-nlp/shared_invite/zt-198dipu77-L3UWNe_AJf4Rqb3DaMb-7A" target="_blank">Slack Community</a>: Connect with other Spark NLP users</li>
|
252 |
+
<li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp" target="_blank">GitHub Repository</a>: Source code and issue tracker</li>
|
253 |
+
</ul>
|
254 |
+
</div>
|
255 |
+
""", unsafe_allow_html=True)
|