--- language: - en - hi - pa tags: - text-classification - bert - finance - multilingual - coercion-detection - fraud-detection license: mit --- # NLP Coercion Detector — SecureWealth Twin (M3) Fine-tuned `google/muril-base-cased` for detecting stress and coercion language in bank AI chat messages across English, Hindi (Devanagari), and Punjabi (Gurmukhi). Part of the **SecureWealth Twin** AI system — a bank-grade fraud detection and financial intelligence platform. --- ## Model Details | | | |---|---| | Base model | `google/muril-base-cased` | | Task | Binary text classification | | Languages | English · Hindi · Punjabi | | Max sequence length | 128 | | Training epochs | 6 (early stopping, patience=2) | | Learning rate | 2e-5 | | Batch size | 16 | | Dataset size | ~490 rows | --- ## Labels | Label | ID | Meaning | |-------|----|---------| | Normal | 0 | Regular chat message | | Coercion | 1 | Stress / coercion language detected | --- ## Usage ### Load and run inference ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch model_id = "NanG01/m3-coercion-bert" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForSequenceClassification.from_pretrained(model_id) model.eval() def predict_coercion(text: str) -> dict: enc = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=128) with torch.no_grad(): label = model(**enc).logits.argmax(-1).item() return {"chat_stress_language": label, "risk_pts": 20 if label == 1 else 0} ``` ### Examples ```python predict_coercion("They said I must transfer 50000 rupees urgent right now") # → {"chat_stress_language": 1, "risk_pts": 20} predict_coercion("Please fast, he told me this is the last warning from income tax department") # → {"chat_stress_language": 1, "risk_pts": 20} predict_coercion("Jaldi karo, do minute vich transfer karna hai nahi tan khat khatam ho jaavega") # → {"chat_stress_language": 1, "risk_pts": 20} predict_coercion("How can I increase my monthly SIP amount?") # → {"chat_stress_language": 0, "risk_pts": 0} predict_coercion("Mera portfolio performance dikhao") # → {"chat_stress_language": 0, "risk_pts": 0} ``` --- ## Output | Field | Type | Description | |-------|------|-------------| | `chat_stress_language` | int | `1` = coercion detected · `0` = normal | | `risk_pts` | int | `+20` if coercion detected, `0` otherwise | `chat_stress_language` feeds directly into **M4 Coercion Risk Scorer** as one of 12 binary signals (+20 risk pts). --- ## Trigger Patterns Common coercion indicators the model detects: `urgent` · `hurry` · `they said` · `he told me` · `please fast` · `last warning` · `account will be blocked` · `income tax` · `jaldi karo` · `abhi transfer karo` --- ## Training Data ~490 chat messages across 3 languages: - 90 English coercion/normal messages - 400 Hindi coercion/normal messages - Punjabi messages included Dataset: `SecureWealthTwin_DL_Datasets_v2.xlsx` (private) **Regularisation applied:** - Frozen BERT encoder layers 0–9 (only top 2 layers + classifier trained) - Dropout 0.3 on hidden, attention, and classifier layers - Weight decay 0.01 - Gradient clipping (max norm 1.0) - Early stopping (patience=2) --- --- license: apache-2.0 ---