import streamlit as st ################################ ####### Generic functions ###### ################################ def option_change(): if st.session_state.action_type=="Sentiment Analysis": sentiment_analysis() elif st.session_state.action_type=="Zero-shot Classification": zero_shot_classification() elif st.session_state.action_type=="Text Generation": text_generation() elif st.session_state.action_type=="Mask Filling": mask_filling() elif st.session_state.action_type=="Named Entity Recognition": named_entity_recognition() elif st.session_state.action_type=="Question & Answering": qna() elif st.session_state.action_type=="Summarization": summarization() elif st.session_state.action_type=="English to French Translation": translation_eng2frn() def button_clicked(): st.session_state.output_text="Button Clicked" def sentiment_analysis(): st.session_state.input_text="I've been waiting for a HuggingFace course my whole life." def zero_shot_classification(): st.session_state.input_text="This is a course about the transformers library" def text_generation(): st.session_state.input_text="In this course, we will teach you how to" def mask_filling(): st.session_state.input_text="This course will teach you all about models." def named_entity_recognition(): st.session_state.input_text="My name is Sylvain and I work at Hugging Face in Brooklyn." def qna(): st.session_state.input_text="My name is Sylvain and I work at Hugging Face in Brooklyn" def summarization(): st.session_state.input_text= """ America has changed dramatically during recent years. Not only has the number of graduates in traditional engineering disciplines such as mechanical, civil, electrical, chemical, and aeronautical engineering declined, but in most of the premier American universities engineering curricula now concentrate on and encourage largely the study of engineering science. As a result, there are declining offerings in engineering subjects dealing with infrastructure, the environment, and related issues, and greater concentration on high technology subjects, largely supporting increasingly complex scientific developments. While the latter is important, it should not be at the expense of more traditional engineering. Rapidly developing economies such as China and India, as well as other industrial countries in Europe and Asia, continue to encourage and advance the teaching of engineering. Both China and India, respectively, graduate six and eight times as many traditional engineers as does the United States. Other industrial countries at minimum maintain their output, while America suffers an increasingly serious decline in the number of engineering graduates and a lack of well-educated engineers. """ def translation_eng2frn(): st.session_state.input_text= "This course is produced by Hugging Face." ################################ ####### Display of data ######## ################################ st.set_page_config(layout='wide') # Title st.title("LLM Basics Demo - with Huggingface Pipeline()") # 3 Column Layout col1, col2, col3 = st.columns(3) with col1: options = ["Sentiment Analysis", "Zero-shot Classification", "Text Generation","Mask Filling","Named Entity Recognition","Question & Answering","Summarization","English to French Translation"] llm_action_type = st.selectbox("Select LLM Tasktype", options,key="action_type", on_change=option_change) with col3: llm_button = st.button("Generate Data",on_click=button_clicked) # Display Input in single Layout llm_input_text = st.text_area(label="Enter your message",key="input_text", height=400) # Display Output in single Layout llm_output_text = st.text_area("Generate Output",key="output_text", height=400)