Text Classification
Transformers
Safetensors
modernbert
prompt-injection
jailbreak-detection
ai-safety
guardrails
bfsi
text-embeddings-inference
Instructions to use Zytra/aval with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zytra/aval with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Zytra/aval")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, SemalithDualHead tokenizer = AutoTokenizer.from_pretrained("Zytra/aval") model = SemalithDualHead.from_pretrained("Zytra/aval", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Zytra/aval: direct link, hf CLI and curl.
- Browser
- Download file 3.66 kB
-
https://huggingface.co/Zytra/aval/resolve/main/README.md
- Command line
-
hf download hf://Zytra/aval/README.md
-
curl -L -o README.md https://huggingface.co/Zytra/aval/resolve/main/README.md
3.66 kB
| library_name: transformers | |
| pipeline_tag: text-classification | |
| tags: | |
| - modernbert | |
| - prompt-injection | |
| - jailbreak-detection | |
| - ai-safety | |
| - guardrails | |
| - bfsi | |
| # Aval (Semalith) | |
| Aval is a dual-head text classifier for screening inputs to LLM applications. For each message it predicts: | |
| 1. **Risk**: whether the text is benign or matches a threat category, such as prompt injection, jailbreak, data extraction, social engineering, harmful content or a BFSI-specific attack. | |
| 2. **Intent**: what a benign user in a banking or financial services (BFSI) setting is asking for, such as checking a balance, card servicing or loans. | |
| ## Model details | |
| | | | | |
| |---|---| | |
| | Architecture | `SemalithDualHead`: a ModernBERT encoder with two classification heads | | |
| | Encoder | 22 layers, hidden size 768, 12 attention heads | | |
| | Attention | Alternating global and sliding-window attention (window 128), with global attention every 3rd layer | | |
| | Max sequence length | 8,192 tokens | | |
| | Vocabulary | 256,000 tokens | | |
| | Pooling | Mean | | |
| | Weights | `float32`, safetensors | | |
| | Taxonomy version | 3.1.0 | | |
| ## Labels | |
| ### Risk head (20 classes) | |
| | ID | Label | Group | | |
| |---|---|---| | |
| | 0 | `BENIGN` | BENIGN | | |
| | 1 | `D1_SYSTEM_OVERRIDE` | D_ATTACK | | |
| | 2 | `D1_JAILBREAK` | D_ATTACK | | |
| | 3 | `D1_EXTRACTION` | D_ATTACK | | |
| | 4 | `D1_SOCIAL_ENGINEERING` | D_ATTACK | | |
| | 5 | `D1_AUTHORITY_CLAIM` | D_ATTACK | | |
| | 6 | `D1_NARRATIVE_FRAME` | D_ATTACK | | |
| | 7 | `D5_EVASION` | D_ATTACK | | |
| | 8 | `D6_AGENTIC_INJECTION` | D_ATTACK | | |
| | 9 | `D7_INDIRECT_INJECTION` | D_ATTACK | | |
| | 10 | `D8_GENERAL_HARM` | D_HARM | | |
| | 11β18 | `B-01` β¦ `B-08` | BFSI_ATTACK | | |
| | 19 | `D2_COPYRIGHT` | D_HARM | | |
| Every label except `BENIGN` is treated as a threat. The four groups are `BENIGN`, `D_ATTACK`, `D_HARM` and `BFSI_ATTACK`. | |
| When a message matches more than one threat label, the label that comes first in this order is reported: | |
| `D7_INDIRECT_INJECTION` β `D6_AGENTIC_INJECTION` β `D5_EVASION` β `D1_SYSTEM_OVERRIDE` β `D1_JAILBREAK` β `D1_NARRATIVE_FRAME` β `D1_AUTHORITY_CLAIM` β `D1_SOCIAL_ENGINEERING` β `D1_EXTRACTION` β `B-01` β¦ `B-08` β `D8_GENERAL_HARM` β `D2_COPYRIGHT` | |
| ### Intent head (12 classes) | |
| | ID | Label | | |
| |---|---| | |
| | 0 | `NONE` | | |
| | 1 | `I_BALANCE_ENQUIRY` | | |
| | 2 | `I_CARD_SERVICING` | | |
| | 3 | `I_TRANSFERS_PAYMENTS` | | |
| | 4 | `I_LOAN_MORTGAGE` | | |
| | 5 | `I_INSURANCE` | | |
| | 6 | `I_WEALTH_INVESTMENT` | | |
| | 7 | `I_KYC_ONBOARDING` | | |
| | 8 | `I_COMPLAINT_DISPUTE` | | |
| | 9 | `I_GREETING_SMALLTALK` | | |
| | 10 | `I_AGENT_HANDOFF` | | |
| | 11 | `I_OTHER` | | |
| The complete mappings, including the threat flags and groups, are in `label_map.json`. | |
| ## Files | |
| | File | Contents | | |
| |---|---| | |
| | `model.safetensors` | Model weights | | |
| | `config.json` | Encoder configuration and risk-label mapping | | |
| | `label_map.json` | Risk, intent and group label mappings, plus the precedence order | | |
| | `tokenizer.json`, `tokenizer_config.json` | Tokenizer | | |
| ## Usage | |
| `SemalithDualHead` is a custom architecture, so `AutoModelForSequenceClassification` cannot load both heads directly. Load the tokenizer with `transformers`, and load the weights with the `SemalithDualHead` model class from the Semalith codebase: | |
| ```python | |
| from transformers import AutoTokenizer | |
| from safetensors.torch import load_file | |
| tokenizer = AutoTokenizer.from_pretrained("zytra/aval") | |
| state_dict = load_file("model.safetensors") # load into SemalithDualHead | |
| ``` | |
| ## Intended use | |
| Aval is meant to be one layer in a guardrail or AI-governance pipeline. It flags risky inputs and routes benign BFSI requests. Don't use it as the only safety control: review its decisions for your own domain and pair it with other safeguards. | |