Spaces:
Runtime error
Runtime error
File size: 1,283 Bytes
007e35d 8b9dc38 007e35d 8b9dc38 007e35d 8b9dc38 007e35d 8b9dc38 44faf86 007e35d 44faf86 85cb8e5 0954b38 8b9dc38 007e35d 8b9dc38 be28b55 44faf86 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from gradio import Textbox
from transformers import pipeline
import gradio as gr
DESCRIPTION = '''
<div>
<h1 style="text-align: center;">Summarization Chatbot</h1>
<p>This Space demonstrates the Summarization model <a href="https://huggingface.co/spaces/AyeshaNoreen/chatboot-edit"><b>Text Summarization Chatbot</b></a>. Meta Llama3 is the new open LLM and comes in two sizes: 8b and 70b. Feel free to play with it, or duplicate to run privately!</p>
<p>🦕 Looking for an even more powerful model? Check out the <a href="https://huggingface.co/chat/"><b>Hugging Chat</b></a> integration for facebook/bart-large-cnn</p>
</div>
'''
# Initialize the summarization pipeline
summarization_pipe = pipeline("summarization", model="facebook/bart-large-cnn")
# Function to summarize input text
def summarize_text(text):
summary = summarization_pipe(text, max_length=100, min_length=50, do_sample=False)[0]['summary_text']
return summary
# Create the chat interface
chatbot = gr.Interface(
summarize_text,
gr.Textbox(lines=5, label="Input Text"),
gr.Textbox(label="Summary"),
#title="Text Summarization Chatbot",
description=DESCRIPTION,
#theme="compact"
)
# Launch the chat interface
if __name__ == "__main__":
chatbot.launch(share=True)
|