kiddothe2b
commited on
Commit
•
eff95de
1
Parent(s):
2f94107
Initial commit
Browse files- README.md +112 -0
- all_results.json +13 -0
- config.json +50 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- vocab.json +0 -0
README.md
CHANGED
@@ -1,3 +1,115 @@
|
|
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 |
+
datasets:
|
8 |
+
- c4
|
9 |
+
model-index:
|
10 |
+
- name: kiddothe2b/longformer-base-4096
|
11 |
+
results: []
|
12 |
---
|
13 |
+
|
14 |
+
# Longformer / longformer-base-4096
|
15 |
+
|
16 |
+
## Model description
|
17 |
+
|
18 |
+
[Longformer](https://arxiv.org/abs/2004.05150) is a transformer model for long documents. This version of Longformer presented in [An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification (Chalkidis et al., 2022)](https://arxiv.org/abs/xxx).
|
19 |
+
|
20 |
+
The model has been warm-started re-using the weights of RoBERTa (Liu et al., 2019), and continued pre-trained for MLM in long sequences following the paradigm of original Longformer released by Beltagy et al. (2020). It supports sequences of length up to 4,096.
|
21 |
+
|
22 |
+
Longformer uses a combination of a sliding window (local) attention and global attention. Global attention is user-configured based on the task to allow the model to learn task-specific representations.
|
23 |
+
|
24 |
+
## Intended uses & limitations
|
25 |
+
|
26 |
+
You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task.
|
27 |
+
See the [model hub](https://huggingface.co/models?filter=longformer) to look for fine-tuned versions on a task that
|
28 |
+
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/longformer-base-4096', 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/longformer-base-4096", trust_remote_code=True)
|
47 |
+
doc_classifier = AutoModelforSequenceClassification(model='kiddothe2b/longformer-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 [roberta-base](https://huggingface.co/roberta-base) checkpoint and has been continued pre-trained for additional 50k steps in long sequences (> 1024 subwords) of [C4](https://huggingface.co/datasets/c4) (Raffel et al., 2020).
|
61 |
+
|
62 |
+
|
63 |
+
### Training hyperparameters
|
64 |
+
|
65 |
+
TThe following hyperparameters were used during training:
|
66 |
+
- learning_rate: 0.0001
|
67 |
+
- train_batch_size: 16
|
68 |
+
- eval_batch_size: 16
|
69 |
+
- seed: 42
|
70 |
+
- gradient_accumulation_steps: 8
|
71 |
+
- total_train_batch_size: 128
|
72 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
73 |
+
- lr_scheduler_type: linear
|
74 |
+
- lr_scheduler_warmup_ratio: 0.1
|
75 |
+
- training_steps: 50000
|
76 |
+
|
77 |
+
### Training results
|
78 |
+
|
79 |
+
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|
80 |
+
|:-------------:|:-----:|:-----:|:---------------:|:--------:|
|
81 |
+
| 1.7067 | 0.2 | 10000 | 1.5923 | 0.6714 |
|
82 |
+
| 1.6532 | 0.4 | 20000 | 1.5494 | 0.6784 |
|
83 |
+
| 1.622 | 0.6 | 30000 | 1.5208 | 0.6830 |
|
84 |
+
| 1.588 | 0.8 | 40000 | 1.4880 | 0.6876 |
|
85 |
+
| 1.5682 | 1.0 | 50000 | 1.4680 | 0.6908 |
|
86 |
+
|
87 |
+
|
88 |
+
### Framework versions
|
89 |
+
|
90 |
+
- Transformers 4.19.0.dev0
|
91 |
+
- Pytorch 1.11.0
|
92 |
+
- Datasets 2.0.0
|
93 |
+
- Tokenizers 0.11.6
|
94 |
+
|
95 |
+
|
96 |
+
## Citing
|
97 |
+
|
98 |
+
If you use this Longformer model in your research, please cite [An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification](https://arxiv.org/abs/xxx), alongside [Longformer: The Long-Document Transformer](https://arxiv.org/abs/2004.05150).
|
99 |
+
|
100 |
+
```
|
101 |
+
@misc{chalkidis-etal-2022-hat,
|
102 |
+
url = {https://arxiv.org/abs/xxx},
|
103 |
+
author = {Chalkidis, Ilias and Dai, Xiang and Fergadiotis, Manos and Malakasiotis, Prodromos and Elliott, Desmond},
|
104 |
+
title = {An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification},
|
105 |
+
publisher = {arXiv},
|
106 |
+
year = {2022},
|
107 |
+
}
|
108 |
+
|
109 |
+
@article{Beltagy2020Longformer,
|
110 |
+
title={Longformer: The Long-Document Transformer},
|
111 |
+
author={Iz Beltagy and Matthew E. Peters and Arman Cohan},
|
112 |
+
journal={arXiv:2004.05150},
|
113 |
+
year={2020},
|
114 |
+
}
|
115 |
+
```
|
all_results.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"epoch": 1.0,
|
3 |
+
"eval_accuracy": 0.6903300106062856,
|
4 |
+
"eval_loss": 1.4704546928405762,
|
5 |
+
"eval_runtime": 564.333,
|
6 |
+
"eval_samples_per_second": 39.987,
|
7 |
+
"eval_steps_per_second": 2.5,
|
8 |
+
"perplexity": 4.351213156804084,
|
9 |
+
"train_loss": 1.6453681225585937,
|
10 |
+
"train_runtime": 632283.9895,
|
11 |
+
"train_samples_per_second": 10.122,
|
12 |
+
"train_steps_per_second": 0.079
|
13 |
+
}
|
config.json
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "data/PLMs/longformer-roberta",
|
3 |
+
"architectures": [
|
4 |
+
"LongformerForMaskedLM"
|
5 |
+
],
|
6 |
+
"attention_mode": "longformer",
|
7 |
+
"attention_probs_dropout_prob": 0.1,
|
8 |
+
"attention_window": [
|
9 |
+
128,
|
10 |
+
128,
|
11 |
+
128,
|
12 |
+
128,
|
13 |
+
128,
|
14 |
+
128,
|
15 |
+
128,
|
16 |
+
128,
|
17 |
+
128,
|
18 |
+
128,
|
19 |
+
128,
|
20 |
+
128
|
21 |
+
],
|
22 |
+
"bos_token_id": 0,
|
23 |
+
"classifier_dropout": null,
|
24 |
+
"cls_token_id": 0,
|
25 |
+
"eos_token_id": 2,
|
26 |
+
"gradient_checkpointing": false,
|
27 |
+
"hidden_act": "gelu",
|
28 |
+
"hidden_dropout_prob": 0.1,
|
29 |
+
"hidden_size": 768,
|
30 |
+
"ignore_attention_mask": false,
|
31 |
+
"initializer_range": 0.02,
|
32 |
+
"intermediate_size": 3072,
|
33 |
+
"layer_norm_eps": 1e-05,
|
34 |
+
"max_position_embeddings": 4099,
|
35 |
+
"max_sentence_length": 128,
|
36 |
+
"max_sentence_size": 128,
|
37 |
+
"max_sentences": 8,
|
38 |
+
"model_max_length": 4096,
|
39 |
+
"model_type": "longformer",
|
40 |
+
"num_attention_heads": 12,
|
41 |
+
"num_hidden_layers": 12,
|
42 |
+
"pad_token_id": 1,
|
43 |
+
"position_embedding_type": "absolute",
|
44 |
+
"sep_token_id": 2,
|
45 |
+
"torch_dtype": "float32",
|
46 |
+
"transformers_version": "4.18.0",
|
47 |
+
"type_vocab_size": 1,
|
48 |
+
"use_cache": true,
|
49 |
+
"vocab_size": 50265
|
50 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ce54d882e182fd7285ffc4741798c41ac8a235bd319a77a93ef2e0e4ff3f970b
|
3 |
+
size 594974811
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"errors": "replace", "bos_token": "<s>", "eos_token": "</s>", "sep_token": "</s>", "cls_token": "<s>", "unk_token": "<unk>", "pad_token": "<pad>", "mask_token": "<mask>", "add_prefix_space": false, "trim_offsets": true, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "data/PLMs/longformer-roberta", "tokenizer_class": "RobertaTokenizer"}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|