|
import gradio as gr |
|
from rag import rbc_product |
|
from tool import rival_product |
|
from graphrag import marketing |
|
from knowledge import graph |
|
from pii import derisk |
|
from classify import judge |
|
|
|
|
|
head = """ |
|
<!-- Google tag (gtag.js) --> |
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-SRX9LDVBCW"></script> |
|
<script> |
|
window.dataLayer = window.dataLayer || []; |
|
function gtag(){dataLayer.push(arguments);} |
|
gtag('js', new Date()); |
|
|
|
gtag('config', 'G-SRX9LDVBCW'); |
|
</script> |
|
""" |
|
|
|
with gr.Blocks(head=head) as demo: |
|
with gr.Tab("Intro"): |
|
gr.Markdown(""" |
|
If you're experiencing declining market share, inefficiencies in your operations, here's how I can help: |
|
============== |
|
Marketing & Client Experience |
|
------------ |
|
- GraphRAG: Models customer-product relationship networks for next-best-action predictions |
|
- DSPy: Optimizes cross-sell/upsell prompt variations through A/B testing |
|
|
|
Risk & Audit |
|
------------ |
|
- GraphRAG: Maps transactional relationships into dynamic knowledge graphs to detect multi-layered fraud patterns |
|
- Tool Use: Integrates fraud detection APIs, anomaly scoring models, and regulatory compliance checkers |
|
- DSPy: Optimizes fraud explanation prompts for regulatory reporting |
|
- Explainable AI: Intuitive visualization to help stakeholder understand model risk and flaw |
|
|
|
Other Links: |
|
------------ |
|
- https://huggingface.co/spaces/kevinhug/clientX |
|
- https://kevinwkc.github.io/davinci/ |
|
""") |
|
|
|
with gr.Tab("RAG"): |
|
gr.Markdown(""" |
|
Objective: Recommend RBC product based on persona. |
|
================================================ |
|
- Retrieval: Public RBC Product Data |
|
- Recommend: RBC Product |
|
|
|
Potential Optimization |
|
------------ |
|
BM25 reranking using keyword |
|
""") |
|
in_verbatim = gr.Textbox(label="Verbatim") |
|
out_product = gr.Textbox(label="Product") |
|
|
|
|
|
gr.Examples( |
|
[ |
|
["Low APR and great customer service. I would highly recommend if you’re looking for a great credit card company and looking to rebuild your credit. I have had my credit limit increased annually and the annual fee is very low."] |
|
], |
|
[in_verbatim] |
|
) |
|
btn_recommend=gr.Button("Recommend") |
|
btn_recommend.click(fn=rbc_product, inputs=in_verbatim, outputs=out_product) |
|
|
|
gr.Markdown(""" |
|
Benefits of a Product Recommender System |
|
==================== |
|
- Increased Sales & Revenue |
|
Personalized recommendations drive higher conversion rates and average order value. |
|
|
|
- Enhanced Customer Experience |
|
Tailored suggestions make the shopping journey smoother and more relevant. |
|
|
|
- Customer Retention & Loyalty |
|
Relevant offers encourage repeat visits and build long-term loyalty. |
|
|
|
- Inventory Optimization |
|
Promotes underperforming products or clears surplus stock with strategic recommendations. |
|
""") |
|
|
|
with gr.Tab("Tool Use"): |
|
gr.Markdown(""" |
|
Objective: Recommend financial product based on persona for competitive analysis, product feature discovery |
|
================================================ |
|
- Retrieval: Public Product Data using Tavily Search |
|
- Recommend: Competition Product |
|
""") |
|
in_verbatim = gr.Textbox(label="Verbatim") |
|
out_product = gr.Textbox(label="Product") |
|
|
|
gr.Examples( |
|
[ |
|
["Low APR and great customer service. I would highly recommend if you’re looking for a great credit card company and looking to rebuild your credit. I have had my credit limit increased annually and the annual fee is very low."] |
|
], |
|
[in_verbatim] |
|
) |
|
btn_recommend=gr.Button("Recommend") |
|
btn_recommend.click(fn=rival_product, inputs=in_verbatim, outputs=out_product) |
|
|
|
gr.Markdown(""" |
|
Benefits of a Competitor Product Recommender |
|
================= |
|
- Improved Customer Retention |
|
Prevents drop-offs by offering similar alternatives when a preferred product is unavailable or suboptimal. |
|
|
|
- Increased Conversion Rates |
|
Captures potential lost sales by guiding customers toward viable substitutes. |
|
|
|
- Builds Trust and Transparency |
|
Demonstrates a customer-first approach by recommending the best-fit product—even if it’s not your own. |
|
|
|
- Portfolio Optimization |
|
Helps businesses learn which competitor features customers prefer, guiding product development and pricing. |
|
""") |
|
with gr.Tab("graphrag"): |
|
gr.Markdown(""" |
|
Objective: Create a Marketing Plan based on persona. |
|
======================= |
|
- Reasoning from context, answering the question |
|
""") |
|
|
|
marketing = """ |
|
A business model is not merely a static description but a dynamic ecosystem defined by five interdependent pillars: |
|
|
|
Value Creation (What you sell): The core offering must solve a critical pain point or unlock untapped demand. This is the foundation of your value proposition—quantifiable (e.g., cost efficiency) or qualitative (e.g., exceptional user experience)—that differentiates you in the market. |
|
|
|
Delivery Infrastructure (How you deliver): Channels and partnerships must align to ensure seamless access to your offering. For instance, a SaaS company might leverage cloud platforms for instant scalability, while a luxury brand prioritizes exclusive retail partnerships. |
|
|
|
Customer Lifecycle Dynamics: |
|
|
|
Acquisition: How do users discover you? Channels like organic search (SEO), targeted ads, or influencer partnerships must map to your customer segments’ behaviors. |
|
|
|
Activation: Do first-time users experience immediate value? A fitness app, for example, might use onboarding tutorials to convert sign-ups into active users. |
|
|
|
Retention: Is engagement sustained? Metrics like churn rate and CLV reveal whether your model fosters loyalty through features like personalized content or subscription perks. |
|
|
|
Referral: Do users become advocates? Incentivize sharing through referral programs or viral loops (e.g., Dropbox’s storage rewards). |
|
|
|
Revenue Architecture (How you monetize): Align pricing models (subscriptions, freemium tiers) with customer willingness-to-pay. For instance, a niche market might sustain premium pricing, while a mass-market product prioritizes volume. |
|
|
|
Cost Symmetry: Every activity—from R&D to customer support—must balance against revenue streams. A low-cost airline, for example, optimizes for operational efficiency to maintain profitability. |
|
|
|
Strategic Imperatives for Modern Business Models |
|
|
|
Systemic Integration: Ohmae’s “3C’s” (Customer, Competitor, Company) remind us that acquisition channels and value propositions must adapt to shifting market realities. For instance, a retailer might pivot from brick-and-mortar to hybrid models post-pandemic. |
|
|
|
Data-Driven Iteration: Use AARRR metrics to identify leaks in the funnel. If activation rates lag, refine onboarding; if referrals stagnate, enhance shareability. |
|
|
|
Scalability through Partnerships: Key partners (e.g., tech vendors, logistics providers) can reduce overhead while expanding reach—critical for transitioning from niche to mass markets. |
|
|
|
By framing each component as a strategic variable rather than a fixed element, businesses can continuously adapt to disruptions—a necessity in Ohmae’s vision of fluid, customer-first strategy. |
|
""" |
|
in_verbatim = gr.Textbox(label="Context", value=marketing, visible=False) |
|
in_question = gr.Textbox(label="Persona") |
|
out_product = gr.Textbox(label="Plan") |
|
|
|
gr.Examples( |
|
[ |
|
[ |
|
""" |
|
Low APR and great customer service. I would highly recommend if you’re looking for a great credit card company and looking to rebuild your credit. I have had my credit limit increased annually and the annual fee is very low. |
|
"""] |
|
], |
|
[in_question] |
|
) |
|
btn_recommend = gr.Button("Reasoning") |
|
btn_recommend.click(fn=marketing, inputs=[in_verbatim, in_question], outputs=out_product) |
|
|
|
gr.Markdown(""" |
|
Benefits of a Marketing Campaign Generator |
|
=============== |
|
- Accelerated Campaign Launches |
|
Quickly generates tailored campaigns, reducing go-to-market time from weeks to hours. |
|
|
|
- Improved Targeting & Personalization |
|
Uses customer data and behavior to craft messages that resonate with specific segments. |
|
""") |
|
|
|
with gr.Tab("Knowledge Graph"): |
|
gr.Markdown(""" |
|
Objective: Explain concept in knowledge graph structured output |
|
===================================== |
|
- We create query plan by breaking down into subquery |
|
- Using those subquery to create knowledge graph |
|
""") |
|
in_verbatim = gr.Textbox(label="Question") |
|
out_product = gr.JSON(label="Knowledge Graph") |
|
|
|
gr.Examples( |
|
[ |
|
[ |
|
"Explain me about red flags in transaction pattern for fraud detection" |
|
] |
|
], |
|
[in_verbatim] |
|
) |
|
btn_recommend = gr.Button("Graph It!") |
|
btn_recommend.click(fn=graph, inputs=in_verbatim, outputs=out_product) |
|
|
|
gr.Markdown(""" |
|
Benefits of a Knowledge Graph |
|
============ |
|
- Smarter Data Relationships |
|
Connects siloed data across domains to create a holistic, contextual view. |
|
|
|
- Improved Search & Discovery |
|
Enables semantic search—understanding meaning, not just keywords. |
|
|
|
- Enhanced Decision-Making |
|
Surfaces hidden patterns and relationships for better analytics and insights. |
|
|
|
- Data Reusability |
|
Once created, knowledge graphs can be repurposed across multiple use cases (e.g., search, recommendation, fraud detection). |
|
""") |
|
|
|
with gr.Tab("pii masking"): |
|
gr.Markdown(""" |
|
Objective: pii data removal |
|
================================================ |
|
""") |
|
in_verbatim = gr.Textbox(label="Peronal Info") |
|
out_product = gr.Textbox(label="PII") |
|
|
|
gr.Examples( |
|
[ |
|
[ |
|
""" |
|
He Hua (Hua Hua) Director |
|
[email protected] |
|
+86-28-83505513 |
|
|
|
Alternative Address Format: |
|
Xiongmao Ave West Section, Jinniu District (listed in some records as 610016 postcode) |
|
""" |
|
] |
|
], |
|
[in_verbatim] |
|
) |
|
btn_recommend = gr.Button("Mask PII") |
|
btn_recommend.click(fn=derisk, inputs=in_verbatim, outputs=out_product) |
|
gr.Markdown(""" |
|
Benefits of Entity Removal |
|
================== |
|
- Data Privacy & Compliance |
|
Ensures sensitive information (names, emails, phone numbers, etc.) is anonymized to comply with GDPR, HIPAA, or other regulations. |
|
|
|
- Improved Data Quality |
|
Removes noise (e.g., irrelevant names or addresses) to make datasets cleaner and more usable for modeling or analysis. |
|
|
|
- Enhanced Focus for NLP Models |
|
Allows downstream tasks (like sentiment analysis or topic modeling) to focus on content rather than personal identifiers. |
|
""") |
|
|
|
|
|
with gr.Tab("classification"): |
|
gr.Markdown(""" |
|
Objective: Classify customer feedback into product bucket |
|
================================================ |
|
- multi class classification, could have multiple label for 1 feedback |
|
- fix classification in this use case: online banking, card, auto finance, mortgage, insurance |
|
- LLM Judge to evaluate relevancy |
|
""") |
|
in_verbatim = gr.Textbox(label="Customer Feedback separate by ;") |
|
out_product = gr.Textbox(label="Classification & Evaluation") |
|
|
|
gr.Examples( |
|
[ |
|
[ |
|
""" |
|
"The online portal makes managing my mortgage payments so convenient."; |
|
"RBC offer great mortgage for my home with competitive rate thank you"; |
|
"Low interest rate compared to other cards I’ve used. Highly recommend for responsible spenders."; |
|
"The mobile check deposit feature saves me so much time. Banking made easy!"; |
|
"Affordable premiums with great coverage. Switched from my old provider and saved!" |
|
""" |
|
] |
|
], |
|
[in_verbatim] |
|
) |
|
btn_recommend = gr.Button("Classify & Evaluation") |
|
btn_recommend.click(fn=judge, inputs=in_verbatim, outputs=out_product) |
|
gr.Markdown(""" |
|
Benefits of Multi Class Classification |
|
================== |
|
- Precision Decision-Making |
|
Automates complex categorization tasks (e.g., loan risk tiers, transaction types) with >90% accuracy, reducing human bias. |
|
|
|
- Operational Efficiency |
|
Processes 10,000+ transactions/cases per minute vs. hours manually (e.g., JP Morgan’s COiN platform reduced 360k loan doc hours to seconds). |
|
|
|
- Risk Mitigation |
|
Proactively flags 5+ fraud types (identity theft, money laundering) with 40% fewer false positives than rule-based systems. |
|
|
|
- Regulatory Compliance |
|
Auto-classifies documents for FINRA/SEC audits (e.g., Morgan Stanley uses NLP to categorize 3M+ annual communications into 50+ compliance buckets). |
|
""") |
|
demo.launch(allowed_paths=["./"]) |