import awesome_streamlit as ast import streamlit as st from transformers import pipeline import apps.summarization API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/TURNA" st.set_page_config( page_title="Turna", page_icon="📖", layout='wide' ) PAGES = { "Home": backend.home, "Arabic Text Preprocessor": backend.processor, "Arabic Language Generation": backend.aragpt, "Arabic Sentiment Analysis": backend.sa, # "Arabic Sarcasm Detection": backend.sarcasm, "Arabic Question Answering": backend.qa, } 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.markdown( """

TURNA

""", unsafe_allow_html=True, ) st.write("#") col = st.columns(2) col[0].image("images/turna-logo.png", width=100) st.markdown( """

TURNA is a Turkish encoder-decoder language model.

Use the generation paramters on the sidebar to adjust generation quality.

""", 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)" )