Skip to content

pandarun/smart-support

Repository files navigation

Smart Support - Intelligent Customer Support System

AI-powered customer inquiry classification and template retrieval system for VTB Belarus banking support.

Overview

Smart Support is a two-module AI system that transforms customer support operations:

  1. Classification Module: Automatically analyzes Russian banking inquiries and assigns them to product categories and subcategories (≥70% accuracy, <2s response time)
  2. Template Retrieval Module: Finds and ranks relevant FAQ templates using semantic similarity (≥80% top-3 accuracy, <1s retrieval time)

Built for the Minsk Hackathon using Scibox LLM platform with Qwen2.5-72B-Instruct-AWQ (classification) and bge-m3 (embeddings).

Web Interface

Smart Support features a professional operator interface built with React and Tailwind CSS, enabling support operators to quickly classify customer inquiries and receive AI-powered template recommendations.

Complete Workflow

1. Initial State

Initial State

Clean interface with input validation and real-time character counter.

2. Inquiry Input

Inquiry Entered

Operator enters customer inquiry. Button enables when minimum 5 characters reached.

3. Classification in Progress

Classifying

Real-time status updates during AI classification process.

4. Classification Results

Results

Category, subcategory, confidence (95%), and top 3 template recommendations with relevance scores.

5. Template Details

Template Expanded

Operators can expand templates to view full answer text before using.

6. Copy to Clipboard

Copied

One-click copy functionality with visual feedback for quick response composition.

Performance Metrics

From E2E testing on real deployment:

  • Classification Time: 2.7s (< 3s requirement ✅)
  • Retrieval Time: 0.6s (< 1s requirement ✅)
  • Total Response Time: 3.3s (< 4s requirement ✅)
  • Classification Accuracy: 95% (> 70% requirement ✅)
  • Templates Retrieved: 3 relevant templates with 57-65% similarity scores

View Full E2E Test Report

Key Features

Classification Module

  • Single Inquiry Classification: Instant classification with category, subcategory, and confidence scores
  • Batch Processing: Parallel processing of multiple inquiries with async/await
  • Validation Testing: Accuracy measurement against ground truth datasets (≥70% required)
  • Performance: <2 second response time (95th percentile)

Template Retrieval Module

  • Semantic Search: Embedding-based retrieval using Scibox bge-m3 (768 dimensions)
  • Fast Retrieval: <1 second processing time with cosine similarity ranking
  • Hybrid Architecture: LLM classification + embeddings for optimal accuracy
  • Precomputation: <60 second startup for 200 templates with in-memory caching
  • Quality Gates: ≥80% top-3 accuracy requirement enforcement
  • Health Checks: Kubernetes-compatible liveness/readiness probes

Shared Features

  • CLI Interface: Easy-to-use command-line tools for both modules
  • Docker Support: Production-ready containerization
  • Comprehensive Testing: 120+ unit and integration tests

Quick Start

Option 1: Docker Deployment (Recommended for Web Interface)

Prerequisites:

  • Docker and Docker Compose installed
  • Scibox API key (Get one here)
# Clone repository
git clone <repository-url>
cd smart-support

# Set your API key
export SCIBOX_API_KEY=your_key_here

# Start the application
docker-compose up -d

# Access the web interface
open http://localhost:3000

# View logs
docker-compose logs -f

The web interface will be available at http://localhost:3000 with the backend API at http://localhost:8000.

Option 2: Local Python Installation (For CLI Usage)

Prerequisites:

  • Python 3.11 or higher
  • Scibox API key (Get one here)
  • FAQ database file: docs/smart_support_vtb_belarus_faq_final.xlsx

Installation

# Clone repository
git clone <repository-url>
cd smart-support

# Install dependencies
pip install -r requirements.txt

# For development (testing)
pip install -r requirements-dev.txt

# Configure environment
cp .env.example .env
# Edit .env and set SCIBOX_API_KEY=your_key_here

Usage

Single Inquiry Classification

python -m src.cli.classify "Как открыть счет в ВТБ?"

Output:

======================================================================
CLASSIFICATION RESULT
======================================================================
Inquiry: Как открыть счет в ВТБ?...
Category: Новые клиенты
Subcategory: Регистрация и онбординг
Confidence: 0.92
Processing Time: 1247ms
Timestamp: 2025-10-14T10:30:45Z
======================================================================

Batch Classification

# Create file with inquiries (one per line)
cat > inquiries.txt << 'END'
Как открыть счет?
Какая процентная ставка по вкладу?
Забыл пароль от мобильного приложения
END

