abdullahmubeen10
commited on
Upload 5 files
Browse files- .streamlit/config.toml +3 -0
- Demo.py +129 -0
- Dockerfile +72 -0
- pages/Workflow & Model Overview.py +180 -0
- requirements.txt +7 -0
.streamlit/config.toml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="light"
|
3 |
+
primaryColor="#29B4E8"
|
Demo.py
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import sparknlp
|
3 |
+
|
4 |
+
from sparknlp.base import *
|
5 |
+
from sparknlp.annotator import *
|
6 |
+
from pyspark.ml import Pipeline
|
7 |
+
|
8 |
+
# Page configuration
|
9 |
+
st.set_page_config(
|
10 |
+
layout="wide",
|
11 |
+
initial_sidebar_state="auto"
|
12 |
+
)
|
13 |
+
|
14 |
+
# CSS for styling
|
15 |
+
st.markdown("""
|
16 |
+
<style>
|
17 |
+
.main-title {
|
18 |
+
font-size: 36px;
|
19 |
+
color: #4A90E2;
|
20 |
+
font-weight: bold;
|
21 |
+
text-align: center;
|
22 |
+
}
|
23 |
+
.section {
|
24 |
+
background-color: #f9f9f9;
|
25 |
+
padding: 10px;
|
26 |
+
border-radius: 10px;
|
27 |
+
margin-top: 10px;
|
28 |
+
}
|
29 |
+
.section p, .section ul {
|
30 |
+
color: #666666;
|
31 |
+
}
|
32 |
+
</style>
|
33 |
+
""", unsafe_allow_html=True)
|
34 |
+
|
35 |
+
@st.cache_resource
|
36 |
+
def init_spark():
|
37 |
+
return sparknlp.start()
|
38 |
+
|
39 |
+
@st.cache_resource
|
40 |
+
def create_pipeline(model):
|
41 |
+
document_assembler = DocumentAssembler() \
|
42 |
+
.setInputCol("text") \
|
43 |
+
.setOutputCol("documents")
|
44 |
+
|
45 |
+
t5 = T5Transformer() \
|
46 |
+
.pretrained(model) \
|
47 |
+
.setTask("question:")\
|
48 |
+
.setMaxOutputLength(200)\
|
49 |
+
.setInputCols(["documents"]) \
|
50 |
+
.setOutputCol("answers")
|
51 |
+
|
52 |
+
pipeline = Pipeline(stages=[document_assembler, t5])
|
53 |
+
return pipeline
|
54 |
+
|
55 |
+
def fit_data(pipeline, data):
|
56 |
+
df = spark.createDataFrame([[data]]).toDF("text")
|
57 |
+
result = pipeline.fit(df).transform(df)
|
58 |
+
return result.select('answers.result').collect()
|
59 |
+
|
60 |
+
# Sidebar content
|
61 |
+
model = st.sidebar.selectbox(
|
62 |
+
"Choose the pretrained model",
|
63 |
+
['t5_base', 't5_small'],
|
64 |
+
help="For more info about the models visit: https://sparknlp.org/models"
|
65 |
+
)
|
66 |
+
|
67 |
+
# Set up the page layout
|
68 |
+
title, sub_title = (
|
69 |
+
'Automatically Answer Questions (OPEN BOOK)',
|
70 |
+
'Automatically generate answers to questions without context.'
|
71 |
+
)
|
72 |
+
|
73 |
+
st.markdown(f'<div class="main-title">{title}</div>', unsafe_allow_html=True)
|
74 |
+
st.write(sub_title)
|
75 |
+
# Reference notebook link in sidebar
|
76 |
+
link = """
|
77 |
+
<a href="https://colab.research.google.com/github/JohnSnowLabs/spark-nlp-workshop/blob/master/tutorials/streamlit_notebooks/public/QUESTION_ANSWERING_OPEN_BOOK.ipynb#scrollTo=SunNYkw3-Ic8">
|
78 |
+
<img src="https://colab.research.google.com/assets/colab-badge.svg" style="zoom: 1.3" alt="Open In Colab"/>
|
79 |
+
</a>
|
80 |
+
"""
|
81 |
+
st.sidebar.markdown('Reference notebook:')
|
82 |
+
st.sidebar.markdown(link, unsafe_allow_html=True)
|
83 |
+
|
84 |
+
# Define the examples as a dictionary for easier access
|
85 |
+
examples = {
|
86 |
+
"What does increased oxygen concentrations in the patient’s lungs displace?": """Hyperbaric (high-pressure) medicine uses special oxygen chambers to increase the partial pressure of O 2 around the patient and, when needed, the medical staff. Carbon monoxide poisoning, gas gangrene, and decompression sickness (the ’bends’) are sometimes treated using these devices. Increased O 2 concentration in the lungs helps to displace carbon monoxide from the heme group of hemoglobin. Oxygen gas is poisonous to the anaerobic bacteria that cause gas gangrene, so increasing its partial pressure helps kill them. Decompression sickness occurs in divers who decompress too quickly after a dive, resulting in bubbles of inert gas, mostly nitrogen and helium, forming in their blood. Increasing the pressure of O 2 as soon as possible is part of the treatment.""",
|
87 |
+
"What category of game is Legend of Zelda: Twilight Princess?": """The Legend of Zelda: Twilight Princess (Japanese: ゼルダの伝説 トワイライトプリンセス, Hepburn: Zeruda no Densetsu: Towairaito Purinsesu?) is an action-adventure game developed and published by Nintendo for the GameCube and Wii home video game consoles. It is the thirteenth installment in the The Legend of Zelda series. Originally planned for release on the GameCube in November 2005, Twilight Princess was delayed by Nintendo to allow its developers to refine the game, add more content, and port it to the Wii. The Wii version was released alongside the console in North America in November 2006, and in Japan, Europe, and Australia the following month. The GameCube version was released worldwide in December 2006.""",
|
88 |
+
"Who is founder of Alibaba Group?": """Alibaba Group founder Jack Ma has made his first appearance since Chinese regulators cracked down on his business empire. His absence had fuelled speculation over his whereabouts amid increasing official scrutiny of his businesses. The billionaire met 100 rural teachers in China via a video meeting on Wednesday, according to local government media. Alibaba shares surged 5% on Hong Kong's stock exchange on the news.""",
|
89 |
+
"For what instrument did Frédéric write primarily for?": """Frédéric François Chopin (/ˈʃoʊpæn/; French pronunciation: [fʁe.de.ʁik fʁɑ̃.swa ʃɔ.pɛ̃]; 22 February or 1 March 1810 – 17 October 1849), born Fryderyk Franciszek Chopin,[n 1] was a Polish and French (by citizenship and birth of father) composer and a virtuoso pianist of the Romantic era, who wrote primarily for the solo piano. He gained and has maintained renown worldwide as one of the leading musicians of his era, whose "poetic genius was based on a professional technique that was without equal in his generation." Chopin was born in what was then the Duchy of Warsaw, and grew up in Warsaw, which after 1815 became part of Congress Poland. A child prodigy, he completed his musical education and composed his earlier works in Warsaw before leaving Poland at the age of 20, less than a month before the outbreak of the November 1830 Uprising.""",
|
90 |
+
"The most populated city in the United States is which city?": """New York—often called New York City or the City of New York to distinguish it from the State of New York, of which it is a part—is the most populous city in the United States and the center of the New York metropolitan area, the premier gateway for legal immigration to the United States and one of the most populous urban agglomerations in the world. A global power city, New York exerts a significant impact upon commerce, finance, media, art, fashion, research, technology, education, and entertainment, its fast pace defining the term New York minute. Home to the headquarters of the United Nations, New York is an important center for international diplomacy and has been described as the cultural and financial capital of the world."""
|
91 |
+
}
|
92 |
+
|
93 |
+
# Create a select box for predefined examples
|
94 |
+
selected_text = st.selectbox('Select an Example:', list(examples.keys()))
|
95 |
+
|
96 |
+
# Add input fields for custom question and context
|
97 |
+
st.write('Try it yourself!')
|
98 |
+
custom_input_question = st.text_input('Create a question')
|
99 |
+
custom_input_context = st.text_input("Create its context")
|
100 |
+
|
101 |
+
# Check if custom input is provided
|
102 |
+
if custom_input_question and custom_input_context:
|
103 |
+
custom_example = {custom_input_question: custom_input_context}
|
104 |
+
selected_example_key = custom_input_question
|
105 |
+
selected_example_context = custom_input_context
|
106 |
+
else:
|
107 |
+
# Fallback to the selected example from dropdown
|
108 |
+
selected_example_key = selected_text
|
109 |
+
selected_example_context = examples[selected_text]
|
110 |
+
|
111 |
+
# Prepare the final selected_text
|
112 |
+
selected_text = f'"""{selected_example_key}""" """context : {selected_example_context}"""'
|
113 |
+
|
114 |
+
st.markdown('---')
|
115 |
+
# Display the selected or custom example
|
116 |
+
st.markdown(f"**Text:** {selected_example_key}")
|
117 |
+
st.markdown(f"**Context:** {selected_example_context}")
|
118 |
+
|
119 |
+
|
120 |
+
# Initialize Spark and create pipeline
|
121 |
+
spark = init_spark()
|
122 |
+
pipeline = create_pipeline(model)
|
123 |
+
output = fit_data(pipeline, selected_text)
|
124 |
+
|
125 |
+
# Display matched sentence
|
126 |
+
output_text = "".join(output[0][0])
|
127 |
+
st.markdown('---')
|
128 |
+
st.markdown(f"Answer: **{output_text.title()}**")
|
129 |
+
|
Dockerfile
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Download base image ubuntu 18.04
|
2 |
+
FROM ubuntu:18.04
|
3 |
+
|
4 |
+
# Set environment variables
|
5 |
+
ENV NB_USER jovyan
|
6 |
+
ENV NB_UID 1000
|
7 |
+
ENV HOME /home/${NB_USER}
|
8 |
+
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
|
9 |
+
|
10 |
+
# Install required packages
|
11 |
+
RUN apt-get update && apt-get install -y \
|
12 |
+
tar \
|
13 |
+
wget \
|
14 |
+
bash \
|
15 |
+
rsync \
|
16 |
+
gcc \
|
17 |
+
libfreetype6-dev \
|
18 |
+
libhdf5-serial-dev \
|
19 |
+
libpng-dev \
|
20 |
+
libzmq3-dev \
|
21 |
+
python3 \
|
22 |
+
python3-dev \
|
23 |
+
python3-pip \
|
24 |
+
unzip \
|
25 |
+
pkg-config \
|
26 |
+
software-properties-common \
|
27 |
+
graphviz \
|
28 |
+
openjdk-8-jdk \
|
29 |
+
ant \
|
30 |
+
ca-certificates-java \
|
31 |
+
&& apt-get clean \
|
32 |
+
&& update-ca-certificates -f
|
33 |
+
|
34 |
+
# Install Python 3.8 and pip
|
35 |
+
RUN add-apt-repository ppa:deadsnakes/ppa \
|
36 |
+
&& apt-get update \
|
37 |
+
&& apt-get install -y python3.8 python3-pip \
|
38 |
+
&& apt-get clean
|
39 |
+
|
40 |
+
# Set up JAVA_HOME
|
41 |
+
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" >> /etc/profile \
|
42 |
+
&& echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile
|
43 |
+
# Create a new user named "jovyan" with user ID 1000
|
44 |
+
RUN useradd -m -u ${NB_UID} ${NB_USER}
|
45 |
+
|
46 |
+
# Switch to the "jovyan" user
|
47 |
+
USER ${NB_USER}
|
48 |
+
|
49 |
+
# Set home and path variables for the user
|
50 |
+
ENV HOME=/home/${NB_USER} \
|
51 |
+
PATH=/home/${NB_USER}/.local/bin:$PATH
|
52 |
+
|
53 |
+
# Set up PySpark to use Python 3.8 for both driver and workers
|
54 |
+
ENV PYSPARK_PYTHON=/usr/bin/python3.8
|
55 |
+
ENV PYSPARK_DRIVER_PYTHON=/usr/bin/python3.8
|
56 |
+
|
57 |
+
# Set the working directory to the user's home directory
|
58 |
+
WORKDIR ${HOME}
|
59 |
+
|
60 |
+
# Upgrade pip and install Python dependencies
|
61 |
+
RUN python3.8 -m pip install --upgrade pip
|
62 |
+
COPY requirements.txt /tmp/requirements.txt
|
63 |
+
RUN python3.8 -m pip install -r /tmp/requirements.txt
|
64 |
+
|
65 |
+
# Copy the application code into the container at /home/jovyan
|
66 |
+
COPY --chown=${NB_USER}:${NB_USER} . ${HOME}
|
67 |
+
|
68 |
+
# Expose port for Streamlit
|
69 |
+
EXPOSE 7860
|
70 |
+
|
71 |
+
# Define the entry point for the container
|
72 |
+
ENTRYPOINT ["streamlit", "run", "Demo.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
pages/Workflow & Model Overview.py
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Page configuration
|
4 |
+
st.set_page_config(
|
5 |
+
layout="wide",
|
6 |
+
initial_sidebar_state="auto"
|
7 |
+
)
|
8 |
+
|
9 |
+
# Custom CSS for better styling
|
10 |
+
st.markdown("""
|
11 |
+
<style>
|
12 |
+
.main-title {
|
13 |
+
font-size: 36px;
|
14 |
+
color: #4A90E2;
|
15 |
+
font-weight: bold;
|
16 |
+
text-align: center;
|
17 |
+
}
|
18 |
+
.sub-title {
|
19 |
+
font-size: 24px;
|
20 |
+
color: #4A90E2;
|
21 |
+
margin-top: 20px;
|
22 |
+
}
|
23 |
+
.section {
|
24 |
+
background-color: #f9f9f9;
|
25 |
+
padding: 15px;
|
26 |
+
border-radius: 10px;
|
27 |
+
margin-top: 20px;
|
28 |
+
}
|
29 |
+
.section h2 {
|
30 |
+
font-size: 22px;
|
31 |
+
color: #4A90E2;
|
32 |
+
}
|
33 |
+
.section p, .section ul {
|
34 |
+
color: #666666;
|
35 |
+
}
|
36 |
+
.link {
|
37 |
+
color: #4A90E2;
|
38 |
+
text-decoration: none;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
""", unsafe_allow_html=True)
|
42 |
+
|
43 |
+
# Title
|
44 |
+
st.markdown('<div class="main-title">Automatically Answer Questions (OPEN BOOK)</div>', unsafe_allow_html=True)
|
45 |
+
|
46 |
+
# Introduction Section
|
47 |
+
st.markdown("""
|
48 |
+
<div class="section">
|
49 |
+
<p>Open-book question answering is a task where a model generates answers based on provided text or documents. Unlike closed-book models, open-book models utilize external sources to produce responses, making them more accurate and versatile in scenarios where the input text provides essential context.</p>
|
50 |
+
<p>This page explores how to implement an open-book question-answering pipeline using state-of-the-art NLP techniques. We use a T5 Transformer model, which is well-suited for generating detailed answers by leveraging the information contained within the input text.</p>
|
51 |
+
</div>
|
52 |
+
""", unsafe_allow_html=True)
|
53 |
+
|
54 |
+
# T5 Transformer Overview
|
55 |
+
st.markdown('<div class="sub-title">Understanding the T5 Transformer for Open-Book QA</div>', unsafe_allow_html=True)
|
56 |
+
|
57 |
+
st.markdown("""
|
58 |
+
<div class="section">
|
59 |
+
<p>The T5 (Text-To-Text Transfer Transformer) model by Google excels in converting various NLP tasks into a unified text-to-text format. For open-book question answering, the model takes a question and relevant context as input, generating a detailed and contextually appropriate answer.</p>
|
60 |
+
<p>The T5 model's ability to utilize provided documents makes it especially powerful in applications where the accuracy of the response is enhanced by access to supporting information, such as research tools, educational applications, or any system where the input text contains critical data.</p>
|
61 |
+
</div>
|
62 |
+
""", unsafe_allow_html=True)
|
63 |
+
|
64 |
+
# Performance Section
|
65 |
+
st.markdown('<div class="sub-title">Performance and Benchmarks</div>', unsafe_allow_html=True)
|
66 |
+
|
67 |
+
st.markdown("""
|
68 |
+
<div class="section">
|
69 |
+
<p>In open-book settings, the T5 model has been benchmarked across various datasets, demonstrating its capability to generate accurate and comprehensive answers when given relevant context. Its performance has been particularly strong in tasks requiring a deep understanding of the input text to produce correct and context-aware responses.</p>
|
70 |
+
<p>Open-book T5 models are especially valuable in applications that require dynamic interaction with content, making them ideal for domains such as customer support, research, and educational technologies.</p>
|
71 |
+
</div>
|
72 |
+
""", unsafe_allow_html=True)
|
73 |
+
|
74 |
+
# Implementation Section
|
75 |
+
st.markdown('<div class="sub-title">Implementing Open-Book Question Answering</div>', unsafe_allow_html=True)
|
76 |
+
|
77 |
+
st.markdown("""
|
78 |
+
<div class="section">
|
79 |
+
<p>The following example demonstrates how to implement an open-book question answering pipeline using Spark NLP. The pipeline includes a document assembler and the T5 model to generate answers based on the input text.</p>
|
80 |
+
</div>
|
81 |
+
""", unsafe_allow_html=True)
|
82 |
+
|
83 |
+
st.code('''
|
84 |
+
from sparknlp.base import *
|
85 |
+
from sparknlp.annotator import *
|
86 |
+
from pyspark.ml import Pipeline
|
87 |
+
from pyspark.sql.functions import col, expr
|
88 |
+
|
89 |
+
document_assembler = DocumentAssembler()\\
|
90 |
+
.setInputCol("text")\\
|
91 |
+
.setOutputCol("documents")
|
92 |
+
|
93 |
+
t5 = T5Transformer()\\
|
94 |
+
.pretrained(model_name)\\
|
95 |
+
.setTask("question:")\\
|
96 |
+
.setMaxOutputLength(200)\\
|
97 |
+
.setInputCols(["documents"])\\
|
98 |
+
.setOutputCol("answers")
|
99 |
+
|
100 |
+
pipeline = Pipeline().setStages([document_assembler, t5])
|
101 |
+
|
102 |
+
data = spark.createDataFrame([["What is the impact of climate change on polar bears?"]]).toDF("text")
|
103 |
+
result = pipeline.fit(data).transform(data)
|
104 |
+
result.select("answers.result").show(truncate=False)
|
105 |
+
''', language='python')
|
106 |
+
|
107 |
+
# Example Output
|
108 |
+
st.text("""
|
109 |
+
+------------------------------------------------+
|
110 |
+
|answers.result |
|
111 |
+
+------------------------------------------------+
|
112 |
+
|Climate change significantly affects polar ... |
|
113 |
+
+------------------------------------------------+
|
114 |
+
""")
|
115 |
+
|
116 |
+
# Model Info Section
|
117 |
+
st.markdown('<div class="sub-title">Choosing the Right Model for Open-Book QA</div>', unsafe_allow_html=True)
|
118 |
+
|
119 |
+
st.markdown("""
|
120 |
+
<div class="section">
|
121 |
+
<p>When selecting a model for open-book question answering, it's important to consider the specific needs of your application. Below are some of the available models, each offering different strengths based on their transformer architecture:</p>
|
122 |
+
<ul>
|
123 |
+
<li><b>t5_base</b>: A versatile model that provides strong performance on question-answering tasks, ideal for applications requiring detailed answers.</li>
|
124 |
+
<li><b>t5_small</b>: A more lightweight variant of T5, suitable for applications where resource efficiency is crucial, though it may not be as accurate as larger models.</li>
|
125 |
+
<li><b>albert_qa_xxlarge_tweetqa</b>: Based on the ALBERT architecture, this model is fine-tuned for the TweetQA dataset, making it effective for answering questions in shorter text formats.</li>
|
126 |
+
<li><b>bert_qa_callmenicky_finetuned_squad</b>: A fine-tuned BERT model that offers a good balance between accuracy and computational efficiency, suitable for general-purpose QA tasks.</li>
|
127 |
+
<li><b>deberta_v3_xsmall_qa_squad2</b>: A smaller DeBERTa model, optimized for high accuracy on SQuAD2 while being resource-efficient, making it great for smaller deployments.</li>
|
128 |
+
<li><b>distilbert_base_cased_qa_squad2</b>: A distilled version of BERT, offering faster inference times with slightly reduced accuracy, suitable for environments with limited resources.</li>
|
129 |
+
<li><b>longformer_qa_large_4096_finetuned_triviaqa</b>: This model is particularly well-suited for open-book QA tasks involving long documents, as it can handle extended contexts effectively.</li>
|
130 |
+
<li><b>roberta_qa_roberta_base_squad2_covid</b>: A RoBERTa-based model fine-tuned for COVID-related QA, making it highly specialized for health-related domains.</li>
|
131 |
+
<li><b>roberta_qa_CV_Merge_DS</b>: Another RoBERTa model, fine-tuned on a diverse dataset, offering versatility across different domains and question types.</li>
|
132 |
+
<li><b>xlm_roberta_base_qa_squad2</b>: A multilingual model fine-tuned on SQuAD2, ideal for QA tasks across various languages.</li>
|
133 |
+
</ul>
|
134 |
+
<p>Among these models, <b>t5_base</b> and <b>longformer_qa_large_4096_finetuned_triviaqa</b> are highly recommended for their strong performance in generating accurate and contextually rich answers, especially in scenarios with long input texts. For faster responses with an emphasis on efficiency, <b>distilbert_base_cased_qa_squad2</b> and <b>deberta_v3_xsmall_qa_squad2</b> are excellent choices. Specialized tasks may benefit from models like <b>albert_qa_xxlarge_tweetqa</b> or <b>roberta_qa_roberta_base_squad2_covid</b>, depending on the domain.</p>
|
135 |
+
<p>Explore the available models on the <a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Models Hub</a> to find the one that best suits your needs.</p>
|
136 |
+
</div>
|
137 |
+
""", unsafe_allow_html=True)
|
138 |
+
|
139 |
+
|
140 |
+
# Footer
|
141 |
+
# References Section
|
142 |
+
st.markdown('<div class="sub-title">References</div>', unsafe_allow_html=True)
|
143 |
+
|
144 |
+
st.markdown("""
|
145 |
+
<div class="section">
|
146 |
+
<ul>
|
147 |
+
<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>
|
148 |
+
<li><a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Model Hub</a>: Explore T5 models</li>
|
149 |
+
<li><a class="link" href="https://github.com/google-research/text-to-text-transfer-transformer" target="_blank">GitHub</a>: T5 Transformer repository</li>
|
150 |
+
<li><a class="link" href="https://arxiv.org/abs/1910.10683" target="_blank">T5 Paper</a>: Detailed insights from the developers</li>
|
151 |
+
</ul>
|
152 |
+
</div>
|
153 |
+
""", unsafe_allow_html=True)
|
154 |
+
|
155 |
+
st.markdown('<div class="sub-title">Community & Support</div>', unsafe_allow_html=True)
|
156 |
+
|
157 |
+
st.markdown("""
|
158 |
+
<div class="section">
|
159 |
+
<ul>
|
160 |
+
<li><a class="link" href="https://sparknlp.org/" target="_blank">Official Website</a>: Documentation and examples</li>
|
161 |
+
<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>
|
162 |
+
<li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp" target="_blank">GitHub</a>: Bug reports, feature requests, and contributions</li>
|
163 |
+
<li><a class="link" href="https://medium.com/spark-nlp" target="_blank">Medium</a>: Spark NLP articles</li>
|
164 |
+
<li><a class="link" href="https://www.youtube.com/channel/UCmFOjlpYEhxf_wJUDuz6xxQ/videos" target="_blank">YouTube</a>: Video tutorials</li>
|
165 |
+
</ul>
|
166 |
+
</div>
|
167 |
+
""", unsafe_allow_html=True)
|
168 |
+
|
169 |
+
st.markdown('<div class="sub-title">Quick Links</div>', unsafe_allow_html=True)
|
170 |
+
|
171 |
+
st.markdown("""
|
172 |
+
<div class="section">
|
173 |
+
<ul>
|
174 |
+
<li><a class="link" href="https://sparknlp.org/docs/en/quickstart" target="_blank">Getting Started</a></li>
|
175 |
+
<li><a class="link" href="https://nlp.johnsnowlabs.com/models" target="_blank">Pretrained Models</a></li>
|
176 |
+
<li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples/python/annotation/text/english" target="_blank">Example Notebooks</a></li>
|
177 |
+
<li><a class="link" href="https://sparknlp.org/docs/en/install" target="_blank">Installation Guide</a></li>
|
178 |
+
</ul>
|
179 |
+
</div>
|
180 |
+
""", unsafe_allow_html=True)
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
st-annotated-text
|
3 |
+
streamlit-tags
|
4 |
+
pandas
|
5 |
+
numpy
|
6 |
+
spark-nlp
|
7 |
+
pyspark
|