yirmibesogluz commited on
Commit
5064d87
·
1 Parent(s): ca81517

Added the STS task

Browse files
Files changed (1) hide show
  1. apps/sts.py +51 -0
apps/sts.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("# Semantic Textual Similarity")
14
+ st.sidebar.header("Semantic Textual Similarity")
15
+ st.write(
16
+ """Here, you can measure semantic textual similarity using the fine-tuned TURNA STS 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_semantic_similarity_stsb_tr",
28
+ "turna_semantic_similarity_stsb_tr_NLU",
29
+ "turna_semantic_similarity_stsb_tr_NLG",
30
+ "turna_semantic_similarity_stsb_tr_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
+ first_text = st.text_area(label='First sentence: ', height=50,
43
+ value="Turnayı gözünden vurduk.")
44
+ second_text = st.text_area(label='Second sentence: ', height=50,
45
+ value="Çok iyi kazandık.")
46
+ url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/" + model_name.lower())
47
+ params = {"max_new_tokens": 10 }
48
+ if st.button("Generate"):
49
+ with st.spinner('Generating...'):
50
+ output = query(f"ilk cümle: {first_text} ikinci cümle: {second_text}", url, params)
51
+ st.success(output)