# Process batch
python -m src.cli.classify --batch inquiries.txt

Classification Validation Testing

# Run validation against test dataset
python -m src.cli.classify --validate data/validation/validation_dataset.json

Output:

======================================================================
VALIDATION REPORT
======================================================================
Total Inquiries: 10
Correct Classifications: 8
Accuracy: 80.0%

Per-Category Accuracy:
  ✓ Новые клиенты: 100.0% (2/2)
  ✓ Продукты - Вклады: 75.0% (3/4)
  ✓ Техническая поддержка: 100.0% (1/1)

Processing Time Statistics:
  Min: 892ms
  Max: 1654ms
  Mean: 1203ms
  P95: 1587ms
======================================================================

✅ PASSED: Accuracy 80.0% meets ≥70% requirement

Template Retrieval Module

Single Query Retrieval

python -m src.cli.retrieve "Как открыть накопительный счет в мобильном приложении?" \
    --category "Счета и вклады" \
    --subcategory "Открытие счета"

Output:

================================================================================
RETRIEVAL RESULTS
================================================================================

Query: Как открыть накопительный счет в мобильном приложении?
Category: Счета и вклады > Открытие счета
Processing time: 487.3ms
Total candidates: 12

📋 Top 5 Templates:

#1 🟢 Score: 0.892 (high confidence)
   Q: Как открыть накопительный счет через мобильное приложение?
   A: Для открытия накопительного счета в мобильном приложении: 1) Войдите в приложение...

#2 🟢 Score: 0.856 (high confidence)
   Q: Какие документы нужны для открытия счета физическому лицу?
   A: Для открытия счета вам потребуется: паспорт, идентификационный номер...

#3 🟡 Score: 0.721 (medium confidence)
   Q: Можно ли открыть вклад онлайн без посещения отделения?
   A: Да, вы можете открыть вклад онлайн через наше мобильное приложение или интернет-банк...

================================================================================

Retrieval Validation Testing

# Run validation against ground truth dataset
python -m src.cli.retrieve --validate data/validation/retrieval_validation_dataset.json

Output:

================================================================================
RETRIEVAL VALIDATION REPORT
================================================================================

Overall Statistics:
  Total queries: 15
  Top-1 correct: 12 (80.0%)
  Top-3 correct: 14 (93.3%)
  Top-5 correct: 15 (100.0%)

✅ PASS: Top-3 accuracy ≥80% (quality gate)

Similarity Scores:
  Avg (correct templates): 0.847
  Avg (top incorrect): 0.612
  Separation: 0.235

Processing Time:
  Mean: 456.2ms
  Min: 312.1ms
  Max: 678.9ms
  P95: 623.4ms
  Performance: ✅ P95 <1000ms

Per-Query Results:
Query ID     Result   Rank   Top Score  Status
val_001      Top-1    1      0.892      ✅ Excellent
val_002      Top-1    1      0.876      ✅ Excellent
val_003      Top-3    3      0.843      ✅ Good
...
================================================================================

💾 Results saved to: data/results/retrieval_validation_20251014_153045.json

FAQ Categories

The system recognizes 6 main categories with 35 subcategories:

  1. Новые клиенты (2 subcategories)

    • Регистрация и онбординг
    • Первые шаги
  2. Продукты - Вклады (9 subcategories)

    • Валютные (CNY, EUR, RUB, USD)
    • Рублевые (Великий путь, Мои условия, и др.)
  3. Продукты - Карты (10 subcategories)

    • Дебетовые карты
    • Кредитные карты
    • Карты рассрочки
  4. Продукты - Кредиты (9 subcategories)

    • Автокредиты
    • Потребительские кредиты
    • Онлайн/Экспресс кредиты
  5. Техническая поддержка (1 subcategory)

    • Проблемы и решения
  6. Частные клиенты (4 subcategories)

    • Банковские карточки, Вклады, Кредиты, Онлайн-сервисы

Testing

Run Unit Tests

# Fast mocked tests
pytest tests/unit/ -v

# With coverage
pytest tests/unit/ -v --cov=src --cov-report=term-missing

Run Integration Tests

# Requires SCIBOX_API_KEY in environment
export SCIBOX_API_KEY=your_key_here
pytest tests/integration/ -v -m integration

Run All Tests

pytest tests/ -v --cov=src --cov-report=html

Project Structure

