CoolFace
Apppublic

shaymaxo/ai-financial-coach-test

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
App README

💳 AI Personal Spending Coach (ML + LLM)

This project is an AI-powered financial behavior coach that turns transaction data into educational, personalized insights. It combines:

  • —A supervised ML model (classification) to estimate “high-spend risk”
  • —A Large Language Model (LLM) to generate friendly explanations and answer user questions
  • —A Streamlit app deployed on Hugging Face Spaces
Disclaimer: Educational only — not financial advice. No personally identifying financial data is required.

✅ What the App Does

  1. 1.User uploads a CSV of transactions
  2. 2.App computes a summary of recent behavior (last 30 days)
  3. 3.ML model outputs a probability score + risk bucket
  4. 4.User can ask questions in a chat interface (e.g., “What should I focus on this month?”)
  5. 5.LLM generates coaching feedback based on the user’s summary + ML score

🧾 Expected CSV Columns

The app expects a CSV containing the following columns:

  • —Customer ID
  • —Gender
  • —Birthdate
  • —Transaction Amount
  • —Transaction Date
  • —Merchant Name
  • —Category
The app handles mixed date formats and fills missing Gender as “Unknown”.

🔐 LLM Setup (Hugging Face Token)

This app calls an LLM using the Hugging Face Inference API.

In your Hugging Face Space:

  1. 1.Go to Settings → Variables and secrets
  2. 2.Add a Secret:
  3. 3.Name: HF_TOKEN
  4. 4.Value: your Hugging Face Access Token (Read is sufficient)

If the token is missing or the LLM request fails, the app uses a safe fallback response.


🛡️ Security Note (Prompt Injection)

For safety, the app does not expose the system prompt to users. Exposing prompts can increase risk of prompt injection and misuse. Instead, the app provides a short “How it works” explanation and keeps prompts server-side.


🧠 Model Details (Summary)

  • —Model: Gradient Boosting Classifier (via scikit-learn pipeline)
  • —Decision Threshold: 0.60 (balanced)
  • —Key features: age (derived), gender, category, merchant

🚀 Running Locally

bash
pip install -r requirements.txt
streamlit run src/streamlit_app.py