TURNA / Turna.py
yirmibesogluz's picture
Added summarization
5dc09e9
raw
history blame
2.21 kB
import awesome_streamlit as ast
import streamlit as st
from transformers import pipeline
import pages.turna
API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/TURNA"
st.set_page_config(
page_title="Turna",
page_icon="📖",
layout='wide'
)
st.markdown(
"""
<h1 style="text-align:left;">TURNA</h1>
""",
unsafe_allow_html=True,
)
st.write("#")
col = st.columns(2)
col[0].image("images/turna-logo.png", width=100)
st.markdown(
"""
<h3 style="text-align:right;">TURNA is a Turkish encoder-decoder language model.</h3>
<p style="text-align:right;"><p>
<p style="text-align:right;">Use the generation paramters on the sidebar to adjust generation quality.</p>
<p style="text-align:right;"><p>
""",
unsafe_allow_html=True,
)
#st.title('Turkish Language Generation')
#st.write('...with Turna')
input_text = st.text_area(label='Enter a text: ', height=100,
value="Türkiye'nin başkeni neresidir?")
if st.button("Generate"):
with st.spinner('Generating...'):
output = query(input_text)
st.success(output)
def query(payload):
#{"inputs": payload, ""}
while True:
response = requests.post(API_URL, json=payload)
if 'error' not in response.json():
output = response.json()[0]["generated_text"]
return output
else:
time.sleep(15)
print('Sending request again', flush=True)
def pipe():
pipe = pipeline("text2text-generation", model="boun-tabi-LMG/TURNA", tokenizer="boun-tabi-LMG/TURNA", temperature=0.7, repetition_penalty=0.5, top_p=0.9)
"""PAGES = {
"Turkish Language Generation": pages.turna,
}
st.sidebar.title("Navigation")
selection = st.sidebar.radio("Pages", list(PAGES.keys()))
page = PAGES[selection]
# with st.spinner(f"Loading {selection} ..."):
ast.shared.components.write_page(page)"""
st.sidebar.header("Info")
st.sidebar.write(
"Models are available on [HF Hub](https://huggingface.co/collections/boun-tabi-LMG)"
)
st.sidebar.write(
"Model source code available on [GitHub](https://github.com/boun-tabi-LMG/turkish-lm-tuner)"
)