SriragData commited on
Commit
3ee4c2a
·
verified ·
1 Parent(s): b153c7c

Smart MCQ Solver: DeBERTa-v3-large, fp32

Browse files
README.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: microsoft/deberta-v3-large
4
+ tags: [multiple-choice, question-answering, deberta-v3, mcq]
5
+ library_name: transformers
6
+ pipeline_tag: multiple-choice
7
+ ---
8
+
9
+ # Smart MCQ Solver - DeBERTa-v3-large
10
+
11
+ Five-option multiple-choice QA over science and philosophy questions.
12
+ Full fine-tune of `microsoft/deberta-v3-large` with `AutoModelForMultipleChoice`.
13
+
14
+ ## Results
15
+
16
+ | Metric | Value |
17
+ |---|---|
18
+ | 3-fold grouped CV MAP@3 | **0.7567** |
19
+ | Held-out MAP@3 (this artifact) | 0.7944 |
20
+ | Held-out accuracy | 0.6912 |
21
+ | Random MAP@3 baseline | 0.3667 |
22
+
23
+ Cross-validation is `GroupKFold` grouped by normalised prompt, because the dataset
24
+ contains roughly eight near-duplicate phrasings of every question; a random split
25
+ would score memorisation rather than generalisation.
26
+
27
+ ## Loading
28
+
29
+ **Always pass `dtype=torch.float32` explicitly.**
30
+
31
+ ```python
32
+ import torch
33
+ from transformers import AutoTokenizer, AutoModelForMultipleChoice
34
+
35
+ tok = AutoTokenizer.from_pretrained("SriragData/smart-mcq-deberta-v3-large")
36
+ model = AutoModelForMultipleChoice.from_pretrained(
37
+ "SriragData/smart-mcq-deberta-v3-large", dtype=torch.float32).eval()
38
+
39
+ question = "What is the capital of France?"
40
+ options = ["Berlin", "Madrid", "Paris", "Rome", "Lisbon"]
41
+ enc = tok([question]*5, options, truncation=True, max_length=256,
42
+ padding=True, return_tensors="pt")
43
+ with torch.no_grad():
44
+ logits = model(input_ids=enc["input_ids"].unsqueeze(0),
45
+ attention_mask=enc["attention_mask"].unsqueeze(0)).logits[0]
46
+ print(options[int(logits.argmax())])
47
+ ```
48
+
49
+ ## Why the dtype matters
50
+
51
+ The upstream `microsoft/deberta-v3-*` checkpoints store fp16 weights, and
52
+ transformers 5.x honours the dtype recorded in the checkpoint. Loaded in fp16,
53
+ DeBERTa's disentangled attention saturates, the attention softmax collapses to
54
+ one-hot, and the model returns an identical score for every option - MAP@3 drops
55
+ to roughly 0.36, the random baseline, with no error raised. This repository stores
56
+ fp32 weights and records `float32` in `config.json`, but passing `dtype` explicitly
57
+ costs nothing and removes the risk entirely.
58
+
59
+ ## Training
60
+
61
+ | Setting | Value |
62
+ |---|---|
63
+ | Precision | full fp32 (no mixed precision) |
64
+ | Batch size | 1, gradient accumulation 16 (effective 16) |
65
+ | Epochs | {EPOCHS} |
66
+ | Learning rate | 8e-6, cosine schedule, warmup ratio 0.1 |
67
+ | Max length | 256 |
68
+ | Gradient checkpointing | enabled |
69
+ | Checkpointing | disabled (`save_strategy="no"`) |
70
+
71
+ `save_strategy="no"` is deliberate: on some transformers versions the checkpoint
72
+ save/reload cycle renames LayerNorm `gamma`/`beta` and silently resets every
73
+ LayerNorm to its initial values after training completes.
74
+
75
+ ## Limitations
76
+
77
+ - Trained on 2,000 rows covering 252 unique questions. Coverage is narrow.
78
+ - The evaluation set overlaps the training set heavily, so headline scores reflect
79
+ that deployment condition. The leakage-free estimate for this project is 0.6817.
80
+ - Closed-book only: no retrieval, no citation, no abstention. It will answer
81
+ confidently on questions it knows nothing about.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[MASK]": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/kaggle/working/models/deberta_large",
3
+ "architectures": [
4
+ "DebertaV2ForMultipleChoice"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 1024,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 4096,
12
+ "layer_norm_eps": 1e-07,
13
+ "max_position_embeddings": 512,
14
+ "max_relative_positions": -1,
15
+ "model_type": "deberta-v2",
16
+ "norm_rel_ebd": "layer_norm",
17
+ "num_attention_heads": 16,
18
+ "num_hidden_layers": 24,
19
+ "pad_token_id": 0,
20
+ "pooler_dropout": 0,
21
+ "pooler_hidden_act": "gelu",
22
+ "pooler_hidden_size": 1024,
23
+ "pos_att_type": [
24
+ "p2c",
25
+ "c2p"
26
+ ],
27
+ "position_biased_input": false,
28
+ "position_buckets": 256,
29
+ "relative_attention": true,
30
+ "share_att_key": true,
31
+ "torch_dtype": "float32",
32
+ "transformers_version": "4.44.2",
33
+ "type_vocab_size": 0,
34
+ "vocab_size": 128100
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80c976de162bee63283074a958ba05b8ca48a24f7f9469ac901d0fb17edc5fe6
3
+ size 1740300340
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "[SEP]",
5
+ "mask_token": "[MASK]",
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "unk_token": {
9
+ "content": "[UNK]",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ }
15
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[CLS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[SEP]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128000": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "[CLS]",
47
+ "do_lower_case": false,
48
+ "eos_token": "[SEP]",
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 1000000000000000019884624838656,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "sp_model_kwargs": {},
54
+ "split_by_punct": false,
55
+ "tokenizer_class": "DebertaV2Tokenizer",
56
+ "unk_token": "[UNK]",
57
+ "vocab_type": "spm"
58
+ }