kiddothe2b
commited on
Commit
·
75e9b16
1
Parent(s):
6860c1c
Initial commit
Browse files- README.md +113 -0
- all_results.json +13 -0
- config.json +44 -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,116 @@
|
|
| 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-mini-1024
|
| 11 |
+
results: []
|
| 12 |
---
|
| 13 |
+
|
| 14 |
+
# Longformer / longformer-mini-1024
|
| 15 |
+
|
| 16 |
+
## Model description
|
| 17 |
+
|
| 18 |
+
[Longformer](https://arxiv.org/abs/2004.05150) is a transformer model for long documents. This version of Longformer is 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 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.
|
| 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-mini-1024', 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-mini-1024", trust_remote_code=True)
|
| 47 |
+
doc_classifier = AutoModelforSequenceClassification(model='kiddothe2b/longformer-mini-1024', 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: 32
|
| 68 |
+
- eval_batch_size: 32
|
| 69 |
+
- seed: 42
|
| 70 |
+
- gradient_accumulation_steps: 4
|
| 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 |
+
```
|
| 116 |
+
|
all_results.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 1.14,
|
| 3 |
+
"eval_accuracy": 0.5881730101414021,
|
| 4 |
+
"eval_loss": 2.206639528274536,
|
| 5 |
+
"eval_runtime": 4720.0655,
|
| 6 |
+
"eval_samples_per_second": 105.931,
|
| 7 |
+
"eval_steps_per_second": 3.31,
|
| 8 |
+
"perplexity": 9.08513469908241,
|
| 9 |
+
"train_loss": 2.444826105957031,
|
| 10 |
+
"train_runtime": 111349.358,
|
| 11 |
+
"train_samples_per_second": 57.477,
|
| 12 |
+
"train_steps_per_second": 0.449
|
| 13 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "kiddothe2b/longformer-mini-1024",
|
| 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 |
+
],
|
| 16 |
+
"bos_token_id": null,
|
| 17 |
+
"classifier_dropout": null,
|
| 18 |
+
"cls_token_id": 101,
|
| 19 |
+
"eos_token_id": null,
|
| 20 |
+
"gradient_checkpointing": false,
|
| 21 |
+
"hidden_act": "gelu",
|
| 22 |
+
"hidden_dropout_prob": 0.1,
|
| 23 |
+
"hidden_size": 256,
|
| 24 |
+
"ignore_attention_mask": false,
|
| 25 |
+
"initializer_range": 0.02,
|
| 26 |
+
"intermediate_size": 1024,
|
| 27 |
+
"layer_norm_eps": 1e-05,
|
| 28 |
+
"max_position_embeddings": 1026,
|
| 29 |
+
"max_sentence_length": 128,
|
| 30 |
+
"max_sentence_size": 128,
|
| 31 |
+
"max_sentences": 8,
|
| 32 |
+
"model_max_length": 1024,
|
| 33 |
+
"model_type": "longformer",
|
| 34 |
+
"num_attention_heads": 4,
|
| 35 |
+
"num_hidden_layers": 6,
|
| 36 |
+
"pad_token_id": 0,
|
| 37 |
+
"position_embedding_type": "absolute",
|
| 38 |
+
"sep_token_id": 102,
|
| 39 |
+
"torch_dtype": "float32",
|
| 40 |
+
"transformers_version": "4.18.0",
|
| 41 |
+
"type_vocab_size": 2,
|
| 42 |
+
"use_cache": true,
|
| 43 |
+
"vocab_size": 30522
|
| 44 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cedb7eb8d017b78e84502a37013d0a7d7864f0c95a7b3bbe74758fbbf627522a
|
| 3 |
+
size 56444323
|
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/longformer", "do_basic_tokenize": true, "never_split": null, "tokenizer_class": "BertTokenizer"}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|