real-jiakai commited on
Commit
cf30567
1 Parent(s): 61fea97

Upload folder using huggingface_hub

Browse files
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ checkpoint-*/
2
+ .ipynb_checkpoints
README.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ language:
4
+ - en
5
+ license: mit
6
+ base_model: FacebookAI/roberta-base
7
+ tags:
8
+ - generated_from_trainer
9
+ datasets:
10
+ - swag
11
+ metrics:
12
+ - accuracy
13
+ model-index:
14
+ - name: swag_base
15
+ results:
16
+ - task:
17
+ name: Multiple Choice
18
+ type: multiple-choice
19
+ dataset:
20
+ name: SWAG
21
+ type: swag
22
+ args: regular
23
+ metrics:
24
+ - name: Accuracy
25
+ type: accuracy
26
+ value: 0.7521243691444397
27
+ ---
28
+
29
+ # swag_base
30
+
31
+ This model is a fine-tuned version of [FacebookAI/roberta-base](https://huggingface.co/FacebookAI/roberta-base) on the SWAG (Situations With Adversarial Generations) dataset.
32
+
33
+ ## Model description
34
+
35
+ The model is designed to perform multiple-choice reasoning about real-world situations. Given a context and four possible continuations, it predicts the most plausible ending based on common sense understanding.
36
+
37
+ Key Features:
38
+ - Base model: RoBERTa-base
39
+ - Task: Multiple Choice Prediction
40
+ - Training dataset: SWAG
41
+ - Performance: 75.21% accuracy on evaluation set
42
+
43
+ ## Training Procedure
44
+
45
+ ### Training hyperparameters
46
+ - Learning rate: 5e-05
47
+ - Batch size: 16
48
+ - Number of epochs: 3
49
+ - Optimizer: AdamW
50
+ - Learning rate scheduler: Linear
51
+ - Training samples: 73,546
52
+ - Training time: 17m 53s
53
+
54
+ ### Training Results
55
+ - Training loss: 0.73
56
+ - Evaluation loss: 0.7362
57
+ - Evaluation accuracy: 0.7521
58
+ - Training samples/second: 205.623
59
+ - Training steps/second: 12.852
60
+
61
+ ## Usage Example
62
+
63
+ Here's how to use the model:
64
+
65
+ ```python
66
+ from transformers import AutoTokenizer, AutoModelForMultipleChoice
67
+ import torch
68
+
69
+ # Load model and tokenizer
70
+ model_path = "real-jiakai/roberta-base-uncased-finetuned-swag"
71
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
72
+ model = AutoModelForMultipleChoice.from_pretrained(model_path)
73
+
74
+ # Example scenarios
75
+ test_examples = [
76
+ {
77
+ 'context': "Stephen Curry dribbles the ball at the three-point line",
78
+ 'endings': [
79
+ "He quickly releases a perfect shot that swishes through the net", # Most plausible
80
+ "He suddenly starts dancing ballet on the court",
81
+ "He transforms the basketball into a pizza",
82
+ "He flies to the moon with the basketball"
83
+ ]
84
+ },
85
+ {
86
+ 'context': "Elon Musk walks into a SpaceX facility and looks at a rocket",
87
+ 'endings': [
88
+ "He discusses technical details with the engineering team", # Most plausible
89
+ "He turns the rocket into a giant chocolate bar",
90
+ "He starts playing basketball with the rocket",
91
+ "He teaches the rocket to speak French"
92
+ ]
93
+ }
94
+ ]
95
+
96
+ def predict_swag(context, endings, model, tokenizer):
97
+ encoding = tokenizer(
98
+ [context] * 4,
99
+ endings,
100
+ truncation=True,
101
+ max_length=128,
102
+ padding="max_length",
103
+ return_tensors="pt"
104
+ )
105
+
106
+ input_ids = encoding['input_ids'].unsqueeze(0)
107
+ attention_mask = encoding['attention_mask'].unsqueeze(0)
108
+
109
+ outputs = model(input_ids=input_ids, attention_mask=attention_mask)
110
+ logits = outputs.logits
111
+
112
+ predicted_idx = torch.argmax(logits).item()
113
+
114
+ return {
115
+ 'context': context,
116
+ 'predicted_ending': endings[predicted_idx],
117
+ 'probabilities': torch.softmax(logits, dim=1)[0].tolist()
118
+ }
119
+ ```
120
+
121
+ ## Limitations and Biases
122
+
123
+ The model's performance is limited by its training data and may not generalize well to all domains
124
+ Performance might vary depending on the complexity and domain of the input scenarios
125
+ The model may exhibit biases present in the training data
126
+
127
+ ## Framework versions
128
+
129
+ Transformers 4.47.0.dev0
130
+ PyTorch 2.5.1+cu124
131
+ Datasets 3.1.0
132
+ Tokenizers 0.20.3
133
+
134
+ ## Citation
135
+
136
+ If you use this model, please cite:
137
+
138
+ ```
139
+ @inproceedings{zellers2018swagaf,
140
+ title={SWAG: A Large-Scale Adversarial Dataset for Grounded Commonsense Inference},
141
+ author={Zellers, Rowan and Bisk, Yonatan and Schwartz, Roy and Choi, Yejin},
142
+ booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing (EMNLP)",
143
+ year={2018}
144
+ }
145
+ ```
all_results.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 3.0,
3
+ "eval_accuracy": 0.7521243691444397,
4
+ "eval_loss": 0.7361685037612915,
5
+ "eval_runtime": 28.3884,
6
+ "eval_samples": 20006,
7
+ "eval_samples_per_second": 704.725,
8
+ "eval_steps_per_second": 44.067,
9
+ "total_flos": 2.508085260375571e+16,
10
+ "train_loss": 0.7300247143699852,
11
+ "train_runtime": 1073.0221,
12
+ "train_samples": 73546,
13
+ "train_samples_per_second": 205.623,
14
+ "train_steps_per_second": 12.852
15
+ }
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "FacebookAI/roberta-base",
3
+ "architectures": [
4
+ "RobertaForMultipleChoice"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 514,
17
+ "model_type": "roberta",
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "pad_token_id": 1,
21
+ "position_embedding_type": "absolute",
22
+ "torch_dtype": "float32",
23
+ "transformers_version": "4.47.0.dev0",
24
+ "type_vocab_size": 1,
25
+ "use_cache": true,
26
+ "vocab_size": 50265
27
+ }
eval_results.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 3.0,
3
+ "eval_accuracy": 0.7521243691444397,
4
+ "eval_loss": 0.7361685037612915,
5
+ "eval_runtime": 28.3884,
6
+ "eval_samples": 20006,
7
+ "eval_samples_per_second": 704.725,
8
+ "eval_steps_per_second": 44.067
9
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b639335e7e79363a1eb5ae188010faec74ac19c1f3fc70c6b41da563f6ac74a1
3
+ size 498609724
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
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
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "model_max_length": 512,
53
+ "pad_token": "<pad>",
54
+ "sep_token": "</s>",
55
+ "tokenizer_class": "RobertaTokenizer",
56
+ "trim_offsets": true,
57
+ "unk_token": "<unk>"
58
+ }
train_results.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 3.0,
3
+ "total_flos": 2.508085260375571e+16,
4
+ "train_loss": 0.7300247143699852,
5
+ "train_runtime": 1073.0221,
6
+ "train_samples": 73546,
7
+ "train_samples_per_second": 205.623,
8
+ "train_steps_per_second": 12.852
9
+ }
trainer_state.json ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 3.0,
5
+ "eval_steps": 500,
6
+ "global_step": 13791,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.10876658690450294,
13
+ "grad_norm": 7.74190092086792,
14
+ "learning_rate": 4.818722355159162e-05,
15
+ "loss": 1.3121,
16
+ "step": 500
17
+ },
18
+ {
19
+ "epoch": 0.2175331738090059,
20
+ "grad_norm": 21.71584129333496,
21
+ "learning_rate": 4.637444710318324e-05,
22
+ "loss": 1.1551,
23
+ "step": 1000
24
+ },
25
+ {
26
+ "epoch": 0.3262997607135088,
27
+ "grad_norm": 14.698501586914062,
28
+ "learning_rate": 4.4561670654774854e-05,
29
+ "loss": 1.0899,
30
+ "step": 1500
31
+ },
32
+ {
33
+ "epoch": 0.4350663476180118,
34
+ "grad_norm": 12.033799171447754,
35
+ "learning_rate": 4.2748894206366476e-05,
36
+ "loss": 1.054,
37
+ "step": 2000
38
+ },
39
+ {
40
+ "epoch": 0.5438329345225147,
41
+ "grad_norm": 8.601971626281738,
42
+ "learning_rate": 4.093611775795809e-05,
43
+ "loss": 1.015,
44
+ "step": 2500
45
+ },
46
+ {
47
+ "epoch": 0.6525995214270176,
48
+ "grad_norm": 12.497455596923828,
49
+ "learning_rate": 3.912334130954971e-05,
50
+ "loss": 0.9868,
51
+ "step": 3000
52
+ },
53
+ {
54
+ "epoch": 0.7613661083315205,
55
+ "grad_norm": 17.868608474731445,
56
+ "learning_rate": 3.731056486114133e-05,
57
+ "loss": 0.9785,
58
+ "step": 3500
59
+ },
60
+ {
61
+ "epoch": 0.8701326952360235,
62
+ "grad_norm": 9.991225242614746,
63
+ "learning_rate": 3.549778841273294e-05,
64
+ "loss": 0.9544,
65
+ "step": 4000
66
+ },
67
+ {
68
+ "epoch": 0.9788992821405265,
69
+ "grad_norm": 30.770978927612305,
70
+ "learning_rate": 3.368501196432456e-05,
71
+ "loss": 0.9245,
72
+ "step": 4500
73
+ },
74
+ {
75
+ "epoch": 1.0876658690450294,
76
+ "grad_norm": 23.796464920043945,
77
+ "learning_rate": 3.187223551591618e-05,
78
+ "loss": 0.7713,
79
+ "step": 5000
80
+ },
81
+ {
82
+ "epoch": 1.1964324559495323,
83
+ "grad_norm": 24.789031982421875,
84
+ "learning_rate": 3.0059459067507794e-05,
85
+ "loss": 0.7294,
86
+ "step": 5500
87
+ },
88
+ {
89
+ "epoch": 1.3051990428540352,
90
+ "grad_norm": 18.538000106811523,
91
+ "learning_rate": 2.8246682619099413e-05,
92
+ "loss": 0.7132,
93
+ "step": 6000
94
+ },
95
+ {
96
+ "epoch": 1.4139656297585381,
97
+ "grad_norm": 15.591426849365234,
98
+ "learning_rate": 2.643390617069103e-05,
99
+ "loss": 0.7076,
100
+ "step": 6500
101
+ },
102
+ {
103
+ "epoch": 1.5227322166630413,
104
+ "grad_norm": 22.807159423828125,
105
+ "learning_rate": 2.462112972228265e-05,
106
+ "loss": 0.7153,
107
+ "step": 7000
108
+ },
109
+ {
110
+ "epoch": 1.6314988035675442,
111
+ "grad_norm": 11.409658432006836,
112
+ "learning_rate": 2.2808353273874268e-05,
113
+ "loss": 0.6954,
114
+ "step": 7500
115
+ },
116
+ {
117
+ "epoch": 1.740265390472047,
118
+ "grad_norm": 20.154701232910156,
119
+ "learning_rate": 2.0995576825465886e-05,
120
+ "loss": 0.707,
121
+ "step": 8000
122
+ },
123
+ {
124
+ "epoch": 1.84903197737655,
125
+ "grad_norm": 17.02855110168457,
126
+ "learning_rate": 1.91828003770575e-05,
127
+ "loss": 0.6715,
128
+ "step": 8500
129
+ },
130
+ {
131
+ "epoch": 1.957798564281053,
132
+ "grad_norm": 19.347368240356445,
133
+ "learning_rate": 1.737002392864912e-05,
134
+ "loss": 0.6609,
135
+ "step": 9000
136
+ },
137
+ {
138
+ "epoch": 2.066565151185556,
139
+ "grad_norm": 18.68759536743164,
140
+ "learning_rate": 1.5557247480240738e-05,
141
+ "loss": 0.5354,
142
+ "step": 9500
143
+ },
144
+ {
145
+ "epoch": 2.1753317380900588,
146
+ "grad_norm": 15.24686050415039,
147
+ "learning_rate": 1.3744471031832355e-05,
148
+ "loss": 0.4594,
149
+ "step": 10000
150
+ },
151
+ {
152
+ "epoch": 2.2840983249945617,
153
+ "grad_norm": 32.36734390258789,
154
+ "learning_rate": 1.1931694583423973e-05,
155
+ "loss": 0.453,
156
+ "step": 10500
157
+ },
158
+ {
159
+ "epoch": 2.3928649118990646,
160
+ "grad_norm": 19.55815315246582,
161
+ "learning_rate": 1.011891813501559e-05,
162
+ "loss": 0.4465,
163
+ "step": 11000
164
+ },
165
+ {
166
+ "epoch": 2.5016314988035675,
167
+ "grad_norm": 16.438173294067383,
168
+ "learning_rate": 8.306141686607208e-06,
169
+ "loss": 0.4226,
170
+ "step": 11500
171
+ },
172
+ {
173
+ "epoch": 2.6103980857080704,
174
+ "grad_norm": 21.047183990478516,
175
+ "learning_rate": 6.493365238198826e-06,
176
+ "loss": 0.4324,
177
+ "step": 12000
178
+ },
179
+ {
180
+ "epoch": 2.7191646726125733,
181
+ "grad_norm": 29.30052947998047,
182
+ "learning_rate": 4.680588789790443e-06,
183
+ "loss": 0.4306,
184
+ "step": 12500
185
+ },
186
+ {
187
+ "epoch": 2.8279312595170762,
188
+ "grad_norm": 7.3705010414123535,
189
+ "learning_rate": 2.8678123413820606e-06,
190
+ "loss": 0.4371,
191
+ "step": 13000
192
+ },
193
+ {
194
+ "epoch": 2.936697846421579,
195
+ "grad_norm": 24.24944305419922,
196
+ "learning_rate": 1.0550358929736786e-06,
197
+ "loss": 0.4305,
198
+ "step": 13500
199
+ },
200
+ {
201
+ "epoch": 3.0,
202
+ "step": 13791,
203
+ "total_flos": 2.508085260375571e+16,
204
+ "train_loss": 0.7300247143699852,
205
+ "train_runtime": 1073.0221,
206
+ "train_samples_per_second": 205.623,
207
+ "train_steps_per_second": 12.852
208
+ }
209
+ ],
210
+ "logging_steps": 500,
211
+ "max_steps": 13791,
212
+ "num_input_tokens_seen": 0,
213
+ "num_train_epochs": 3,
214
+ "save_steps": 500,
215
+ "stateful_callbacks": {
216
+ "TrainerControl": {
217
+ "args": {
218
+ "should_epoch_stop": false,
219
+ "should_evaluate": false,
220
+ "should_log": false,
221
+ "should_save": true,
222
+ "should_training_stop": true
223
+ },
224
+ "attributes": {}
225
+ }
226
+ },
227
+ "total_flos": 2.508085260375571e+16,
228
+ "train_batch_size": 16,
229
+ "trial_name": null,
230
+ "trial_params": null
231
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83eb56997ccc18225206b4b840525474985d7de9254a3d04681d437858b94051
3
+ size 5304
vocab.json ADDED
The diff for this file is too large to render. See raw diff