File size: 680 Bytes
92cd920 859df33 92cd920 300b5da 92cd920 2852e17 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import streamlit as st
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load the pre-trained model and tokenizer
model_name = "facebook/opt-125m"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Create the Streamlit app
st.title("Text Summarization App")
text_input = st.text_area("Enter text to summarize")
if st.button("Summarize"):
input_ids = tokenizer.encode(text_input, return_tensors="pt")
summary_ids = model.generate(input_ids, max_length=100, min_length=20, do_sample=False)
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
st.write("Summary:", summary)
|