thetobysiu commited on
Commit
8507fc5
·
verified ·
1 Parent(s): e50f546

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ tags:
7
+ - text-generation
8
+ - gpt2
9
+ - pytorch
10
+ - fine-tuned
11
+ - creative-writing
12
+ - fiction
13
+ - fantasy
14
+ datasets:
15
+ - custom
16
+ pipeline_tag: text-generation
17
+ widget:
18
+ - text: "The witcher drew his sword and"
19
+ example_title: "Action Scene"
20
+ - text: "Geralt looked at Yennefer and said,"
21
+ example_title: "Dialogue"
22
+ - text: "The monster emerged from the shadows,"
23
+ example_title: "Monster Encounter"
24
+ inference:
25
+ parameters:
26
+ max_length: 100
27
+ temperature: 0.9
28
+ top_p: 0.95
29
+ do_sample: true
30
+ ---
31
+
32
+ # GPT-2 Fine-tuned on The Witcher Books
33
+
34
+ A GPT-2 Medium model fine-tuned on text from The Witcher book series by Andrzej Sapkowski for creative text generation in a dark fantasy style.
35
+
36
+ ## Model Description
37
+
38
+ This model is part of the [Deepstory](https://github.com/thetobysiu/deepstory) project, which combines Natural Language Generation, Text-to-Speech, and animation technologies to create interactive storytelling experiences.
39
+
40
+ The model has been fine-tuned on The Witcher novels to generate text that captures the narrative style, vocabulary, and themes of the original books.
41
+
42
+ ## Model Architecture
43
+
44
+ This model is based on **GPT-2 Medium** architecture.
45
+
46
+ | Parameter | Value |
47
+ |-----------|-------|
48
+ | Architecture | GPT2LMHeadModel |
49
+ | Model Size | GPT-2 Medium |
50
+ | Number of Layers (n_layer) | 24 |
51
+ | Hidden Size (n_embd) | 1024 |
52
+ | Attention Heads (n_head) | 16 |
53
+ | Context Length (n_ctx) | 1024 |
54
+ | Max Positions (n_positions) | 1024 |
55
+ | Vocabulary Size | 50,257 |
56
+ | Activation Function | GELU (new) |
57
+ | Attention Dropout | 0.1 |
58
+ | Embedding Dropout | 0.1 |
59
+ | Residual Dropout | 0.1 |
60
+ | Layer Norm Epsilon | 1e-05 |
61
+
62
+ ## Usage
63
+
64
+ ### With Transformers Library
65
+
66
+ ```python
67
+ from transformers import GPT2Tokenizer, GPT2LMHeadModel
68
+ import torch
69
+
70
+ # Load model and tokenizer
71
+ tokenizer = GPT2Tokenizer.from_pretrained("thetobysiu/gpt2-witcher-books")
72
+ model = GPT2LMHeadModel.from_pretrained("thetobysiu/gpt2-witcher-books")
73
+
74
+ # Generate text
75
+ prompt = "The witcher drew his silver sword and"
76
+ input_ids = tokenizer.encode(prompt, return_tensors='pt')
77
+
78
+ output = model.generate(
79
+ input_ids=input_ids,
80
+ max_length=150,
81
+ temperature=0.9,
82
+ top_p=0.95,
83
+ top_k=50,
84
+ do_sample=True,
85
+ num_return_sequences=1
86
+ )
87
+
88
+ generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
89
+ print(generated_text)
90
+ ```
91
+
92
+ ### Generation Parameters
93
+
94
+ For best results, we recommend the following generation parameters:
95
+
96
+ | Parameter | Recommended Value | Description |
97
+ |-----------|-------------------|-------------|
98
+ | temperature | 0.7 - 1.0 | Higher values = more creative |
99
+ | top_p | 0.9 - 0.95 | Nucleus sampling threshold |
100
+ | top_k | 40 - 50 | Top-k sampling |
101
+ | max_length | 100 - 300 | Maximum tokens to generate |
102
+ | do_sample | True | Enable sampling |
103
+
104
+ ## Training Data
105
+
106
+ The model was fine-tuned on text from The Witcher book series, including:
107
+ - The Last Wish
108
+ - Sword of Destiny
109
+ - Blood of Elves
110
+ - Time of Contempt
111
+ - Baptism of Fire
112
+ - The Tower of the Swallow
113
+ - The Lady of the Lake
114
+ - Season of Storms
115
+
116
+ ## Training Procedure
117
+
118
+ The model was fine-tuned using the Hugging Face Transformers library starting from the pre-trained GPT-2 Medium checkpoint.
119
+
120
+ ## Intended Use
121
+
122
+ This model is intended for:
123
+ - Creative writing assistance in fantasy genre
124
+ - Interactive storytelling applications
125
+ - Fan fiction generation
126
+ - Research in language model fine-tuning
127
+ - Educational purposes
128
+
129
+ ## Limitations
130
+
131
+ - The model may generate content that doesn't perfectly match the original author's style
132
+ - Context length is limited to 1024 tokens
133
+ - May occasionally generate repetitive or incoherent text
134
+ - The training data is based on copyrighted material
135
+
136
+ ## Ethical Considerations
137
+
138
+ - This model is trained on copyrighted material and should be used for personal/research purposes
139
+ - Generated content should not be presented as original work by the book author
140
+ - Users should be aware that generated text may contain mature themes consistent with the source material
141
+
142
+ ## Citation
143
+
144
+ If you use this model, please cite the Deepstory project:
145
+
146
+ ```bibtex
147
+ @misc{deepstory,
148
+ author = {Siu King Wai},
149
+ title = {Deepstory},
150
+ year = {2020},
151
+ publisher = {GitHub},
152
+ url = {https://github.com/thetobysiu/deepstory}
153
+ }
154
+ ```
155
+
156
+ ## License
157
+
158
+ This model is released under the MIT License. Please note that The Witcher series is the intellectual property of Andrzej Sapkowski and CD Projekt.
159
+
160
+ ## Acknowledgments
161
+
162
+ - OpenAI for the original GPT-2 model
163
+ - Hugging Face for the Transformers library
164
+ - Andrzej Sapkowski for The Witcher book series
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 1024,
14
+ "n_embd": 1024,
15
+ "n_head": 16,
16
+ "n_layer": 24,
17
+ "n_positions": 1024,
18
+ "n_special": 0,
19
+ "predict_special_tokens": true,
20
+ "resid_pdrop": 0.1,
21
+ "summary_activation": null,
22
+ "summary_first_dropout": 0.1,
23
+ "summary_proj_to_labels": true,
24
+ "summary_type": "cls_index",
25
+ "summary_use_proj": true,
26
+ "task_specific_params": {
27
+ "text-generation": {
28
+ "do_sample": true,
29
+ "max_length": 50
30
+ }
31
+ },
32
+ "vocab_size": 50257
33
+ }
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 50256,
3
+ "eos_token_id": 50256,
4
+ "max_length": 200,
5
+ "do_sample": true,
6
+ "top_k": 50,
7
+ "top_p": 0.95,
8
+ "temperature": 0.9,
9
+ "repetition_penalty": 1.1,
10
+ "transformers_version": "4.0.0"
11
+ }
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:02b346ed5f42b00724e1e5b05ea95df69cd0a392baf228dd322f8d425a8099cc
3
+ size 1444527986
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "unk_token": "<|endoftext|>"}
tokenizer_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_max_length": 1024,
3
+ "tokenizer_class": "GPT2Tokenizer",
4
+ "bos_token": "<|endoftext|>",
5
+ "eos_token": "<|endoftext|>",
6
+ "unk_token": "<|endoftext|>",
7
+ "pad_token": "<|endoftext|>"
8
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff