This project is a language model application built using Streamlit and Hugging Face Transformers libraries, allowing users to generate text interactively with pretrained models. It features model selection, streamlined user interface, and can be applied in various domains like creative writing, education, and AI assistants. With continuous improvement plans, it aims to provide a seamless text generation experience for users.
-
Imports:
- Imported the
pipeline
function from the Streamlit library and the Hugging Face Transformers library.
- Imported the
-
Load Model:
- Loaded a text generation model using the
pipeline("text-generation", model="openai-gpt")
statement, specifying the model as OpenAI GPT.
- Loaded a text generation model using the
-
Main Function:
- Defined a
main
function to build the Streamlit application. - Configured the page layout and styling using
st.set_page_config
. - Added the application title and a horizontal line using
st.title
andst.markdown
respectively. - Provided a description of the application using
st.write
. - Created a sidebar for user input with
st.sidebar
.- Added a subheader and a text area for users to input text.
- Added a button to trigger text generation using
st.button
. - Upon button click, generated text using the pre-trained language model and displayed it using
st.write
.
- Defined a
-
Run the App:
- Used
if __name__ == "__main__":
to start the main function of the application.
- Used
- Streamlit: To create the interactive web application.
- Transformers: For utilizing pretrained language models.
- TensorFlow: Required for TensorFlow-based models or operations.
- tf-keras: Necessary for Keras functionalities in TensorFlow.
You can install the required libraries using pip:
pip install streamlit transformers tensorflow tf-keras
Once the libraries are installed, you can start the Streamlit application locally by running:
streamlit run streamlit_app.py
You can use the app function by accessing the following Web URL:
-
Access the official Streamlit website
https://streamlit.io/
and signin to your account. -
Create a new app connecting to the GitHub account.
3. Deploy the app, the process can be slow.
- Once the app has been deployed, you can access the streamlit application using the web url: https://ids721-project9-xc202-byao4pryw27go8ilsnklhn.streamlit.app/