Spaces:
Running
Running
Commit
·
1dbf22b
1
Parent(s):
7f1f820
Added paraphrasing task
Browse files- app.py +2 -1
- apps/paraphrasing.py +53 -0
- apps/summarization.py +1 -1
app.py
CHANGED
|
@@ -13,7 +13,8 @@ st.set_page_config(
|
|
| 13 |
|
| 14 |
PAGES = {
|
| 15 |
"Turna": apps.home,
|
| 16 |
-
"Text Summarization": apps.summarization
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
|
|
|
|
| 13 |
|
| 14 |
PAGES = {
|
| 15 |
"Turna": apps.home,
|
| 16 |
+
"Text Summarization": apps.summarization,
|
| 17 |
+
"Text Paraphrasing": apps.paraphrasing
|
| 18 |
}
|
| 19 |
|
| 20 |
|
apps/paraphrasing.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import time
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
import os
|
| 6 |
+
from .utils import query
|
| 7 |
+
|
| 8 |
+
HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN')
|
| 9 |
+
headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"}
|
| 10 |
+
|
| 11 |
+
def write():
|
| 12 |
+
|
| 13 |
+
st.markdown("# Text Paraphrasing")
|
| 14 |
+
st.sidebar.header("Text Paraphrasing")
|
| 15 |
+
st.write(
|
| 16 |
+
"""Here, you can paraphrase your text using the fine-tuned TURNA paraphrasing models. """
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
# Sidebar
|
| 20 |
+
|
| 21 |
+
# Taken from https://huggingface.co/spaces/flax-community/spanish-gpt2/blob/main/app.py
|
| 22 |
+
st.sidebar.subheader("Configurable parameters")
|
| 23 |
+
|
| 24 |
+
model_name = st.sidebar.selectbox(
|
| 25 |
+
"Model Selector",
|
| 26 |
+
options=[
|
| 27 |
+
"turna_paraphrasing_tatoeba",
|
| 28 |
+
"turna_paraphrasing_tatoeba_NLU",
|
| 29 |
+
"turna_paraphrasing_tatoeba_NLG",
|
| 30 |
+
"turna_paraphrasing_tatoeba_S2S",
|
| 31 |
+
"turna_paraphrasing_opensubtitles",
|
| 32 |
+
"turna_paraphrasing_opensubtitles_NLU",
|
| 33 |
+
"turna_paraphrasing_opensubtitles_NLG",
|
| 34 |
+
"turna_paraphrasing_opensubtitles_S2S",
|
| 35 |
+
],
|
| 36 |
+
index=0,
|
| 37 |
+
)
|
| 38 |
+
max_new_tokens = st.sidebar.number_input(
|
| 39 |
+
"Maximum length",
|
| 40 |
+
min_value=0,
|
| 41 |
+
max_value=20,
|
| 42 |
+
value=20,
|
| 43 |
+
help="The maximum length of the sequence to be generated.",
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
input_text = st.text_area(label='Enter a text: ', height=100,
|
| 47 |
+
value="Kalp krizi geçirenlerin yaklaşık üçte birinin kısa bir süre önce grip atlattığı düşünülüyor. ")
|
| 48 |
+
url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/" + model_name.lower())
|
| 49 |
+
params = {"max_new_tokens": max_new_tokens }
|
| 50 |
+
if st.button("Generate"):
|
| 51 |
+
with st.spinner('Generating...'):
|
| 52 |
+
output = query(input_text, url, params)
|
| 53 |
+
st.success(output)
|
apps/summarization.py
CHANGED
|
@@ -26,8 +26,8 @@ def write():
|
|
| 26 |
model_name = st.sidebar.selectbox(
|
| 27 |
"Model Selector",
|
| 28 |
options=[
|
| 29 |
-
"turna_summarization_mlsum",
|
| 30 |
"turna_summarization_tr_news",
|
|
|
|
| 31 |
],
|
| 32 |
index=0,
|
| 33 |
)
|
|
|
|
| 26 |
model_name = st.sidebar.selectbox(
|
| 27 |
"Model Selector",
|
| 28 |
options=[
|
|
|
|
| 29 |
"turna_summarization_tr_news",
|
| 30 |
+
"turna_summarization_mlsum"
|
| 31 |
],
|
| 32 |
index=0,
|
| 33 |
)
|