Spaces:
Build error
Build error
Commit ·
48e59e1
1
Parent(s): ffa4ee0
feat: initial commit
Browse files- app.py +23 -0
- requirements.txt +2 -0
- samples.py +36 -0
- summarizer.py +15 -0
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from summarizer import summarize_text
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def main():
|
| 6 |
+
st.title("Text Summarizer")
|
| 7 |
+
|
| 8 |
+
text = st.text_area("Enter text to summarize")
|
| 9 |
+
|
| 10 |
+
if st.button("Summarize"):
|
| 11 |
+
if text:
|
| 12 |
+
summarized_text = summarize_text(text)
|
| 13 |
+
st.subheader("Original Text")
|
| 14 |
+
st.write(text)
|
| 15 |
+
|
| 16 |
+
st.subheader("Summarized Text")
|
| 17 |
+
st.write(summarized_text)
|
| 18 |
+
else:
|
| 19 |
+
st.warning("Please enter some text to summarize")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers[torch]
|
samples.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ARTICLE_FROM_HFACE = (
|
| 2 |
+
"PG&E stated it scheduled the blackouts in response to forecasts for high winds "
|
| 3 |
+
"amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were "
|
| 4 |
+
"scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow."
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
ARTICLE_FROM_BOOMAI = """
|
| 8 |
+
The integration of Artificial Intelligence (AI) in customer engagement strategies has marked a
|
| 9 |
+
new era in the business-consumer relationship. AI technologies are transforming how
|
| 10 |
+
businesses interact with their customers, offering personalized experiences and enhancing
|
| 11 |
+
customer satisfaction.
|
| 12 |
+
One of the key applications of AI in customer engagement is through chatbots and virtual
|
| 13 |
+
assistants. These AI-powered tools can handle a wide range of customer service inquiries,
|
| 14 |
+
providing instant responses and support 24/7. They are programmed to learn from interactions,
|
| 15 |
+
enabling them to deliver more accurate and helpful responses over time. This not only improves
|
| 16 |
+
the efficiency of customer service but also allows human agents to focus on more complex
|
| 17 |
+
queries. Another significant impact of AI is in the realm of data analysis and customer insights.
|
| 18 |
+
AI algorithms can process vast amounts of data from various customer touchpoints and extract
|
| 19 |
+
meaningful patterns and trends. This data-driven approach enables businesses to understand
|
| 20 |
+
customer behavior and preferences in-depth, leading to more targeted and effective marketing
|
| 21 |
+
strategies. Personalization is also a major benefit of AI in customer engagement. By analyzing
|
| 22 |
+
past interactions and purchases, AI can help businesses tailor their communications and
|
| 23 |
+
recommendations to individual customers. This level of personalization enhances the customer
|
| 24 |
+
experience, increases brand loyalty, and can lead to higher conversion rates.
|
| 25 |
+
AI is also reshaping customer engagement through predictive analytics. By forecasting future
|
| 26 |
+
customer behaviors and trends, businesses can proactively address potential issues and seize
|
| 27 |
+
opportunities. This forward-looking approach helps in maintaining a competitive edge and
|
| 28 |
+
staying relevant in the market. However, the use of AI in customer engagement also presents
|
| 29 |
+
challenges, particularly in terms of privacy and ethical considerations. Businesses must ensure
|
| 30 |
+
that customer data is handled responsibly, and AI interactions are transparent and secure.
|
| 31 |
+
In conclusion, AI is playing a crucial role in revolutionizing customer engagement. Its ability to
|
| 32 |
+
provide personalized, efficient, and data-driven interactions is not only enhancing the customer
|
| 33 |
+
experience but also driving business growth and innovation. As AI technology continues to
|
| 34 |
+
evolve, its impact on customer engagement is expected to grow even further, shaping the future
|
| 35 |
+
of business-customer relationships.
|
| 36 |
+
"""
|
summarizer.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, BartForConditionalGeneration
|
| 2 |
+
|
| 3 |
+
model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn")
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn")
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def summarize_text(text_to_summarize):
|
| 8 |
+
inputs = tokenizer([text_to_summarize], max_length=1024, return_tensors="pt")
|
| 9 |
+
summary_ids = model.generate(
|
| 10 |
+
inputs["input_ids"], num_beams=2, min_length=0, max_length=100
|
| 11 |
+
)
|
| 12 |
+
summarized_text = tokenizer.batch_decode(
|
| 13 |
+
summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 14 |
+
)[0]
|
| 15 |
+
return summarized_text
|