|
|
import streamlit as st |
|
|
from transformers import pipeline |
|
|
import warnings |
|
|
|
|
|
warnings.filterwarnings('ignore') |
|
|
|
|
|
st.set_page_config( |
|
|
page_title="AI Solutions for Customer Complaints", |
|
|
layout="wide", |
|
|
initial_sidebar_state="expanded" |
|
|
) |
|
|
|
|
|
|
|
|
st.markdown(""" |
|
|
<style> |
|
|
/* Center all content inside the page */ |
|
|
.centered-div { |
|
|
text-align: center !important; |
|
|
max-width: 800px; |
|
|
margin: auto; |
|
|
} |
|
|
|
|
|
/* Center tabs */ |
|
|
div[role="tablist"] { |
|
|
justify-content: center; |
|
|
} |
|
|
|
|
|
/* Increase tab size */ |
|
|
button[role="tab"] { |
|
|
font-size: 20px !important; |
|
|
padding: 12px 30px !important; |
|
|
height: 60px !important; |
|
|
} |
|
|
|
|
|
/* Center all Streamlit headers and text elements inside the div */ |
|
|
.centered-div h1, |
|
|
.centered-div h2, |
|
|
.centered-div h3, |
|
|
.centered-div h4, |
|
|
.centered-div h5, |
|
|
.centered-div h6, |
|
|
.centered-div p { |
|
|
text-align: center !important; |
|
|
} |
|
|
</style> |
|
|
""", unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
|
|
st.markdown('<div class="centered-div">', unsafe_allow_html=True) |
|
|
st.title("π€ AI Customer Support Solutions") |
|
|
st.markdown(""" |
|
|
Welcome! Explore AI-powered classification for customer complaints in **E-commerce** and **Banking**. Β |
|
|
Select a tab below to get started. |
|
|
""") |
|
|
st.markdown('</div>', unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
tab1, tab2 = st.tabs(["ποΈ E-commerce", "π¦ Bank"]) |
|
|
|
|
|
|
|
|
with tab1: |
|
|
st.markdown('<div class="centered-div">', unsafe_allow_html=True) |
|
|
|
|
|
st.header("E-commerce Customer Support Classification") |
|
|
|
|
|
st.subheader("π Categories You Can Explore:") |
|
|
st.markdown(""" |
|
|
- π¦ **Delivery Problem** β Delays, lost packages, or damaged goods. |
|
|
- πΈ **Returns and Refunds** β Queries about refunds or return policies. |
|
|
- π **Product Inquiry** β Asking about product details, specifications, or availability. |
|
|
- π³ **Payment Issue** β Failed transactions, double charges, or payment errors. |
|
|
- ποΈ **...and 11 more categories fine-tuned in the model!** |
|
|
""") |
|
|
|
|
|
|
|
|
st.subheader("π Try It Yourself!") |
|
|
try: |
|
|
ecommerce_classifier = pipeline( |
|
|
'text-classification', |
|
|
model='E-commerce-customer-query-classifier', |
|
|
trust_remote_code=True |
|
|
) |
|
|
except Exception: |
|
|
st.error("β οΈ Could not load the E-commerce model.") |
|
|
st.stop() |
|
|
|
|
|
text = st.text_area("βοΈ Enter the customer query:", height=150, placeholder="I havenβt received my order yet.") |
|
|
if st.button("Classify E-commerce Query", use_container_width=True, type="primary"): |
|
|
if text.strip(): |
|
|
with st.spinner('π€ Analyzing the query...'): |
|
|
try: |
|
|
result = ecommerce_classifier(text) |
|
|
st.success(f"β
The query has been classified as: **{result[0]['label']}**") |
|
|
st.info(f"π Confidence Level: **{result[0]['score']:.4f}**") |
|
|
except Exception as e: |
|
|
st.error(f"β Classification error: {e}") |
|
|
else: |
|
|
st.warning("β οΈ Please enter a query to classify.") |
|
|
|
|
|
st.subheader("π§ Technical Overview & Features") |
|
|
st.markdown(""" |
|
|
**Model & Dataset:** |
|
|
- Fine-tuned `distilbert-base-uncased` |
|
|
- Dataset: [`Ataur77/ecommerce-customer-support`](https://huggingface.co/datasets/Ataur77/ecommerce-customer-support) |
|
|
|
|
|
**Framework & Libraries:** |
|
|
- Streamlit for interactive UI |
|
|
- Hugging Face Transformers |
|
|
|
|
|
**Features:** |
|
|
- π Quick Classification β Queries are categorized instantly. |
|
|
- π Offline Deployment β Works with locally stored models. |
|
|
- π§© Scalable Design β Extendable to more categories or data. |
|
|
- π User-Friendly β Minimal clicks, maximum insight. |
|
|
""") |
|
|
|
|
|
st.image("e-comm-accuracy.png", caption="π Model Accuracy", width=700) |
|
|
|
|
|
st.subheader("π© Contact") |
|
|
st.markdown("If youβd like to collaborate or learn more: [[email protected]](mailto:[email protected])") |
|
|
|
|
|
st.markdown('</div>', unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
with tab2: |
|
|
st.markdown('<div class="centered-div">', unsafe_allow_html=True) |
|
|
|
|
|
st.header("Bank Customer Complaint Classification") |
|
|
|
|
|
st.subheader("π Example Categories:") |
|
|
st.markdown(""" |
|
|
- π³ **Credit Card or Prepaid Card** β Fraud, charges, or transaction disputes. |
|
|
- π¦ **Checking or Savings Account** β Account balance, overdrafts, or account access. |
|
|
- π‘ **Mortgage** β Loan approvals, EMI, foreclosure, or rate queries. |
|
|
""") |
|
|
|
|
|
|
|
|
st.subheader("π Try It Yourself!") |
|
|
bank_classifier = pipeline('text-classification', model='bank_customer_ticket_category_classifier') |
|
|
|
|
|
text = st.text_area("βοΈ Please describe your issue:", placeholder="My credit card was charged twice for one purchase.") |
|
|
if st.button("Classify Bank Complaint", use_container_width=True, type="primary"): |
|
|
if text.strip(): |
|
|
with st.spinner('π Analyzing complaint...'): |
|
|
result = bank_classifier(text) |
|
|
st.success(f"β
Your issue is classified under: **{result[0]['label']}**") |
|
|
st.info(f"π Confidence Level: **{result[0]['score']:.4f}**") |
|
|
else: |
|
|
st.warning("β οΈ Please enter your complaint.") |
|
|
|
|
|
st.subheader("π§ Technical Overview & Features") |
|
|
st.markdown(""" |
|
|
**Model & Framework:** |
|
|
- Fine-tuned Transformer |
|
|
- Streamlit for rapid prototyping |
|
|
|
|
|
**Libraries:** |
|
|
- Hugging Face Transformers |
|
|
|
|
|
**Features:** |
|
|
- β±οΈ Faster Processing β No waiting for manual triage. |
|
|
- π High Accuracy β Reliable complaint classification. |
|
|
- π‘ Scalability β Handles thousands of inputs seamlessly. |
|
|
""") |
|
|
|
|
|
st.image("bank-accuracy.png", caption="π Model Accuracy", width=700) |
|
|
|
|
|
st.subheader("π© Contact") |
|
|
st.markdown("Reach out?: [[email protected]](mailto:[email protected])") |
|
|
|
|
|
st.markdown('</div>', unsafe_allow_html=True) |