VishalMysore commited on
Commit
1356723
·
verified ·
1 Parent(s): 2390352

Maya v0.2 (DeBERTa-v3-large fine-tune)

Browse files
Files changed (6) hide show
  1. README.md +30 -20
  2. config.json +29 -69
  3. maya_config.json +6 -3
  4. model.safetensors +2 -2
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +10 -6
README.md CHANGED
@@ -1,40 +1,50 @@
1
  ---
2
  license: apache-2.0
3
- base_model: MoritzLaurer/ModernBERT-base-zeroshot-v2.0
4
  pipeline_tag: text-classification
5
- tags: [yes-no, guardrail, zero-shot, nli, modernbert, calibration]
6
  language: [en]
7
  ---
8
 
9
- # Maya: a dedicated yes/no gate
10
 
11
- Maya reads a text and a statement (or a yes/no question) and returns P(yes). 150M parameters, fine-tuned from [MoritzLaurer/ModernBERT-base-zeroshot-v2.0](https://huggingface.co/MoritzLaurer/ModernBERT-base-zeroshot-v2.0) on rule-labeled synthetic data in which every fact appears in plain and negated wordings with opposite labels (plus a consistency loss that, in an ablation, added nothing measurable).
12
 
13
- Code, data, evaluation and full results: https://github.com/vishalmysore/maya. Browser (int8 ONNX) build: [VishalMysore/mayaWasm](https://huggingface.co/VishalMysore/mayaWasm).
 
 
 
14
 
15
  ```python
16
- # pip install torch transformers ; then from the GitHub repo:
17
  from maya.gate import Maya
18
  maya = Maya.load("VishalMysore/maya")
19
- maya.ask("Hi team, how do I export the dashboard to Excel? No rush.", ["Is the customer angry?"])
 
 
20
  ```
21
 
22
- Without the repo: tokenize the pair `(text, statement)`, run `AutoModelForSequenceClassification` (load with `dtype=torch.float32` on CPU), and take `sigmoid((logits[:, 0] - logits[:, 1]) / 2.8)`; label 0 is "yes". The temperature 2.8 is in `maya_config.json`.
23
 
24
- ## Results (hand-labeled, never used for training)
25
 
26
- | | v1: 120 answers, mostly in-domain | v2: 256 answers, 8 unseen domains |
27
- |---|---|---|
28
- | laya-typed-decisions (421M) | 68.3% acc, AUROC 0.792 | 80.1% acc, AUROC 0.889 |
29
- | ModernBERT-base-zeroshot-v2.0 (starting point) | 76.7%, 0.875 | 78.5%, 0.868 |
30
- | deberta-v3-large-zeroshot-v2.0 (435M) | 75.8%, 0.890 | **89.8%, 0.957** |
31
- | **Maya** | **78.3%, 0.905** | 81.2%, 0.893 |
32
 
33
- Maya is the strongest model tested on its own domains (v1). On unseen domains (v2) it is level with Laya and smaller NLI models, and a 3x larger off-the-shelf NLI model is clearly better.
 
 
 
34
 
35
- - Contradictions between a statement and its negation: 25% (v1) and 27% (v2), against 44-92% for the other models.
36
- - With the shipped temperature, v2 calibration error (ECE) is 0.061.
37
- - Weak spots: agent guardrails (61% on v1, misled by lexical overlap such as "no human has reviewed" vs "without a human"), and minimal pairs in unseen domains (53% vs Laya's 69%). Do not use it as the only safety check.
38
- - It only outputs P(yes): every answer is yes or no (or "not sure" if you set abstention thresholds). It cannot refuse non-yes/no questions.
 
 
39
 
40
  Unofficial experiment, not affiliated with the authors of the base model or of Laya. Apache-2.0; see NOTICE.md.
 
1
  ---
2
  license: apache-2.0
3
+ base_model: MoritzLaurer/deberta-v3-large-zeroshot-v2.0
4
  pipeline_tag: text-classification
5
+ tags: [yes-no, guardrail, zero-shot, nli, deberta-v3, calibration]
6
  language: [en]
7
  ---
8
 
9
+ # Maya v0.2: a dedicated yes/no gate
10
 
11
+ Maya reads a text and a statement (or a yes/no question) and returns P(yes). Version 0.2 has 435M parameters and is fine-tuned from [MoritzLaurer/deberta-v3-large-zeroshot-v2.0](https://huggingface.co/MoritzLaurer/deberta-v3-large-zeroshot-v2.0) on rule-labeled texts with varied wording, minimal pairs and word-overlap traps, plus BoolQ and MNLI pairs to keep its general skill.
12
 
13
+ - Code, data, tests and every result: https://github.com/vishalmysore/maya
14
+ - Live demo in the browser: https://vishalmysore.github.io/maya/
15
+ - Browser (int8 ONNX) build: [VishalMysore/mayaWasm](https://huggingface.co/VishalMysore/mayaWasm)
16
+ - The previous model (v0.1, ModernBERT-base) is kept under the `v0.1` tag of this repo.
17
 
18
  ```python
19
+ # pip install torch transformers sentencepiece ; then from the GitHub repo:
20
  from maya.gate import Maya
21
  maya = Maya.load("VishalMysore/maya")
22
+ maya.ask("Agent plan: delete the `sessions` table on the production database. A verified backup was taken ten minutes ago and the on-call engineer has reviewed the plan.",
23
+ ["The action is destructive and cannot be undone", "This action can be undone if needed"])
24
+ # -> no (0.15), yes (0.90)
25
  ```
26
 
27
+ Without the repo: tokenize the pair `(text, statement)`, run `AutoModelForSequenceClassification` (load with `dtype=torch.float32` on CPU), and take `sigmoid((logits[:, 0] - logits[:, 1]) / 1.65)`; label 0 is "yes". The temperature is in `maya_config.json`.
28
 
29
+ ## Results (hand-labeled test sets, never used for training or model selection)
30
 
31
+ | Model | v3: judgment questions (192 answers) | v2: 8 unseen domains (256) | v1: familiar domains (120) |
32
+ |---|---|---|---|
33
+ | laya-typed-decisions (421M) | 62.5% | 80.1% | 68.3% |
34
+ | deberta-v3-large-zeroshot-v2.0 (Maya's starting point) | 72.9% | 89.8% | 75.8% |
35
+ | Maya v0.1 (ModernBERT-base, 150M) | 71.9% | 81.2% | 78.3% |
36
+ | **Maya v0.2** | **87.5%** | **95.3%** | **87.5%** |
37
 
38
+ - v3 was written and committed before the v0.2 training data existed; it includes word-overlap traps (Maya v0.2: 90%) and minimal pairs (71% of pairs fully right; starting point 33%).
39
+ - Contradictions between a statement and its negation: 12% on v3 and 8% on v2 (starting point: 73% and 30%).
40
+ - Calibration error (ECE) with the shipped temperature: 0.064 on v3, 0.025 on v2.
41
+ - The checkpoint was chosen on a separate 64-answer dev set (87.5%).
42
 
43
+ ## Limits
44
+
45
+ - It still makes mistakes: about one in eight answers on judgment questions is wrong. Example: for a production `DELETE` that "no human has reviewed", it correctly says the action is not safe to run without a human, but answers "no" to "A human should approve this action before it runs". Do not use it as the only safety check.
46
+ - It only outputs P(yes): every answer is yes or no (or "not sure" if you set abstention thresholds). It cannot refuse a question that is not yes/no.
47
+ - A "not sure" band with a guaranteed error rate has to be fitted on a few hundred labeled examples of your own inputs (`maya.conformal.Abstainer`).
48
+ - English only; 435M parameters, about 1 s per question on a laptop CPU.
49
 
50
  Unofficial experiment, not affiliated with the authors of the base model or of Laya. Apache-2.0; see NOTICE.md.
config.json CHANGED
@@ -1,86 +1,46 @@
1
  {
2
  "architectures": [
3
- "ModernBertForSequenceClassification"
4
  ],
5
- "attention_bias": false,
6
- "attention_dropout": 0.0,
7
- "bos_token_id": 50281,
8
- "classifier_activation": "gelu",
9
- "classifier_bias": false,
10
- "classifier_dropout": 0.0,
11
- "classifier_pooling": "mean",
12
- "cls_token_id": 50281,
13
- "decoder_bias": true,
14
- "deterministic_flash_attn": false,
15
  "dtype": "float32",
16
- "embedding_dropout": 0.0,
17
- "eos_token_id": 50282,
18
- "global_attn_every_n_layers": 3,
19
- "gradient_checkpointing": false,
20
- "hidden_activation": "gelu",
21
- "hidden_size": 768,
22
  "id2label": {
23
  "0": "yes",
24
  "1": "no"
25
  },
26
- "initializer_cutoff_factor": 2.0,
27
  "initializer_range": 0.02,
28
- "intermediate_size": 1152,
29
  "label2id": {
30
  "no": 1,
31
  "yes": 0
32
  },
33
- "layer_norm_eps": 1e-05,
34
- "layer_types": [
35
- "full_attention",
36
- "sliding_attention",
37
- "sliding_attention",
38
- "full_attention",
39
- "sliding_attention",
40
- "sliding_attention",
41
- "full_attention",
42
- "sliding_attention",
43
- "sliding_attention",
44
- "full_attention",
45
- "sliding_attention",
46
- "sliding_attention",
47
- "full_attention",
48
- "sliding_attention",
49
- "sliding_attention",
50
- "full_attention",
51
- "sliding_attention",
52
- "sliding_attention",
53
- "full_attention",
54
- "sliding_attention",
55
- "sliding_attention",
56
- "full_attention"
57
  ],
58
- "local_attention": 128,
59
- "max_position_embeddings": 8192,
60
- "mlp_bias": false,
61
- "mlp_dropout": 0.0,
62
- "model_type": "modernbert",
63
- "norm_bias": false,
64
- "norm_eps": 1e-05,
65
- "num_attention_heads": 12,
66
- "num_hidden_layers": 22,
67
- "pad_token_id": 50283,
68
- "position_embedding_type": "absolute",
69
- "problem_type": "single_label_classification",
70
- "rope_parameters": {
71
- "full_attention": {
72
- "rope_theta": 160000.0,
73
- "rope_type": "default"
74
- },
75
- "sliding_attention": {
76
- "rope_theta": 10000.0,
77
- "rope_type": "default"
78
- }
79
- },
80
- "sep_token_id": 50282,
81
- "sparse_pred_ignore_index": -100,
82
- "sparse_prediction": false,
83
  "tie_word_embeddings": true,
84
  "transformers_version": "5.17.0",
85
- "vocab_size": 50368
 
86
  }
 
1
  {
2
  "architectures": [
3
+ "DebertaV2ForSequenceClassification"
4
  ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": null,
 
 
 
 
 
 
 
 
7
  "dtype": "float32",
8
+ "eos_token_id": null,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 1024,
 
 
12
  "id2label": {
13
  "0": "yes",
14
  "1": "no"
15
  },
 
16
  "initializer_range": 0.02,
17
+ "intermediate_size": 4096,
18
  "label2id": {
19
  "no": 1,
20
  "yes": 0
21
  },
22
+ "layer_norm_eps": 1e-07,
23
+ "legacy": true,
24
+ "max_position_embeddings": 512,
25
+ "max_relative_positions": -1,
26
+ "model_type": "deberta-v2",
27
+ "norm_rel_ebd": "layer_norm",
28
+ "num_attention_heads": 16,
29
+ "num_hidden_layers": 24,
30
+ "pad_token_id": 0,
31
+ "pooler_dropout": 0,
32
+ "pooler_hidden_act": "gelu",
33
+ "pooler_hidden_size": 1024,
34
+ "pos_att_type": [
35
+ "p2c",
36
+ "c2p"
 
 
 
 
 
 
 
 
 
37
  ],
38
+ "position_biased_input": false,
39
+ "position_buckets": 256,
40
+ "relative_attention": true,
41
+ "share_att_key": true,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  "tie_word_embeddings": true,
43
  "transformers_version": "5.17.0",
44
+ "type_vocab_size": 0,
45
+ "vocab_size": 128100
46
  }
maya_config.json CHANGED
@@ -1,10 +1,13 @@
1
  {
2
  "p_yes": "sigmoid((logit_yes - logit_no) / temperature)",
3
- "temperature": 2.8,
4
- "temperature_fitted_on": "data/eval (v1, 120 hand-labeled answers); lowered v2 ECE from 0.152 to 0.061",
5
  "thresholds": {
6
  "t_yes": 0.5,
7
  "t_no": 0.5
8
  },
9
- "thresholds_note": "Default is strict yes/no. For 'not sure' with a bounded error rate, fit maya.conformal.Abstainer on a labeled sample of your own inputs (a few hundred answers per side are needed to certify ~10% error)."
 
 
 
10
  }
 
1
  {
2
  "p_yes": "sigmoid((logit_yes - logit_no) / temperature)",
3
+ "temperature": 1.65,
4
+ "temperature_fitted_on": "data/dev (64 hand-labeled answers, never a test set)",
5
  "thresholds": {
6
  "t_yes": 0.5,
7
  "t_no": 0.5
8
  },
9
+ "thresholds_note": "Default is strict yes/no. For 'not sure' with a bounded error rate, fit maya.conformal.Abstainer on a labeled sample of your own inputs (a few hundred answers per side are needed to certify ~10% error).",
10
+ "pad_token_id": 0,
11
+ "version": "0.2",
12
+ "base_model": "MoritzLaurer/deberta-v3-large-zeroshot-v2.0"
13
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cb7d67b8f8303f137bd70055ecdeeef542a3cd9c91d7c1599b15ee04a2bc6ea2
3
- size 598439784
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8040f98ed19a5a4ec19d8d0472befd6fe81a565f697993fb50942c8b22d699d
3
+ size 1740304440
tokenizer.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
@@ -1,17 +1,21 @@
1
  {
 
2
  "backend": "tokenizers",
 
3
  "clean_up_tokenization_spaces": true,
4
  "cls_token": "[CLS]",
 
 
5
  "is_local": false,
6
  "local_files_only": false,
7
  "mask_token": "[MASK]",
8
- "model_input_names": [
9
- "input_ids",
10
- "attention_mask"
11
- ],
12
  "model_max_length": 512,
13
  "pad_token": "[PAD]",
14
  "sep_token": "[SEP]",
15
- "tokenizer_class": "TokenizersBackend",
16
- "unk_token": "[UNK]"
 
 
 
 
17
  }
 
1
  {
2
+ "add_prefix_space": true,
3
  "backend": "tokenizers",
4
+ "bos_token": "[CLS]",
5
  "clean_up_tokenization_spaces": true,
6
  "cls_token": "[CLS]",
7
+ "do_lower_case": false,
8
+ "eos_token": "[SEP]",
9
  "is_local": false,
10
  "local_files_only": false,
11
  "mask_token": "[MASK]",
 
 
 
 
12
  "model_max_length": 512,
13
  "pad_token": "[PAD]",
14
  "sep_token": "[SEP]",
15
+ "sp_model_kwargs": {},
16
+ "split_by_punct": false,
17
+ "tokenizer_class": "DebertaV2Tokenizer",
18
+ "unk_id": 3,
19
+ "unk_token": "[UNK]",
20
+ "vocab_type": "spm"
21
  }