Skip to content

Public Home

Nick edited this page Mar 10, 2026 · 1 revision

PATAS - Pattern-Adaptive Anti-Spam System

Automatically discovers spam patterns and creates blocking rules


🎯 What is PATAS?

PATAS is a system that automatically analyzes your messages, finds similar spam patterns, and creates blocking rules that can be immediately used in your system.

The Problem PATAS Solves

Before PATAS:

  • ❌ Moderators manually review thousands of complaints
  • ❌ Blocking rules are written manually and quickly become outdated
  • ❌ New spam patterns emerge faster than they can be blocked
  • ❌ No understanding of why messages are similar

With PATAS:

  • ✅ Automatically groups similar spam messages
  • ✅ Explains why messages are similar
  • ✅ Creates ready-to-use SQL queries for blocking
  • ✅ Works 24/7, never tires, never misses patterns

🚀 Quick Start

1. Try the CLI Demo (Simplified Version)

Want to quickly understand how PATAS works?

Try our educational CLI demo — a simplified version that demonstrates the basic concept:

# Install from GitHub Release
pip install patas_demo_cli-0.1.0-py3-none-any.whl

# Or from Git
pip install git+https://github.com/KikuAI-Lab/PATAS.git#subdirectory=apps/demo-cli

# Usage
patas-demo analyze

⚠️ Important: This is a simplified version for educational purposes. See CLI Demo for details.

2. Try the Full Demo

Interactive demo — drag and drop a file with messages and see pattern analysis:

👉 Run Demo

3. Use the API

If you're a developer, integrate PATAS via the API:

# Send a batch of messages
curl -X POST https://api.patas.com/api/v1/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"id": "1", "text": "Buy now! http://spam.com", "is_spam": true},
      {"id": "2", "text": "Click here: http://spam.com", "is_spam": true}
    ],
    "run_mining": true
  }'

Result:

{
  "patterns": [
    {
      "group_size": 2,
      "similarity_reason": "Messages contain the same suspicious URL: http://spam.com",
      "sql_query": "SELECT id FROM reports WHERE message_content LIKE '%http://spam.com%'"
    }
  ]
}

📚 Documentation

For Developers

General Documents

Specialized Topics


🎯 Key Features

Pattern Discovery

  • Automatically identifies spam patterns from your data
  • Supports multiple pattern types (URLs, keywords, signatures, semantic)
  • Uses LLM for intelligent pattern recognition (optional)

Safe Rule Lifecycle

  • CandidateShadowActiveDeprecated
  • Shadow evaluation prevents false positives
  • Automatic rollback for degrading rules

Metrics & Evaluation

  • Tracks precision, recall, coverage
  • Monitors false positives
  • Performance metrics for each rule

Production-Ready

  • RESTful API for integration
  • Batch processing for large datasets
  • Configurable aggressiveness profiles (conservative/balanced/aggressive)

📊 API Endpoints

PATAS provides 9 RESTful endpoints:

  1. GET /api/v1/health — Health check
  2. POST /api/v1/messages/ingest — Message ingestion
  3. POST /api/v1/patterns/mine — Run pattern mining
  4. GET /api/v1/patterns — List patterns
  5. GET /api/v1/rules — List rules
  6. POST /api/v1/rules/eval-shadow — Evaluate shadow rules
  7. POST /api/v1/rules/promote — Promote/deprecate rules
  8. GET /api/v1/rules/export — Export active rules
  9. POST /api/v1/analyze ⭐ — Batch analysis (main endpoint)

See API Reference for details.


💻 CLI Commands

PATAS provides 7 CLI commands:

  • patas ingest-logs — Ingest from external API or storage
  • patas mine-patterns — Run pattern mining
  • patas eval-rules — Evaluate shadow rules
  • patas promote-rules — Promote and monitor rules
  • patas safety-eval — Safety evaluation
  • patas demo-telegram — Demo for Telegram engineers
  • patas explain-rule — Explain a rule with examples

🔒 Security

  • SQL injection protection
  • Whitelist for tables/columns
  • Input data validation
  • PII redaction
  • Privacy modes (STANDARD/STRICT)

📄 License

MIT License — see LICENSE


🤝 Contributing

We welcome contributions! See CONTRIBUTING for details.


Version: 2.0.0
Status: Production Ready

Clone this wiki locally