yirmibesogluz commited on
Commit
9ab8c93
·
1 Parent(s): d6dbc14

Added classification tasks

Browse files
Files changed (3) hide show
  1. app.py +4 -0
  2. apps/categorization.py +49 -0
  3. apps/sentiment.py +53 -0
app.py CHANGED
@@ -6,6 +6,8 @@ import apps.summarization
6
  import apps.home
7
  import apps.paraphrasing
8
  import apps.title_generation
 
 
9
 
10
  st.set_page_config(
11
  page_title="Turna",
@@ -18,6 +20,8 @@ PAGES = {
18
  "Text Summarization": apps.summarization,
19
  "Text Paraphrasing": apps.paraphrasing,
20
  "News Title Generation": apps.title_generation,
 
 
21
  }
22
 
23
 
 
6
  import apps.home
7
  import apps.paraphrasing
8
  import apps.title_generation
9
+ import apps.sentiment
10
+ import apps.categorization
11
 
12
  st.set_page_config(
13
  page_title="Turna",
 
20
  "Text Summarization": apps.summarization,
21
  "Text Paraphrasing": apps.paraphrasing,
22
  "News Title Generation": apps.title_generation,
23
+ "Sentiment Classification": apps.sentiment,
24
+ "Text Categorization": apps.categorization,
25
  }
26
 
27
 
apps/categorization.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Categorization")
14
+ st.sidebar.header("Text Categorization")
15
+ st.write(
16
+ """Here, you can perform text categorization using the fine-tuned TURNA classification 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_classification_ttc4900",
28
+ "turna_classification_ttc4900_NLU",
29
+ "turna_classification_ttc4900_NLG",
30
+ "turna_classification_ttc4900_S2S",
31
+ ],
32
+ index=0,
33
+ )
34
+ """max_new_tokens = st.sidebar.number_input(
35
+ "Maximum length",
36
+ min_value=0,
37
+ max_value=20,
38
+ value=20,
39
+ help="The maximum length of the sequence to be generated.",
40
+ )"""
41
+
42
+ input_text = st.text_area(label='Enter a text: ', height=200,
43
+ value=" anadolu_efes e 18 lik star ! beko_basketbol_ligi nde iddialı bir kadroyla sezona giren anadolu_efes transfer harekatına devam ediyor avrupa basınında yer alan iddialara göre lacivert beyazlıların son hedefi kk zagreb de forma giyen 1994 doğumlu dario saric hırvat oyuncunun anadolu_efes ile kesin anlaşmaya vardığı iddia edilirken efes in bu transfer için kk zagreb e 550 bin euro ödeyeceği ifade edildi saric in sezon sonuna kadar şu anda kiralık olarak formasını giydiği kk split te kalacağı ve sezon sonunda anadolu_efes e katılacağı belirtildi hırvat basketbolunun gelecek vaadeden isimlerinden biri olarak gösterilen saric 2 05 boyunda ve kısa forvet pozisyonunda görev yapıyor yıldız basketbolcu 2012 18 yaş altı avrupa_basketbol_şampiyonasında hırvatistan ı şampiyonluğa taşımıştı final karşılaşmasında litvanya potasına 39 sayı bırakan saric turnuvayı 25 6 sayı 10 1 ribaund ve 3 3 asist ortalamasıyla tamamlamıştı")
44
+ url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/" + model_name.lower())
45
+ params = {"max_new_tokens": 8 }
46
+ if st.button("Generate"):
47
+ with st.spinner('Generating...'):
48
+ output = query(input_text, url, params)
49
+ st.success(output)
apps/sentiment.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("# Sentiment Classification")
14
+ st.sidebar.header("Sentiment Classification")
15
+ st.write(
16
+ """Here, you can perform sentiment classification using the fine-tuned TURNA classification 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_classification_17bintweet_sentiment",
28
+ "turna_classification_17bintweet_sentiment_NLU",
29
+ "turna_classification_17bintweet_sentiment_NLG",
30
+ "turna_classification_17bintweet_sentiment_S2S",
31
+ "turna_classification_tr_product_reviews",
32
+ "turna_classification_tr_product_reviews_NLU",
33
+ "turna_classification_tr_product_reviews_NLG",
34
+ "turna_classification_tr_product_reviews_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="sonunda bugün kurtuldum senden")
48
+ url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/" + model_name.lower())
49
+ params = {"max_new_tokens": 4 }
50
+ if st.button("Generate"):
51
+ with st.spinner('Generating...'):
52
+ output = query(input_text, url, params)
53
+ st.success(output)