Spaces:
Runtime error
Runtime error
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) |