|
import streamlit as st |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
|
|
|
model_name = "facebook/opt-125m" |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = AutoModelForCausalLM.from_pretrained(model_name) |
|
|
|
|
|
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) |
|
|