Text Classification
Transformers
Safetensors
Laya
mmbert
system-one
calibrated-decisions
rlcd
classification
routing
guardrails
moderation
commercial-use
Instructions to use convaiinnovations/laya-multilingual with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use convaiinnovations/laya-multilingual with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="convaiinnovations/laya-multilingual")# pip install -U transformers accelerate # Load model directly from transformers import LayaTypedDecisions model = LayaTypedDecisions.from_pretrained("convaiinnovations/laya-multilingual", device_map="auto") - Laya
How to use convaiinnovations/laya-multilingual with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Inference
- Notebooks
- Google Colab
- Kaggle
Initial release of Laya Multilingual (mmBERT-base, 100+ languages, RLCD)
Browse files- .gitattributes +1 -0
- README.md +94 -0
- encoder/config.json +79 -0
- model.safetensors +3 -0
- rl_agent_config.json +26 -0
- tokenizer/tokenizer.json +3 -0
- tokenizer/tokenizer_config.json +22 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
tags:
|
| 5 |
+
- laya
|
| 6 |
+
- multilingual
|
| 7 |
+
- mmbert
|
| 8 |
+
- system-one
|
| 9 |
+
- calibrated-decisions
|
| 10 |
+
- rlcd
|
| 11 |
+
- classification
|
| 12 |
+
- routing
|
| 13 |
+
- guardrails
|
| 14 |
+
- moderation
|
| 15 |
+
- email-triage
|
| 16 |
+
- commercial-use
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Laya Multilingual (mmBERT-base)
|
| 20 |
+
|
| 21 |
+
Laya Multilingual is a fast, non-autoregressive System 1 decision engine supporting over 100 languages natively. It evaluates typed schemas (`choice`, `score`, `noul`) over unstructured state (text, email, ticket, or JSON) in a **single ~35ms forward pass** on a GPU, returning mathematically calibrated probabilities and confidence scores with zero text generation and zero hallucinations.
|
| 22 |
+
|
| 23 |
+
Trained on over 1,000,000 multi-domain records using **RLCD (Reinforcement Learning for Calibrated Decisions)** with strictly proper scoring rules.
|
| 24 |
+
|
| 25 |
+
| Question Type | Returns | Real-World Application |
|
| 26 |
+
|---|---|---|
|
| 27 |
+
| `choice` | Top option, probability distribution, confidence | Multilingual intent classification, department routing, topic sorting |
|
| 28 |
+
| `score` | Position along an ordinal rubric, distribution, confidence | Frustration level, ticket urgency, harm severity |
|
| 29 |
+
| `noul` | Calibrated boolean probability P(true) from 0.0 to 1.0 | Phishing detection, spam filtering, jailbreak detection, churn risk |
|
| 30 |
+
|
| 31 |
+
## Model Architecture
|
| 32 |
+
* **Backbone Encoder:** `jhu-clsp/mmBERT-base` (135M parameters, bidirectional ModernBERT architecture, 22 layers, 768 hidden dimension, 12 attention heads, 256k multilingual vocabulary covering 100+ languages, natively supporting up to 8,192 tokens with RoPE).
|
| 33 |
+
* **Decision Head:** 2-layer TransformerEncoder (768 dim, 12 heads, FFN=3072) + Option Marker Scorer + Cost-Sensitive Act/Escalate Head.
|
| 34 |
+
* **Total Parameters:** ~160M parameters (runs 3x faster than 400M+ models).
|
| 35 |
+
* **Option Markers:** Options are denoted by `[MASK]` tokens; hidden states are pooled via `torch.gather` and scored in a single forward pass.
|
| 36 |
+
|
| 37 |
+
## Training Details
|
| 38 |
+
* **Method:** RLCD (pure policy gradient REINFORCE with GRPO-style group baseline).
|
| 39 |
+
* **Rewards:** Strictly proper scoring rules (Log-score + Spherical score + Ranked Probability Score for ordinal rubrics).
|
| 40 |
+
* **Dataset:** 100% human-annotated real-world datasets across multilingual intents, NLI, safety moderation, prompt guardrails, and all 5 email triage and threat sources (Enron spam, phishing emails, phishing URLs, support tickets, and Bitext intents).
|
| 41 |
+
* **Precision:** Trained in BF16 on NVIDIA RTX 6000 Pro.
|
| 42 |
+
* **Fitted Temperatures:** [1.0, 1.0, 1.0]
|
| 43 |
+
|
| 44 |
+
## Quickstart (`pip install laya`)
|
| 45 |
+
|
| 46 |
+
```bash
|
| 47 |
+
pip install laya
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
import laya
|
| 52 |
+
|
| 53 |
+
# Load the multilingual model directly from Hugging Face
|
| 54 |
+
agent = laya.load("convaiinnovations/laya-multilingual")
|
| 55 |
+
|
| 56 |
+
# 1. State in any supported language
|
| 57 |
+
state = {
|
| 58 |
+
"subject": "Facture débitée deux fois",
|
| 59 |
+
"body": "Bonjour, nous avons été facturés deux fois pour le mois de mars. Veuillez rembourser le doublon aujourd'hui."
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
# 2. Define typed questions
|
| 63 |
+
questions = {
|
| 64 |
+
"department": {
|
| 65 |
+
"type": "choice",
|
| 66 |
+
"instructions": "Quel service doit traiter cet e-mail ?",
|
| 67 |
+
"criteria": {
|
| 68 |
+
"facturation": "factures, paiements, remboursements",
|
| 69 |
+
"technique": "bugs, pannes, intégrations",
|
| 70 |
+
"commercial": "tarification, nouveaux contrats",
|
| 71 |
+
"autre": "toute autre demande"
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"urgence": {
|
| 75 |
+
"type": "score",
|
| 76 |
+
"instructions": "Quelle est l'urgence de cette demande ?",
|
| 77 |
+
"criteria": ["pas urgent", "bientôt", "blocage critique ou date limite"]
|
| 78 |
+
},
|
| 79 |
+
"est_spam": {
|
| 80 |
+
"type": "noul",
|
| 81 |
+
"instructions": "Cet e-mail est-il un spam non sollicité ?"
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
# 3. Single forward pass in ~35 ms
|
| 86 |
+
result = agent.predict(state, questions)
|
| 87 |
+
print(result["answers"])
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
## Interactive Demo
|
| 91 |
+
Try the live Space demo: [convaiinnovations/laya-demo](https://huggingface.co/spaces/convaiinnovations/laya-demo)
|
| 92 |
+
|
| 93 |
+
## License
|
| 94 |
+
Released under the Apache 2.0 License by [Convai Innovations](https://huggingface.co/convaiinnovations).
|
encoder/config.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ModernBertForMaskedLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 2,
|
| 8 |
+
"classifier_activation": "gelu",
|
| 9 |
+
"classifier_bias": false,
|
| 10 |
+
"classifier_dropout": 0.0,
|
| 11 |
+
"classifier_pooling": "mean",
|
| 12 |
+
"cls_token_id": 1,
|
| 13 |
+
"decoder_bias": true,
|
| 14 |
+
"deterministic_flash_attn": false,
|
| 15 |
+
"dtype": "float32",
|
| 16 |
+
"embedding_dropout": 0.0,
|
| 17 |
+
"eos_token_id": 1,
|
| 18 |
+
"global_attn_every_n_layers": 3,
|
| 19 |
+
"gradient_checkpointing": false,
|
| 20 |
+
"hidden_activation": "gelu",
|
| 21 |
+
"hidden_size": 768,
|
| 22 |
+
"initializer_cutoff_factor": 2.0,
|
| 23 |
+
"initializer_range": 0.02,
|
| 24 |
+
"intermediate_size": 1152,
|
| 25 |
+
"layer_norm_eps": 1e-05,
|
| 26 |
+
"layer_types": [
|
| 27 |
+
"full_attention",
|
| 28 |
+
"sliding_attention",
|
| 29 |
+
"sliding_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"sliding_attention",
|
| 32 |
+
"sliding_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"sliding_attention",
|
| 35 |
+
"sliding_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"sliding_attention",
|
| 38 |
+
"sliding_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"sliding_attention",
|
| 41 |
+
"sliding_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"sliding_attention",
|
| 44 |
+
"sliding_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"sliding_attention",
|
| 47 |
+
"sliding_attention",
|
| 48 |
+
"full_attention"
|
| 49 |
+
],
|
| 50 |
+
"local_attention": 128,
|
| 51 |
+
"mask_token_id": 4,
|
| 52 |
+
"max_position_embeddings": 8192,
|
| 53 |
+
"mlp_bias": false,
|
| 54 |
+
"mlp_dropout": 0.0,
|
| 55 |
+
"model_type": "modernbert",
|
| 56 |
+
"norm_bias": false,
|
| 57 |
+
"norm_eps": 1e-05,
|
| 58 |
+
"num_attention_heads": 12,
|
| 59 |
+
"num_hidden_layers": 22,
|
| 60 |
+
"pad_token_id": 0,
|
| 61 |
+
"position_embedding_type": "sans_pos",
|
| 62 |
+
"repad_logits_with_grad": false,
|
| 63 |
+
"rope_parameters": {
|
| 64 |
+
"full_attention": {
|
| 65 |
+
"rope_theta": 160000,
|
| 66 |
+
"rope_type": "default"
|
| 67 |
+
},
|
| 68 |
+
"sliding_attention": {
|
| 69 |
+
"rope_theta": 160000,
|
| 70 |
+
"rope_type": "default"
|
| 71 |
+
}
|
| 72 |
+
},
|
| 73 |
+
"sep_token_id": 1,
|
| 74 |
+
"sparse_pred_ignore_index": -100,
|
| 75 |
+
"sparse_prediction": false,
|
| 76 |
+
"tie_word_embeddings": true,
|
| 77 |
+
"transformers_version": "5.0.0",
|
| 78 |
+
"vocab_size": 256000
|
| 79 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9d628fd971b700382ac6f65920a86f149777b2e748e0c955fb3b19695aa8f204
|
| 3 |
+
size 643835514
|
rl_agent_config.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"encoder": "/kaggle/input/notebooks/nandukuttan/rl-agent-asset/models/mmBERT-base",
|
| 3 |
+
"head_layers": 2,
|
| 4 |
+
"max_len": 1024,
|
| 5 |
+
"head_max_len": 256,
|
| 6 |
+
"max_prefixes": 6,
|
| 7 |
+
"act_costs": {
|
| 8 |
+
"escalate": 0.5
|
| 9 |
+
},
|
| 10 |
+
"cost_wrong_act": 3.0,
|
| 11 |
+
"amp_dtype": "bf16",
|
| 12 |
+
"model_name": "rl-agent",
|
| 13 |
+
"temperature": [
|
| 14 |
+
1.0,
|
| 15 |
+
1.0,
|
| 16 |
+
1.0
|
| 17 |
+
],
|
| 18 |
+
"temperature_by_options": {},
|
| 19 |
+
"training": {
|
| 20 |
+
"updates": 15987,
|
| 21 |
+
"epochs_completed": 4,
|
| 22 |
+
"hours": 4.97,
|
| 23 |
+
"world_size": 1,
|
| 24 |
+
"fine_tuned_from_checkpoint": false
|
| 25 |
+
}
|
| 26 |
+
}
|
tokenizer/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:609d8f4c067cd3950f88594c5a802616cea245823836ef5848ee4fc40aab5b6f
|
| 3 |
+
size 34363188
|
tokenizer/tokenizer_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<bos>",
|
| 3 |
+
"clean_up_tokenization_spaces": false,
|
| 4 |
+
"cls_token": "<bos>",
|
| 5 |
+
"eos_token": "<eos>",
|
| 6 |
+
"extra_special_tokens": [
|
| 7 |
+
"<start_of_turn>",
|
| 8 |
+
"<end_of_turn>"
|
| 9 |
+
],
|
| 10 |
+
"mask_token": "<mask>",
|
| 11 |
+
"model_input_names": [
|
| 12 |
+
"input_ids",
|
| 13 |
+
"attention_mask"
|
| 14 |
+
],
|
| 15 |
+
"model_max_length": 8192,
|
| 16 |
+
"pad_token": "<pad>",
|
| 17 |
+
"padding_side": "right",
|
| 18 |
+
"sep_token": "<eos>",
|
| 19 |
+
"spaces_between_special_tokens": false,
|
| 20 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 21 |
+
"unk_token": "<unk>"
|
| 22 |
+
}
|