File size: 1,457 Bytes
5064d87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ce2ff3
5064d87
 
 
 
 
 
 
 
0ce2ff3
5064d87
 
 
 
 
 
 
75bb8ff
5064d87
35a7872
5064d87
35a7872
5064d87
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests
import streamlit as st
import time 
from transformers import pipeline
import os
from .utils import query

HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN')
headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"}

def write():

	st.markdown("# Semantic Textual Similarity")
	st.sidebar.header("Semantic Textual Similarity")
	st.write(
		"""Here, you can measure semantic textual similarity using the fine-tuned TURNA STS models. """
	)

	# Sidebar

	# Taken from https://huggingface.co/spaces/flax-community/spanish-gpt2/blob/main/app.py
	"""st.sidebar.subheader("Configurable parameters")

	model_name = st.sidebar.selectbox(
		"Model Selector",
		options=[
			"turna_semantic_similarity_stsb_tr",
		],
		index=0,
	)
	max_new_tokens = st.sidebar.number_input(
		"Maximum length",
		min_value=0,
		max_value=20,
		value=20,
		help="The maximum length of the sequence to be generated.",
	)"""
	
	model_name = "turna_semantic_similarity_stsb_tr"
	first_text = st.text_area(label='First sentence: ', height=50, 
			value="Bugün okula gitmedim. ")
	second_text = st.text_area(label='Second sentence: ', height=50, 
			value="Ben okula gitmedim bugün. ")
	url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/" + model_name.lower())
	params = {"max_new_tokens": 10 }
	if st.button("Generate"):
		with st.spinner('Generating...'):
			output = query(f"ilk cümle: {first_text} ikinci cümle: {second_text}", url, params)
			st.success(output)