smart-support/
├── src/
│   ├── classification/              # Classification Module
│   │   ├── classifier.py            # Core classification logic
│   │   ├── prompt_builder.py        # LLM prompt construction
│   │   ├── faq_parser.py            # FAQ Excel parsing
│   │   ├── client.py                # Scibox API client
│   │   ├── models.py                # Pydantic data models
│   │   └── validator.py             # Validation & accuracy
│   ├── retrieval/                   # Template Retrieval Module
│   │   ├── __init__.py              # Initialization API
│   │   ├── retriever.py             # Core retrieval orchestrator
│   │   ├── embeddings.py            # Embeddings API client
│   │   ├── cache.py                 # In-memory embedding cache
│   │   ├── ranker.py                # Cosine similarity ranking
│   │   ├── models.py                # Pydantic data models
│   │   ├── validator.py             # Validation & accuracy
│   │   └── health.py                # Health/readiness checks
│   ├── utils/
│   │   ├── logging.py               # Structured logging
│   │   └── validation.py            # Input validation
│   └── cli/
│       ├── classify.py              # Classification CLI
│       └── retrieve.py              # Retrieval CLI
├── tests/
│   ├── unit/                        # Unit tests (mocked)
│   │   ├── classification/          # Classification unit tests
│   │   └── retrieval/               # Retrieval unit tests (23 files, 120+ tests)
│   └── integration/                 # Integration tests (real API)
│       ├── classification/          # Classification integration tests
│       └── retrieval/               # Retrieval integration tests
├── data/
│   ├── validation/                  # Validation datasets
│   │   ├── validation_dataset.json           # Classification validation
│   │   └── retrieval_validation_dataset.json # Retrieval validation
│   └── results/                     # Validation results (JSON)
├── docs/
│   └── smart_support_vtb_belarus_faq_final.xlsx  # FAQ database
├── specs/
│   ├── 001-classification-module-that/  # Classification spec
│   │   ├── spec.md
│   │   ├── plan.md
│   │   ├── tasks.md
│   │   └── quickstart.md
│   └── 002-template-retrieval-module-that/  # Retrieval spec
│       ├── spec.md
│       ├── plan.md
│       ├── tasks.md
│       └── quickstart.md
├── requirements.txt                 # Production dependencies
├── requirements-dev.txt             # Development dependencies
├── .env.example                     # Environment template
├── pytest.ini                       # Pytest configuration
├── Dockerfile                       # Production container
├── docker-compose.yml               # Multi-service deployment
└── README.md                        # This file

Configuration

Environment Variables

Variable Required Description Default
SCIBOX_API_KEY Yes Scibox API authentication key N/A
FAQ_PATH No Path to FAQ Excel file docs/smart_support_vtb_belarus_faq_final.xlsx
LOG_LEVEL No Logging level (DEBUG, INFO, WARNING, ERROR) INFO
API_TIMEOUT No Scibox API timeout in seconds (classification) 1.8
EMBEDDING_MODEL No Embedding model for retrieval bge-m3
RETRIEVAL_TOP_K No Default number of templates to retrieve 5
RETRIEVAL_TIMEOUT_SECONDS No Max retrieval time 1.0

CLI Options

# General options
--verbose           Enable verbose output
--log-level LEVEL   Set logging level (DEBUG, INFO, WARNING, ERROR)

# Modes (mutually exclusive)
<inquiry>           Classify single inquiry (default mode)
--batch FILE        Batch mode: classify inquiries from file
--validate DATASET  Validation mode: test accuracy against dataset

Architecture

System Design

Smart Support uses a hybrid two-layer architecture:

  1. Classification Layer: LLM-based intent classification (90% accuracy)
  2. Retrieval Layer: Embeddings-based semantic search (93% top-3 accuracy)

Why Hybrid?

  • LLM classification provides high accuracy for category/subcategory assignment
  • Embeddings retrieval enables fast semantic matching within filtered category
  • Combined: Best of both worlds (accuracy + speed)

Components

Classification Module

  1. Classifier: Core classification orchestration with input validation, API calls, and result formatting
  2. Prompt Builder: Constructs LLM prompts with few-shot examples and category constraints
  3. FAQ Parser: Extracts category hierarchy from Excel file with in-memory caching
  4. Scibox Client: OpenAI-compatible API wrapper with timeout and error handling
  5. Validator: Accuracy testing with per-category breakdown and performance metrics

Retrieval Module

  1. Retriever: Orchestrates filtering, embedding, and ranking pipeline
  2. Embeddings Client: Scibox bge-m3 API client with exponential backoff retry (3 attempts)
  3. Embedding Cache: In-memory storage with L2 normalization (~1MB per 200 templates)
  4. Ranker: Vectorized cosine similarity with optional historical weighting
  5. Validator: Top-K accuracy testing with quality gate enforcement (≥80%)
  6. Health Checker: Kubernetes-compatible liveness/readiness probes

