初始化项目,由ModelHub XC社区提供模型
Model: sadia72/gpt2-shakespeare Source: Original Platform
This commit is contained in:
34
.gitattributes
vendored
Normal file
34
.gitattributes
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
checkpoint-*/
|
||||||
112
README.md
Normal file
112
README.md
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
---
|
||||||
|
license: mit
|
||||||
|
tags:
|
||||||
|
- generated_from_trainer
|
||||||
|
model-index:
|
||||||
|
- name: gpt2-shakespeare
|
||||||
|
results: []
|
||||||
|
pipeline_tag: text-generation
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
||||||
|
should probably proofread and complete it, then remove this comment. -->
|
||||||
|
|
||||||
|
# gpt2-shakespeare
|
||||||
|
|
||||||
|
This model is a fine-tuned version of [gpt2](https://huggingface.co/gpt2) on [datasets](https://github.com/sadia-sust/dataset-finetune-gpt2) containing Shakespeare Books.
|
||||||
|
It achieves the following results on the evaluation set:
|
||||||
|
- Loss: 2.5738
|
||||||
|
|
||||||
|
## Model description
|
||||||
|
|
||||||
|
GPT-2 model is finetuned with text corpus.
|
||||||
|
|
||||||
|
## Intended uses & limitations
|
||||||
|
|
||||||
|
Intended use for this model is to write novel in Shakespeare Style. It has limitations to write in other writer's style.
|
||||||
|
|
||||||
|
## Datasets Description
|
||||||
|
|
||||||
|
Text corpus is developed for fine-tuning gpt-2 model. Books are downloaded from [Project Gutenberg](http://www.gutenberg.org/) as plain text files.
|
||||||
|
A large text corpus were needed to train the model to be abled to write in Shakespeare style.
|
||||||
|
|
||||||
|
|
||||||
|
The following books are used to develop text corpus:
|
||||||
|
|
||||||
|
- Macbeth, word count: 38197
|
||||||
|
- THE TRAGEDY OF TITUS ANDRONICUS, word count: 40413
|
||||||
|
- King Richard II, word count: 48423
|
||||||
|
- Shakespeare's Tragedy of Romeo and Juliet, word count: 144935
|
||||||
|
- A MIDSUMMER NIGHT’S DREAM, word count: 36597
|
||||||
|
- ALL’S WELL THAT ENDS WELL, word count: 49363
|
||||||
|
- THE TRAGEDY OF HAMLET, PRINCE OF DENMARK, word count: 57471
|
||||||
|
- THE TRAGEDY OF JULIUS CAESAR, word count: 37391
|
||||||
|
- THE TRAGEDY OF KING LEAR, word count: 54101
|
||||||
|
- THE LIFE AND DEATH OF KING RICHARD III, word count: 55985
|
||||||
|
- Romeo and Juliet, word count: 51417
|
||||||
|
- Measure for Measure, word count: 62703
|
||||||
|
- Much Ado about Nothing, word count: 45577
|
||||||
|
- Othello, the Moor of Venice, word count: 53967
|
||||||
|
- THE WINTER’S TALE, word count: 52911
|
||||||
|
- The Comedy of Errors, word count: 43179
|
||||||
|
- The Merchant of Venice, word count: 45903
|
||||||
|
- The Taming of the Shrew, word count: 44777
|
||||||
|
- The Tempest, word count: 32323
|
||||||
|
- TWELFTH NIGHT: OR, WHAT YOU WILL, word count: 42907
|
||||||
|
- The Sonnets, word count: 39849
|
||||||
|
|
||||||
|
Corpus has total 1078389 word tokens.
|
||||||
|
|
||||||
|
## Datasets Preprocessing
|
||||||
|
|
||||||
|
- Header text are removed manually.
|
||||||
|
- Using sent_tokenize() function from NLTK python library, extra spaces and new-lines were removed programmatically.
|
||||||
|
|
||||||
|
|
||||||
|
## Training and evaluation data
|
||||||
|
|
||||||
|
Training dataset has 880447 word tokens and test dataset has 197913 word tokens.
|
||||||
|
|
||||||
|
## Training procedure
|
||||||
|
|
||||||
|
To train the model, training api from Transformer class is used.
|
||||||
|
|
||||||
|
### Training hyperparameters
|
||||||
|
|
||||||
|
The following hyperparameters were used during training:
|
||||||
|
- learning_rate: 5e-05
|
||||||
|
- train_batch_size: 32
|
||||||
|
- eval_batch_size: 64
|
||||||
|
- seed: 42
|
||||||
|
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
||||||
|
- lr_scheduler_type: linear
|
||||||
|
- lr_scheduler_warmup_steps: 350
|
||||||
|
- num_epochs: 3
|
||||||
|
|
||||||
|
### Training results
|
||||||
|
|
||||||
|
| Training Loss | Epoch | Step | Validation Loss |
|
||||||
|
|:-------------:|:-----:|:----:|:---------------:|
|
||||||
|
| No log | 0.63 | 250 | 2.7133 |
|
||||||
|
| 2.8492 | 1.25 | 500 | 2.6239 |
|
||||||
|
| 2.8492 | 1.88 | 750 | 2.5851 |
|
||||||
|
| 2.3842 | 2.51 | 1000 | 2.5738 |
|
||||||
|
|
||||||
|
|
||||||
|
## Sample Code Using Transformers Pipeline
|
||||||
|
|
||||||
|
```
|
||||||
|
from transformers import pipeline
|
||||||
|
|
||||||
|
story = pipeline('text-generation',model='./gpt2-shakespeare', tokenizer='gpt2', max_length = 300)
|
||||||
|
story("how art thou")
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Framework versions
|
||||||
|
|
||||||
|
- Transformers 4.26.1
|
||||||
|
- Pytorch 1.13.1+cu116
|
||||||
|
- Datasets 2.10.0
|
||||||
|
- Tokenizers 0.13.2
|
||||||
39
config.json
Normal file
39
config.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"_name_or_path": "gpt2",
|
||||||
|
"activation_function": "gelu_new",
|
||||||
|
"architectures": [
|
||||||
|
"GPT2LMHeadModel"
|
||||||
|
],
|
||||||
|
"attn_pdrop": 0.1,
|
||||||
|
"bos_token_id": 50256,
|
||||||
|
"embd_pdrop": 0.1,
|
||||||
|
"eos_token_id": 50256,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"layer_norm_epsilon": 1e-05,
|
||||||
|
"model_type": "gpt2",
|
||||||
|
"n_ctx": 1024,
|
||||||
|
"n_embd": 768,
|
||||||
|
"n_head": 12,
|
||||||
|
"n_inner": null,
|
||||||
|
"n_layer": 12,
|
||||||
|
"n_positions": 1024,
|
||||||
|
"reorder_and_upcast_attn": false,
|
||||||
|
"resid_pdrop": 0.1,
|
||||||
|
"scale_attn_by_inverse_layer_idx": false,
|
||||||
|
"scale_attn_weights": true,
|
||||||
|
"summary_activation": null,
|
||||||
|
"summary_first_dropout": 0.1,
|
||||||
|
"summary_proj_to_labels": true,
|
||||||
|
"summary_type": "cls_index",
|
||||||
|
"summary_use_proj": true,
|
||||||
|
"task_specific_params": {
|
||||||
|
"text-generation": {
|
||||||
|
"do_sample": true,
|
||||||
|
"max_length": 50
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"torch_dtype": "float32",
|
||||||
|
"transformers_version": "4.26.1",
|
||||||
|
"use_cache": true,
|
||||||
|
"vocab_size": 50257
|
||||||
|
}
|
||||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"_from_model_config": true,
|
||||||
|
"bos_token_id": 50256,
|
||||||
|
"eos_token_id": 50256,
|
||||||
|
"transformers_version": "4.26.1"
|
||||||
|
}
|
||||||
50001
merges.txt
Normal file
50001
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:29bc9713a99a2f07d33ca5a2a69c93badbdbd744002ba299e508cc4ebcd3f538
|
||||||
|
size 510398013
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:3f106cd61df63583e454d0217137495951f031490dfd28c07ab4fc0216682613
|
||||||
|
size 5667
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:a9d5f29edd0e7f1f70115ba7ef9b14ebce8f457985612f1292c84c1a9757f21d
|
||||||
|
size 4401
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:b7b6e8742cb313835b52df0e9647d9fdf62480ad2d38a0758c610896bb43960e
|
||||||
|
size 5670
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:228afc367e05db6f0d87718d3125516b9091b7b75a3ac2b151394a71b8060d6a
|
||||||
|
size 5910
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:980382bbebe01122548c7f12d04c249a45c0a3801ea8ee9da6b16ecbe5fb7ed5
|
||||||
|
size 5670
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:54abb57aa5bed7b785c2b7edae3c201cefe76018ee2c7ed0f4dc34c952744c2d
|
||||||
|
size 12771
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e68e862028452052e4b1162ca566594606f205f96c5e02ab7ce94c084a3e064a
|
||||||
|
size 5670
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:b048dc98026b53565fec7cac457a85ce19f4f99772537a9b756410fbc9c1d12e
|
||||||
|
size 6544
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:da2cc2298084936d42b8ace18bc03ed8948ee42a55a10a69f011c1f0173dc496
|
||||||
|
size 5670
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:9ceef2fa95902ebdae7dee8386bfe3f411ddaf1ba9a984210fae08e651bfbba5
|
||||||
|
size 5670
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:5caf2ef2fce5195b21dcd7dcd7eb2eca70ced1b1d3ea298270f896f2e74a6a92
|
||||||
|
size 8088
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:46b36367f777f6e548684df6bed47164ad482b3643678c70b62dcbbd1a8e6987
|
||||||
|
size 5670
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:b7c77ccb8aa3b19299ab088f2062fd10226e29c883be41141efe62af2d576486
|
||||||
|
size 5801
|
||||||
23
special_tokens_map.json
Normal file
23
special_tokens_map.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"bos_token": {
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"eos_token": {
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"unk_token": {
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
}
|
||||||
|
}
|
||||||
34
tokenizer_config.json
Normal file
34
tokenizer_config.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"add_bos_token": false,
|
||||||
|
"add_prefix_space": false,
|
||||||
|
"bos_token": {
|
||||||
|
"__type": "AddedToken",
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"eos_token": {
|
||||||
|
"__type": "AddedToken",
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"errors": "replace",
|
||||||
|
"model_max_length": 1024,
|
||||||
|
"name_or_path": "gpt2",
|
||||||
|
"pad_token": null,
|
||||||
|
"special_tokens_map_file": null,
|
||||||
|
"tokenizer_class": "GPT2Tokenizer",
|
||||||
|
"unk_token": {
|
||||||
|
"__type": "AddedToken",
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
}
|
||||||
|
}
|
||||||
3
training_args.bin
Normal file
3
training_args.bin
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:a7478cc739e23bc5814145743fea2aeb1f7a44032f3081bb15dcf3e2d153298a
|
||||||
|
size 3515
|
||||||
50259
vocab.json
Normal file
50259
vocab.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user