Spaces:
Sleeping
Sleeping
added first example
Browse files- .vscode/settings.json +3 -0
- app.py +11 -0
- pages/1_Sentiment_Analysis.py +53 -0
- pages/2_Zero-shot_Classification.py +4 -0
- pages/3_Text_Generation.py +4 -0
- pages/4_Mask_filling.py +4 -0
- pages/5_Named_Entity_Recognition.py +4 -0
- pages/6_Question_Answering.py +4 -0
- pages/7_Summarization.py +4 -0
- pages/8_ Translation.py +4 -0
- requirements.txt +4 -0
.vscode/settings.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"wcaForGP.enable": true
|
| 3 |
+
}
|
app.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('🤗 Transformers Library examples')
|
| 4 |
+
st.divider()
|
| 5 |
+
st.write("Sentiment Analysis")
|
| 6 |
+
st.write("'Zero-shot classification")
|
| 7 |
+
st.write("Text Generation")
|
| 8 |
+
st.write("'Mask Filling")
|
| 9 |
+
st.write("Named Entity Recognition")
|
| 10 |
+
st.write("Question Answering")
|
| 11 |
+
st.write("Translation")
|
pages/1_Sentiment_Analysis.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
st.title('Sentiment Analysis')
|
| 5 |
+
|
| 6 |
+
st.subheader("Example: Single statement analysis")
|
| 7 |
+
with st.spinner('Wait for it...'):
|
| 8 |
+
time.sleep(5)
|
| 9 |
+
|
| 10 |
+
from transformers import pipeline
|
| 11 |
+
|
| 12 |
+
classifier = pipeline("sentiment-analysis")
|
| 13 |
+
results = classifier("Transformers library is very helpful.")
|
| 14 |
+
|
| 15 |
+
code = '''
|
| 16 |
+
from transformers import pipeline
|
| 17 |
+
|
| 18 |
+
classifier = pipeline("sentiment-analysis")
|
| 19 |
+
results = classifier("Transformers library is very helpful.")
|
| 20 |
+
'''
|
| 21 |
+
st.code(code, language='python')
|
| 22 |
+
|
| 23 |
+
st.write("Output:")
|
| 24 |
+
st.success(results)
|
| 25 |
+
|
| 26 |
+
st.divider()
|
| 27 |
+
|
| 28 |
+
st.subheader("Example: Multiple statements analysis")
|
| 29 |
+
with st.spinner('Wait for it...'):
|
| 30 |
+
time.sleep(5)
|
| 31 |
+
|
| 32 |
+
code = '''
|
| 33 |
+
from transformers import pipeline
|
| 34 |
+
|
| 35 |
+
classifier = pipeline("sentiment-analysis")
|
| 36 |
+
results = classifier([
|
| 37 |
+
"This is quick tutorial site.",
|
| 38 |
+
"I learnt new topics today.",
|
| 39 |
+
"I do not like lengthy tutorials."
|
| 40 |
+
])
|
| 41 |
+
'''
|
| 42 |
+
st.code(code, language='python')
|
| 43 |
+
|
| 44 |
+
results = classifier([
|
| 45 |
+
"This is quick tutorial site.",
|
| 46 |
+
"I learnt new topics today.",
|
| 47 |
+
"I do not like lengthy tutorials."
|
| 48 |
+
])
|
| 49 |
+
|
| 50 |
+
st.write("Output:")
|
| 51 |
+
st.success(results)
|
| 52 |
+
|
| 53 |
+
|
pages/2_Zero-shot_Classification.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Zero-shot classification')
|
| 4 |
+
|
pages/3_Text_Generation.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Text Generation')
|
| 4 |
+
|
pages/4_Mask_filling.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Mask Filling')
|
| 4 |
+
|
pages/5_Named_Entity_Recognition.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Named Entity Recognition')
|
| 4 |
+
|
pages/6_Question_Answering.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Question Answering')
|
| 4 |
+
|
pages/7_Summarization.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Summarization')
|
| 4 |
+
|
pages/8_ Translation.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Translation')
|
| 4 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
numpy
|
| 3 |
+
pandas
|
| 4 |
+
time
|