import streamlit as st # Custom CSS for better styling st.markdown(""" """, unsafe_allow_html=True) # Main Title st.markdown('
Detect Entities (66-labeled) in General Scope
', unsafe_allow_html=True) # Description st.markdown("""

This app utilizes the nerdl_fewnerd_subentity_100d model, which is trained on the Few-NERD/inter public dataset to detect 66 entities with high accuracy. The model is based on 100d GloVe embeddings, ensuring robust entity detection.

""", unsafe_allow_html=True) # What is Entity Recognition st.markdown('
What is Entity Recognition?
', unsafe_allow_html=True) st.markdown("""

Entity Recognition is a task in Natural Language Processing (NLP) that involves identifying and classifying named entities in text into predefined categories. For general texts, this model focuses on detecting a wide range of entities, which are crucial for understanding and analyzing diverse content.

""", unsafe_allow_html=True) # Model Importance and Applications st.markdown('
Model Importance and Applications
', unsafe_allow_html=True) st.markdown("""

The nerdl_fewnerd_subentity_100d model is highly effective for extracting named entities from general texts. Its applications include:

Why use the nerdl_fewnerd_subentity_100d model?

""", unsafe_allow_html=True) # Predicted Entities st.markdown('
Predicted Entities
', unsafe_allow_html=True) # st.markdown(""" #
# #
# """, unsafe_allow_html=True) st.markdown("""

building-theater, art-other, location-bodiesofwater, other-god, organization-politicalparty, product-other, building-sportsfacility, building-restaurant, organization-sportsleague, event-election, organization-media/newspaper, product-software, other-educationaldegree, person-politician, person-soldier, other-disease, product-airplane, person-athlete, location-mountain, organization-company, other-biologything, location-other, other-livingthing, person-actor, organization-other, event-protest, art-film, other-award, other-astronomything, building-airport, product-food, person-other, event-disaster, product-weapon, event-sportsevent, location-park, product-ship, building-library, art-painting, building-other, other-currency, organization-education, person-scholar, organization-showorganization, person-artist/author, product-train, location-GPE, product-car, art-writtenart, event-attack/battle/war/militaryconflict, other-law, other-medical, organization-sportsteam, art-broadcastprogram, art-music, organization-government/governmentagency, other-language, event-other, person-director, other-chemicalthing, product-game, organization-religion, location-road/railway/highway/transit, location-island, building-hotel, building-hospital

""", unsafe_allow_html=True) # How to Use the Model st.markdown('
How to Use the Model
', unsafe_allow_html=True) st.code(''' from sparknlp.base import * from sparknlp.annotator import * from pyspark.ml import Pipeline from pyspark.sql.functions import col, expr # Load the pre-trained model document_assembler = DocumentAssembler() \\ .setInputCol("text") \\ .setOutputCol("document") sentence_detector = SentenceDetector() \\ .setInputCols(["document"]) \\ .setOutputCol("sentence") tokenizer = Tokenizer() \\ .setInputCols(["sentence"]) \\ .setOutputCol("token") embeddings = WordEmbeddingsModel.pretrained("glove_100d", "en")\\ .setInputCols("sentence", "token") \\ .setOutputCol("embeddings") ner_tagger = NerDLModel.pretrained("nerdl_fewnerd_subentity_100d", "en") \\ .setInputCols(['sentence', 'token', 'embeddings']) \\ .setOutputCol("ner") ner_converter = NerConverter() \\ .setInputCols(["document", "token", "ner"]) \\ .setOutputCol("ner_chunk") pipeline = Pipeline(stages=[ document_assembler, sentence_detector, tokenizer, embeddings, ner_tagger, ner_converter ]) # Sample text text = """ In 2023, Apple Inc. announced the release of their new iPhone 15 at a major event held in San Francisco. The announcement was made by Tim Cook, the CEO of Apple, who highlighted the innovative features of the device, including its advanced camera system and improved battery life. The event took place on September 12, 2023, and was streamed live on the company's official website. During the event, several prominent tech bloggers, such as John Doe from TechCrunch and Jane Smith from The Verge, were present to cover the announcement. Additionally, the event featured a surprise appearance by popular musician Taylor Swift, who performed her hit single "Anti-Hero." The new iPhone 15 will be available for pre-order starting on September 15, 2023, and is expected to hit the stores on September 22, 2023. """ # Create a DataFrame with the text data = spark.createDataFrame([[text]]).toDF("text") # Apply the pipeline to the data model = pipeline.fit(data) result = model.transform(data) # Display results result.select( expr("explode(ner_chunk) as ner_chunk") ).select( col("ner_chunk.result").alias("chunk"), col("ner_chunk.metadata.entity").alias("ner_label") ).show(truncate=False) ''', language='python') st.text(""" +-------------+----------------------------+ |chunk |ner_label | +-------------+----------------------------+ |Apple Inc. |organization-company | |iPhone 15 |product-other | |San Francisco|location-GPE | |Apple |organization-company | |company's |location-GPE | |TechCrunch |organization-media/newspaper| |Taylor Swift |person-artist/author | |iPhone 15 |product-other | +-------------+----------------------------+ """) # Model Information st.markdown('
Model Information
', unsafe_allow_html=True) st.markdown("""
Attribute Description
Model Name nerdl_fewnerd_subentity_100d
Type ner
Compatibility Spark NLP 3.1.1+
License Open Source
Edition Official
Input Labels [sentence, token, embeddings]
Output Labels [ner]
Language en
""", unsafe_allow_html=True) # Data Source Information st.markdown('
Data Source Information
', unsafe_allow_html=True) st.markdown("""
Attribute Description
Dataset Few-NERD: A Few-shot Named Entity Recognition Dataset
Authors Ding, Ning; Xu, Guangwei; Chen, Yulin; Wang, Xiaobin; Han, Xu; Xie, Pengjun; Zheng, Hai-Tao; Liu, Zhiyuan
Conference ACL-IJCNL 2021
""", unsafe_allow_html=True) # Benchmarking Results Description st.markdown('
Benchmarking Results
', unsafe_allow_html=True) st.markdown("""
Metric Score
Precision 89.45%
Recall 91.67%
F1-Score 90.55%
""", unsafe_allow_html=True) st.markdown("""

The benchmarking results highlight the performance of the nerdl_fewnerd_subentity_100d model. The metrics used are:

The scores indicate that the model achieves high accuracy and reliability in detecting entities within general scope texts.

""", unsafe_allow_html=True) # Conclusion st.markdown('
Conclusion
', unsafe_allow_html=True) st.markdown("""

The nerdl_fewnerd_subentity_100d model is a powerful tool for entity recognition in general texts, offering high accuracy across a diverse set of entities. Its robust performance, as demonstrated by the benchmark results, makes it suitable for various applications such as text analysis, content classification, and knowledge graph construction. By utilizing this model, users can effectively extract and categorize entities, enhancing their ability to analyze and understand textual data.

For more information and to access the model, visit the John Snow Labs Model Page or the Spark NLP GitHub Repository.

""", unsafe_allow_html=True) # References st.markdown('
References
', unsafe_allow_html=True) st.markdown("""
""", unsafe_allow_html=True) # Community & Support st.markdown('
Community & Support
', unsafe_allow_html=True) st.markdown("""
""", unsafe_allow_html=True)