kiddothe2b
commited on
Commit
•
c2ba13f
1
Parent(s):
6f209a9
Initial commit
Browse files- README.md +110 -0
- all_results.json +12 -0
- config.json +79 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
README.md
CHANGED
@@ -1,3 +1,113 @@
|
|
1 |
---
|
2 |
license: cc-by-nc-sa-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-nc-sa-4.0
|
3 |
+
pipeline_tag: fill-mask
|
4 |
+
language: en
|
5 |
+
tags:
|
6 |
+
- long_documents
|
7 |
+
- hierarchical_transformers
|
8 |
+
datasets:
|
9 |
+
- wikipedia
|
10 |
+
model-index:
|
11 |
+
- name: kiddothe2b/hat-mini-1024-I2
|
12 |
+
results: []
|
13 |
---
|
14 |
+
|
15 |
+
# Hierarchical Attention Transformer (HAT) / hat-mini-1024-I2
|
16 |
+
|
17 |
+
## Model description
|
18 |
+
|
19 |
+
This is a Hierarchical Attention Transformer (HAT) model as presented in [An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification (Chalkidis et al., 2022)](https://arxiv.org/abs/xxx).
|
20 |
+
|
21 |
+
The model has been warm-started re-using the weights of miniature BERT [(Turc et al., 2019)](https://arxiv.org/abs/1908.08962), and continued pre-trained for MLM following the paradigm of Longformer released by [Beltagy et al. (2020)](](https://arxiv.org/abs/1908.08962)). It supports sequences of length up to 1,024.
|
22 |
+
|
23 |
+
HAT use a hierarchical attention, which is a combination of segment-wise and cross-segment attention operations. You can think segments as paragraphs or sentences.
|
24 |
+
|
25 |
+
## Intended uses & limitations
|
26 |
+
|
27 |
+
You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task.
|
28 |
+
See the [model hub](https://huggingface.co/models?other=hierarchical-transformer) to look for fine-tuned versions on a task that interests you.
|
29 |
+
|
30 |
+
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole document to make decisions, such as document classification, sequential sentence classification or question answering.
|
31 |
+
|
32 |
+
## How to use
|
33 |
+
|
34 |
+
You can use this model directly with a pipeline for masked language modeling:
|
35 |
+
|
36 |
+
```python
|
37 |
+
from transformers import pipeline
|
38 |
+
mlm_model = pipeline('fill-mask', model='kiddothe2b/hat-mini-1024-I1', trust_remote_code=True)
|
39 |
+
mlm_model("Hello I'm a <mask> model.")
|
40 |
+
```
|
41 |
+
|
42 |
+
You can also fine-tun it for SequenceClassification, SequentialSentenceClassification, and MultipleChoice down-stream tasks:
|
43 |
+
|
44 |
+
```python
|
45 |
+
from transformers import AutoTokenizer, AutoModelforSequenceClassification
|
46 |
+
tokenizer = AutoTokenizer.from_pretrained("kiddothe2b/hat-mini-1024-I1", trust_remote_code=True)
|
47 |
+
doc_classifier = AutoModelforSequenceClassification(model='kiddothe2b/hat-base-4096', trust_remote_code=True)
|
48 |
+
```
|
49 |
+
|
50 |
+
## Limitations and bias
|
51 |
+
|
52 |
+
The training data used for this model contains a lot of unfiltered content from the internet, which is far from
|
53 |
+
neutral. Therefore, the model can have biased predictions.
|
54 |
+
|
55 |
+
|
56 |
+
## Training procedure
|
57 |
+
|
58 |
+
### Training and evaluation data
|
59 |
+
|
60 |
+
The model has been warm-started from [google/bert_uncased_L-6_H-256_A-4](https://huggingface.co/google/bert_uncased_L-6_H-256_A-4) checkpoint and has been continued pre-trained for additional 50k steps on English [Wikipedia](https://huggingface.co/datasets/wikipedia).
|
61 |
+
|
62 |
+
|
63 |
+
### Training hyperparameters
|
64 |
+
|
65 |
+
The following hyperparameters were used during training:
|
66 |
+
- learning_rate: 0.0001
|
67 |
+
- train_batch_size: 4
|
68 |
+
- eval_batch_size: 4
|
69 |
+
- seed: 42
|
70 |
+
- distributed_type: tpu
|
71 |
+
- num_devices: 8
|
72 |
+
- gradient_accumulation_steps: 4
|
73 |
+
- total_train_batch_size: 128
|
74 |
+
- total_eval_batch_size: 32
|
75 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
76 |
+
- lr_scheduler_type: linear
|
77 |
+
- lr_scheduler_warmup_ratio: 0.1
|
78 |
+
- training_steps: 50000
|
79 |
+
|
80 |
+
|
81 |
+
### Training results
|
82 |
+
|
83 |
+
| Training Loss | Epoch | Step | Validation Loss |
|
84 |
+
|:-------------:|:-----:|:-----:|:---------------:|
|
85 |
+
| 2.7353 | 0.2 | 10000 | 2.5067 |
|
86 |
+
| 2.6081 | 0.4 | 20000 | 2.3966 |
|
87 |
+
| 2.5552 | 0.6 | 30000 | 2.3446 |
|
88 |
+
| 2.5105 | 0.8 | 40000 | 2.3117 |
|
89 |
+
| 2.4978 | 1.14 | 50000 | 2.2954 |
|
90 |
+
|
91 |
+
|
92 |
+
### Framework versions
|
93 |
+
|
94 |
+
- Transformers 4.19.0.dev0
|
95 |
+
- Pytorch 1.11.0+cu102
|
96 |
+
- Datasets 2.0.0
|
97 |
+
- Tokenizers 0.11.6
|
98 |
+
|
99 |
+
|
100 |
+
##Citing
|
101 |
+
If you use HAT in your research, please cite [An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification](https://arxiv.org/abs/xxx)
|
102 |
+
|
103 |
+
```
|
104 |
+
@misc{chalkidis-etal-2022-hat,
|
105 |
+
url = {https://arxiv.org/abs/xxx},
|
106 |
+
author = {Chalkidis, Ilias and Dai, Xiang and Fergadiotis, Manos and Malakasiotis, Prodromos and Elliott, Desmond},
|
107 |
+
title = {An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification},
|
108 |
+
publisher = {arXiv},
|
109 |
+
year = {2022},
|
110 |
+
}
|
111 |
+
```
|
112 |
+
|
113 |
+
|
all_results.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"epoch": 1.14,
|
3 |
+
"eval_loss": 2.2956442832946777,
|
4 |
+
"eval_runtime": 3135.1617,
|
5 |
+
"eval_samples_per_second": 159.481,
|
6 |
+
"eval_steps_per_second": 4.984,
|
7 |
+
"perplexity": 9.930832220881081,
|
8 |
+
"train_loss": 2.669982685546875,
|
9 |
+
"train_runtime": 65951.2344,
|
10 |
+
"train_samples_per_second": 97.041,
|
11 |
+
"train_steps_per_second": 0.758
|
12 |
+
}
|
config.json
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "kiddothe2b/hat-mini-1024-I2",
|
3 |
+
"architectures": [
|
4 |
+
"HATForMaskedLM"
|
5 |
+
],
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "configuration_hat.HATConfig",
|
8 |
+
"AutoTokenizer": "tokenization_hat.HATTokenizer",
|
9 |
+
"AutoModel": "modelling_hat.HATModel",
|
10 |
+
"AutoModelForMaskedLM": "modelling_hat.HATForMaskedLM",
|
11 |
+
"AutoModelForMultipleChoice": "modelling_hat.HATForMultipleChoice",
|
12 |
+
"AutoModelForQuestionAnswering": "modelling_hat.HATForQuestionAnswering",
|
13 |
+
"AutoModelForSequenceClassification": "modelling_hat.HATForSequenceClassification",
|
14 |
+
"AutoModelForTokenClassification": "modelling_hat.HATForTokenClassification"
|
15 |
+
},
|
16 |
+
"attention_probs_dropout_prob": 0.1,
|
17 |
+
"classifier_dropout": null,
|
18 |
+
"encoder_layout": {
|
19 |
+
"0": {
|
20 |
+
"document_encoder": false,
|
21 |
+
"sentence_encoder": true
|
22 |
+
},
|
23 |
+
"1": {
|
24 |
+
"document_encoder": true,
|
25 |
+
"sentence_encoder": true
|
26 |
+
},
|
27 |
+
"2": {
|
28 |
+
"document_encoder": true,
|
29 |
+
"sentence_encoder": false
|
30 |
+
},
|
31 |
+
"3": {
|
32 |
+
"document_encoder": false,
|
33 |
+
"sentence_encoder": true
|
34 |
+
},
|
35 |
+
"4": {
|
36 |
+
"document_encoder": true,
|
37 |
+
"sentence_encoder": true
|
38 |
+
},
|
39 |
+
"5": {
|
40 |
+
"document_encoder": true,
|
41 |
+
"sentence_encoder": false
|
42 |
+
},
|
43 |
+
"6": {
|
44 |
+
"document_encoder": false,
|
45 |
+
"sentence_encoder": true
|
46 |
+
},
|
47 |
+
"7": {
|
48 |
+
"document_encoder": true,
|
49 |
+
"sentence_encoder": true
|
50 |
+
},
|
51 |
+
"8": {
|
52 |
+
"document_encoder": true,
|
53 |
+
"sentence_encoder": false
|
54 |
+
}
|
55 |
+
},
|
56 |
+
"hidden_act": "gelu",
|
57 |
+
"hidden_dropout_prob": 0.1,
|
58 |
+
"hidden_size": 256,
|
59 |
+
"initializer_range": 0.02,
|
60 |
+
"intermediate_size": 1024,
|
61 |
+
"layer_norm_eps": 1e-12,
|
62 |
+
"max_position_embeddings": 128,
|
63 |
+
"max_sentence_length": 128,
|
64 |
+
"max_sentence_size": 128,
|
65 |
+
"max_sentences": 8,
|
66 |
+
"model_max_length": 1024,
|
67 |
+
"model_type": "hierarchical-transformer",
|
68 |
+
"num_attention_heads": 4,
|
69 |
+
"num_hidden_layers": 9,
|
70 |
+
"output_past": true,
|
71 |
+
"pad_token_id": 0,
|
72 |
+
"parameters": 136350720,
|
73 |
+
"position_embedding_type": "absolute",
|
74 |
+
"torch_dtype": "float32",
|
75 |
+
"transformers_version": "4.19.0.dev0",
|
76 |
+
"type_vocab_size": 2,
|
77 |
+
"use_cache": true,
|
78 |
+
"vocab_size": 30522
|
79 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9846499976ce5546ddcadf89828a6d5199eb731aba25a56fba46bd702958e5a7
|
3 |
+
size 101198747
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 1024, "special_tokens_map_file": null, "name_or_path": "data/PLMs/hi-transformer-s2-grouped", "do_basic_tokenize": true, "never_split": null, "tokenizer_class": "BertTokenizer", "auto_map": {"AutoTokenizer": ["tokenization_hat.HATTokenizer", "tokenization_hat.HATTokenizer"]}}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|