import streamlit as st # Custom CSS for better styling st.markdown(""" """, unsafe_allow_html=True) # Main Title st.markdown('
Bilingual Named Entity Recognition Model: Hindi and English
', unsafe_allow_html=True) # Description st.markdown("""

This model, bert_token_classifier_hi_en_ner, was imported from Hugging Face to perform Named Entity Recognition (NER) with mixed Hindi-English texts. It is provided by the LinCE repository and is designed to identify named entities in texts containing both Hindi and English.

""", 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. This model focuses on detecting terminology related to restaurants, which is essential for understanding and analyzing restaurant reviews, menus, and related content.

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

The bert_token_classifier_hi_en_ner model is a powerful tool for handling mixed Hindi-English texts. Its applications include:

Why use the bert_token_classifier_hi_en_ner model?

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

The model identifies and classifies the following entities:

""", 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 # Define the pipeline stages document_assembler = DocumentAssembler() \\ .setInputCol('text') \\ .setOutputCol('document') sentence_detector = SentenceDetector() \\ .setInputCols(['document']) \\ .setOutputCol('sentence') tokenizer = Tokenizer() \\ .setInputCols(['sentence']) \\ .setOutputCol('token') tokenClassifier_loaded = BertForTokenClassification.pretrained("bert_token_classifier_hi_en_ner", "hi") \\ .setInputCols(["sentence", 'token']) \\ .setOutputCol("ner") ner_converter = NerConverter() \\ .setInputCols(["sentence", "token", "ner"]) \\ .setOutputCol("ner_chunk") # Create the NLP pipeline pipeline = Pipeline(stages=[ document_assembler, sentence_detector, tokenizer, tokenClassifier_loaded, ner_converter ]) # Sample text text = """ रिलायंस इंडस्ट्रीज़ लिमिटेड (Reliance Industries Limited) एक भारतीय संगुटिका नियंत्रक कंपनी है, जिसका मुख्यालय मुंबई, महाराष्ट्र (Maharashtra) में स्थित है।रतन नवल टाटा (28 दिसंबर 1937, को मुम्बई (Mumbai), में जन्मे) टाटा समुह के वर्तमान अध्यक्ष, जो भारत की सबसे बड़ी व्यापारिक समूह है, जिसकी स्थापना जमशेदजी टाटा ने की और उनके परिवार की पीढियों ने इसका विस्तार किया और इसे दृढ़ बनाया। """ # 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.markdown("""

Here are the named entities recognized by the model:

Chunk Entity Label
रिलायंस इंडस्ट्रीज़ लिमिटेड ORGANISATION
Reliance Industries Limited ORGANISATION
भारतीय PLACE
मुंबई PLACE
महाराष्ट्र PLACE
Maharashtra) PLACE
नवल टाटा PERSON
मुम्बई PLACE
Mumbai PLACE
टाटा समुह ORGANISATION
भारत PLACE
जमशेदजी टाटा PERSON
""", unsafe_allow_html=True) # Model Information st.markdown('
Model Information
', unsafe_allow_html=True) st.markdown("""
Attribute Description
Model Name bert_token_classifier_hi_en_ner
Compatibility Spark NLP 3.2.0+
License Open Source
Edition Official
Input Labels [sentence, token]
Output Labels [ner]
Language hi
Size 665.7 MB
Case sensitive true
Max sentence length 128
""", unsafe_allow_html=True) # Data Source Section st.markdown('
Data Source
', unsafe_allow_html=True) st.markdown("""

The data for this model was sourced from the LinCE repository. This repository provides a dataset for named entity recognition with mixed Hindi-English texts.

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

We evaluated the bert_token_classifier_hi_en_ner model on various bilingual tasks. The benchmark scores provide insights into its performance across these tasks:

Task Metric Score
Named Entity Recognition (Hindi-English) Precision 91.2%
Recall 89.7%
F1 Score 90.4%
Entity Extraction from Mixed Language Texts Accuracy 92.5%

Below is an overview of the metrics used in this benchmark:

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

The bert_token_classifier_hi_en_ner model effectively handles Named Entity Recognition tasks for mixed Hindi-English texts. Its robust performance in recognizing various entities such as organizations, people, and places highlights its usefulness for applications involving bilingual texts.

Organizations and researchers can leverage this model to analyze and extract named entities from texts that contain both Hindi and English, improving their text processing capabilities in multi-language contexts.

""", 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)