abdullahmubeen10 commited on
Commit
5e99ace
1 Parent(s): fe05f12

Update pages/Workflow & Model Overview.py

Browse files
Files changed (1) hide show
  1. pages/Workflow & Model Overview.py +167 -167
pages/Workflow & Model Overview.py CHANGED
@@ -1,167 +1,167 @@
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
- # Title
38
- st.markdown('<div class="main-title">Evaluate Sentence Grammar</div>', unsafe_allow_html=True)
39
-
40
- # Introduction Section
41
- st.markdown("""
42
- <div class="section">
43
- <p>Evaluating sentence grammar is crucial for maintaining the clarity and accuracy of written communication. Whether you're reviewing content for publication, editing academic work, or checking everyday writing, ensuring grammatical correctness is key.</p>
44
- <p>This page showcases the implementation of a grammar evaluation pipeline using advanced NLP models. We leverage the T5 Transformer model, fine-tuned for assessing sentence grammar, to evaluate and identify potential errors in sentences.</p>
45
- </div>
46
- """, unsafe_allow_html=True)
47
-
48
- # T5 Transformer Overview
49
- st.markdown('<div class="sub-title">Understanding the T5 Transformer for Grammar Evaluation</div>', unsafe_allow_html=True)
50
-
51
- st.markdown("""
52
- <div class="section">
53
- <p>The T5 (Text-To-Text Transfer Transformer) model, developed by Google, is a powerful tool for various NLP tasks, including grammar evaluation. When configured with the appropriate task, T5 can assess sentences for grammatical correctness, helping users identify and correct errors.</p>
54
- <p>This capability is particularly useful in proofreading tools, automated editing software, and educational applications, where precise grammar is essential.</p>
55
- </div>
56
- """, unsafe_allow_html=True)
57
-
58
- # Performance Section
59
- st.markdown('<div class="sub-title">Performance and Use Cases</div>', unsafe_allow_html=True)
60
-
61
- st.markdown("""
62
- <div class="section">
63
- <p>The T5 model exhibits strong performance in grammar evaluation tasks, providing accurate and contextually relevant assessments. This makes it a valuable resource for anyone looking to improve the quality of written content.</p>
64
- <p>Use cases include academic proofreading, professional editing, and everyday writing checks, where maintaining grammatical integrity is of utmost importance.</p>
65
- </div>
66
- """, unsafe_allow_html=True)
67
-
68
- # Implementation Section
69
- st.markdown('<div class="sub-title">Implementing Grammar Evaluation</div>', unsafe_allow_html=True)
70
-
71
- st.markdown("""
72
- <div class="section">
73
- <p>The following example demonstrates how to implement a grammar evaluation pipeline using Spark NLP. The pipeline includes a document assembler and the T5 model configured for evaluating sentence grammar.</p>
74
- </div>
75
- """, unsafe_allow_html=True)
76
-
77
- st.code('''
78
- import sparknlp
79
- from sparknlp.base import *
80
- from sparknlp.annotator import *
81
- from pyspark.ml import Pipeline
82
-
83
- # Initialize Spark NLP
84
- spark = sparknlp.start()
85
-
86
- # Define the pipeline stages
87
- documentAssembler = DocumentAssembler() \\
88
- .setInputCol("text") \\
89
- .setOutputCol("documents")
90
-
91
- t5 = T5Transformer.pretrained('t5_base') \\
92
- .setTask("cola:") \\
93
- .setInputCols(["documents"])\\
94
- .setMaxOutputLength(200)\\
95
- .setOutputCol("prediction")
96
-
97
- pipeline = Pipeline().setStages([documentAssembler, t5])
98
-
99
- # Input data example
100
- data = spark.createDataFrame([["She don't knows nothing about what's happening in the office."]]).toDF("text")
101
-
102
- # Apply the pipeline for grammar evaluation
103
- result = pipeline.fit(data).transform(data)
104
- result.select("prediction.result").show(truncate=False)
105
- ''', language='python')
106
-
107
- # Example Output
108
- st.text("""
109
- +--------------------+
110
- |corrections.result |
111
- +--------------------+
112
- |unacceptable |
113
- +--------------------+
114
- """)
115
-
116
- # Model Info Section
117
- st.markdown('<div class="sub-title">Choosing the Right T5 Model for Grammar Evaluation</div>', unsafe_allow_html=True)
118
-
119
- st.markdown("""
120
- <div class="section">
121
- <p>For evaluating sentence grammar, we use the model: "t5_grammar_error_corrector" with the task set to "cola:". This model is specifically tuned to assess grammatical correctness in English sentences.</p>
122
- <p>Explore other T5 models tailored for different NLP tasks on the <a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Models Hub</a> to find the best fit for your specific needs.</p>
123
- </div>
124
- """, unsafe_allow_html=True)
125
-
126
- # References Section
127
- st.markdown('<div class="sub-title">References</div>', unsafe_allow_html=True)
128
-
129
- st.markdown("""
130
- <div class="section">
131
- <ul>
132
- <li><a class="link" href="https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html" target="_blank">Google AI Blog</a>: Exploring Transfer Learning with T5</li>
133
- <li><a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Model Hub</a>: Explore T5 models</li>
134
- <li><a class="link" href="https://github.com/google-research/text-to-text-transfer-transformer" target="_blank">GitHub</a>: T5 Transformer repository</li>
135
- <li><a class="link" href="https://arxiv.org/abs/1910.10683" target="_blank">T5 Paper</a>: Detailed insights from the developers</li>
136
- </ul>
137
- </div>
138
- """, unsafe_allow_html=True)
139
-
140
- # Community & Support Section
141
- st.markdown('<div class="sub-title">Community & Support</div>', unsafe_allow_html=True)
142
-
143
- st.markdown("""
144
- <div class="section">
145
- <ul>
146
- <li><a class="link" href="https://sparknlp.org/" target="_blank">Official Website</a>: Documentation and examples</li>
147
- <li><a class="link" href="https://join.slack.com/t/spark-nlp/shared_invite/zt-198dipu77-L3UWNe_AJ8xqDk0ivmih5Q" target="_blank">Slack</a>: Live discussion with the community and team</li>
148
- <li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp" target="_blank">GitHub</a>: Bug reports, feature requests, and contributions</li>
149
- <li><a class="link" href="https://medium.com/spark-nlp" target="_blank">Medium</a>: Spark NLP articles</li>
150
- <li><a class="link" href="https://www.youtube.com/channel/UCmFOjlpYEhxf_wJUDuz6xxQ/videos" target="_blank">YouTube</a>: Video tutorials</li>
151
- </ul>
152
- </div>
153
- """, unsafe_allow_html=True)
154
-
155
- # Quick Links Section
156
- st.markdown('<div class="sub-title">Quick Links</div>', unsafe_allow_html=True)
157
-
158
- st.markdown("""
159
- <div class="section">
160
- <ul>
161
- <li><a class="link" href="https://sparknlp.org/docs/en/quickstart" target="_blank">Getting Started</a></li>
162
- <li><a class="link" href="https://nlp.johnsnowlabs.com/models" target="_blank">Pretrained Models</a></li>
163
- <li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples/python/annotation/text/english" target="_blank">Example Notebooks</a></li>
164
- <li><a class="link" href="https://sparknlp.org/docs/en/install" target="_blank">Installation Guide</a></li>
165
- </ul>
166
- </div>
167
- """, unsafe_allow_html=True)
 
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
+ # Title
38
+ st.markdown('<div class="main-title">Evaluate Sentence Grammar</div>', unsafe_allow_html=True)
39
+
40
+ # Introduction Section
41
+ st.markdown("""
42
+ <div class="section">
43
+ <p>Evaluating sentence grammar is crucial for maintaining the clarity and accuracy of written communication. Whether you're reviewing content for publication, editing academic work, or checking everyday writing, ensuring grammatical correctness is key.</p>
44
+ <p>This page showcases the implementation of a grammar evaluation pipeline using advanced NLP models. We leverage the T5 Transformer model, fine-tuned for assessing sentence grammar, to evaluate and identify potential errors in sentences.</p>
45
+ </div>
46
+ """, unsafe_allow_html=True)
47
+
48
+ # T5 Transformer Overview
49
+ st.markdown('<div class="sub-title">Understanding the T5 Transformer for Grammar Evaluation</div>', unsafe_allow_html=True)
50
+
51
+ st.markdown("""
52
+ <div class="section">
53
+ <p>The T5 (Text-To-Text Transfer Transformer) model, developed by Google, is a powerful tool for various NLP tasks, including grammar evaluation. When configured with the appropriate task, T5 can assess sentences for grammatical correctness, helping users identify and correct errors.</p>
54
+ <p>This capability is particularly useful in proofreading tools, automated editing software, and educational applications, where precise grammar is essential.</p>
55
+ </div>
56
+ """, unsafe_allow_html=True)
57
+
58
+ # Performance Section
59
+ st.markdown('<div class="sub-title">Performance and Use Cases</div>', unsafe_allow_html=True)
60
+
61
+ st.markdown("""
62
+ <div class="section">
63
+ <p>The T5 model exhibits strong performance in grammar evaluation tasks, providing accurate and contextually relevant assessments. This makes it a valuable resource for anyone looking to improve the quality of written content.</p>
64
+ <p>Use cases include academic proofreading, professional editing, and everyday writing checks, where maintaining grammatical integrity is of utmost importance.</p>
65
+ </div>
66
+ """, unsafe_allow_html=True)
67
+
68
+ # Implementation Section
69
+ st.markdown('<div class="sub-title">Implementing Grammar Evaluation</div>', unsafe_allow_html=True)
70
+
71
+ st.markdown("""
72
+ <div class="section">
73
+ <p>The following example demonstrates how to implement a grammar evaluation pipeline using Spark NLP. The pipeline includes a document assembler and the T5 model configured for evaluating sentence grammar.</p>
74
+ </div>
75
+ """, unsafe_allow_html=True)
76
+
77
+ st.code('''
78
+ import sparknlp
79
+ from sparknlp.base import *
80
+ from sparknlp.annotator import *
81
+ from pyspark.ml import Pipeline
82
+
83
+ # Initialize Spark NLP
84
+ spark = sparknlp.start()
85
+
86
+ # Define the pipeline stages
87
+ documentAssembler = DocumentAssembler() \\
88
+ .setInputCol("text") \\
89
+ .setOutputCol("documents")
90
+
91
+ t5 = T5Transformer.pretrained('t5_base') \\
92
+ .setTask("cola:") \\
93
+ .setInputCols(["documents"])\\
94
+ .setMaxOutputLength(200)\\
95
+ .setOutputCol("prediction")
96
+
97
+ pipeline = Pipeline().setStages([documentAssembler, t5])
98
+
99
+ # Input data example
100
+ data = spark.createDataFrame([["She don't knows nothing about what's happening in the office."]]).toDF("text")
101
+
102
+ # Apply the pipeline for grammar evaluation
103
+ result = pipeline.fit(data).transform(data)
104
+ result.select("prediction.result").show(truncate=False)
105
+ ''', language='python')
106
+
107
+ # Example Output
108
+ st.text("""
109
+ +--------------------+
110
+ |corrections.result |
111
+ +--------------------+
112
+ |unacceptable |
113
+ +--------------------+
114
+ """)
115
+
116
+ # Model Info Section
117
+ st.markdown('<div class="sub-title">Choosing the Right T5 Model for Grammar Evaluation</div>', unsafe_allow_html=True)
118
+
119
+ st.markdown("""
120
+ <div class="section">
121
+ <p>For evaluating sentence grammar, we use the model: "t5_base" with the task set to "cola:". This model is specifically tuned to assess grammatical correctness in English sentences.</p>
122
+ <p>Explore other T5 models tailored for different NLP tasks on the <a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Models Hub</a> to find the best fit for your specific needs.</p>
123
+ </div>
124
+ """, unsafe_allow_html=True)
125
+
126
+ # References Section
127
+ st.markdown('<div class="sub-title">References</div>', unsafe_allow_html=True)
128
+
129
+ st.markdown("""
130
+ <div class="section">
131
+ <ul>
132
+ <li><a class="link" href="https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html" target="_blank">Google AI Blog</a>: Exploring Transfer Learning with T5</li>
133
+ <li><a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Model Hub</a>: Explore T5 models</li>
134
+ <li><a class="link" href="https://github.com/google-research/text-to-text-transfer-transformer" target="_blank">GitHub</a>: T5 Transformer repository</li>
135
+ <li><a class="link" href="https://arxiv.org/abs/1910.10683" target="_blank">T5 Paper</a>: Detailed insights from the developers</li>
136
+ </ul>
137
+ </div>
138
+ """, unsafe_allow_html=True)
139
+
140
+ # Community & Support Section
141
+ st.markdown('<div class="sub-title">Community & Support</div>', unsafe_allow_html=True)
142
+
143
+ st.markdown("""
144
+ <div class="section">
145
+ <ul>
146
+ <li><a class="link" href="https://sparknlp.org/" target="_blank">Official Website</a>: Documentation and examples</li>
147
+ <li><a class="link" href="https://join.slack.com/t/spark-nlp/shared_invite/zt-198dipu77-L3UWNe_AJ8xqDk0ivmih5Q" target="_blank">Slack</a>: Live discussion with the community and team</li>
148
+ <li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp" target="_blank">GitHub</a>: Bug reports, feature requests, and contributions</li>
149
+ <li><a class="link" href="https://medium.com/spark-nlp" target="_blank">Medium</a>: Spark NLP articles</li>
150
+ <li><a class="link" href="https://www.youtube.com/channel/UCmFOjlpYEhxf_wJUDuz6xxQ/videos" target="_blank">YouTube</a>: Video tutorials</li>
151
+ </ul>
152
+ </div>
153
+ """, unsafe_allow_html=True)
154
+
155
+ # Quick Links Section
156
+ st.markdown('<div class="sub-title">Quick Links</div>', unsafe_allow_html=True)
157
+
158
+ st.markdown("""
159
+ <div class="section">
160
+ <ul>
161
+ <li><a class="link" href="https://sparknlp.org/docs/en/quickstart" target="_blank">Getting Started</a></li>
162
+ <li><a class="link" href="https://nlp.johnsnowlabs.com/models" target="_blank">Pretrained Models</a></li>
163
+ <li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples/python/annotation/text/english" target="_blank">Example Notebooks</a></li>
164
+ <li><a class="link" href="https://sparknlp.org/docs/en/install" target="_blank">Installation Guide</a></li>
165
+ </ul>
166
+ </div>
167
+ """, unsafe_allow_html=True)