Spaces:
Runtime error
Runtime error
File size: 699 Bytes
f0a7780 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
import transformers
import numpy as np
# Load the pre-trained model
model = transformers.pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-topic-modeling")
# Define the Streamlit app
def main():
st.title("Topic Modeling with Hugging Face")
text = st.text_area("Enter some text to generate topics", height=200)
if st.button("Generate Topics"):
# Generate topics
topics = model(text, max_length=50, do_sample=True, num_beams=5, temperature=0.7)
# Print topics
st.write("Top 5 topics:")
for i in range(5):
st.write(f"{i+1}. {topics[i]['generated_text']}")
if __name__ == "__main__":
main()
|