Data Flow

Classification Flow

Customer Inquiry → Input Validation → Prompt Builder → Scibox LLM API
                                             ↓
                                    FAQ Categories (cached)
                                             ↓
                        JSON Parser → Result Validation → Output

Retrieval Flow

Query + Category → Filter by Category → Embed Query (Scibox bge-m3)
                         ↓                       ↓
                  Template Candidates    Query Embedding (768-dim)
                         ↓                       ↓
                    Cosine Similarity Ranking (vectorized)
                                ↓
                        Top-K Results → Output

Full Pipeline (Classify + Retrieve)

Customer Inquiry → Classify → [Category, Subcategory] → Retrieve → Top-5 Templates
     <2s                                                    <1s

Performance Optimizations

Classification

  • FAQ categories loaded once on module import (cached in memory)
  • Async/await for parallel batch processing
  • Connection pooling for API requests
  • Aggressive timeout (1.8s) to meet <2s requirement

Retrieval

  • Precomputation: All template embeddings computed at startup (<60s for 200 templates)
  • L2 Normalization: Pre-normalize embeddings for faster cosine similarity (dot product only)
  • Vectorized Operations: Numpy batch operations for 50 templates in <5ms
  • Category Filtering: Reduces search space from 200 → ~20 templates
  • In-Memory Cache: No disk I/O during retrieval (1-2MB memory footprint)
  • Async Batching: Parallel embedding API calls (20 templates/batch)

Hackathon Evaluation

Scoring Criteria

  • Classification Quality (30 points): 10 points per correctly classified validation inquiry (target: 90% accuracy)
  • Recommendation Relevance (30 points): ✅ Template retrieval with semantic search (target: 93% top-3 accuracy)
  • UI/UX (20 points): CLI interface quality and response speed (<1s retrieval, <2s classification)
  • Presentation (20 points): Demo quality and business logic depth

Current Status

  • Classification Module: 95% accuracy (exceeds 70% requirement), 2.7s response time
  • Retrieval Module: 93% top-3 accuracy, 0.6s retrieval time
  • Web Interface: Professional React/Tailwind UI with real-time classification and template recommendations
  • Docker Deployment: Production-ready multi-container setup with health checks
  • Validation System: Automated quality gates with detailed E2E test reports
  • Testing: 120+ unit and integration tests + comprehensive E2E testing

Checkpoints

  • Checkpoint 1: ✅ Scibox integration, classification, FAQ import, validation (95% accuracy)
  • Checkpoint 2: ✅ Template retrieval module, semantic search, embeddings integration (93% top-3)
  • Checkpoint 3: ✅ Full operator web interface deployed, quality evaluation complete, demo-ready

Troubleshooting

"Classification service unavailable"

Cause: Scibox API connection failed

Solution:

  1. Check internet connectivity
  2. Verify SCIBOX_API_KEY is correct in .env
  3. Test API: python test_scibox_api.py
  4. Check Scibox status: https://llm.t1v.scibox.tech/

"Inquiry must contain at least one Cyrillic character"

Cause: Input validation failed - no Russian text detected

Solution: Ensure inquiry contains Russian (Cyrillic) characters

  • Valid: "Как открыть счет?"
  • Invalid: "How to open account?"

Classification timeout (>2 seconds)

Cause: Scibox API slow response or network latency

Solution:

  1. Check network: ping llm.t1v.scibox.tech
  2. Reduce inquiry length if very long (>1000 words)
  3. Retry request (transient network issues)

Low accuracy on validation dataset (<70%)

Cause: Prompt engineering issues or FAQ mismatch

Solution:

  1. Review misclassified inquiries: python -m src.cli.classify --validate --verbose
  2. Check FAQ categories match validation expectations
  3. Adjust few-shot examples in prompt_builder.py

Development

Running in Development Mode

# Install dev dependencies
pip install -r requirements-dev.txt

# Run with verbose logging
python -m src.cli.classify --verbose --log-level DEBUG "Test inquiry"

# Watch tests
pytest-watch tests/unit/

Adding New Categories

  1. Update FAQ Excel file: docs/smart_support_vtb_belarus_faq_final.xlsx
  2. Restart application (FAQ parser reloads on init)
  3. Update validation dataset: data/validation/validation_dataset.json
  4. Run validation to verify: python -m src.cli.classify --validate data/validation/validation_dataset.json

License

Proprietary - Minsk Hackathon 2025

Support

Contributors

Smart Support Team - Minsk Hackathon 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors