Geralt-Targaryen commited on
Commit
f277591
·
1 Parent(s): 91e6cc2
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - FantasyGPT
6
+ widget:
7
+ - "Legolas and Gimli advanced on the orcs, raising their weapons with a harrowing war cry."
8
+ - "Hermione smiled at Harry."
9
+ - "Ghost bared his teeth."
10
+ - "Geralt drew his sword"
11
+ - "Galadriel drew her sword"
12
+ - "Daenerys kissed Gandalf, as the witcher hacked off Lord Voldemort's head with a brutal swing of Longclaw."
13
+ - "Harry leapt forward, dodging Fingolfin's wildfire and reaching for the ring."
14
+ ---
15
+
16
+ A tiny GPT-2 (51.5M params) trained **from scratch** on some of my favorite books (about 14M words in total).
17
+
18
+ It's only trained on an RTX 3090 for two hours, so don't take it seriously, just have fun!
19
+
20
+ - peak lr: 5e-4
21
+ - global batch size: 32
22
+ - weight decay: 0.01
23
+ - training steps: 20k
24
+ - warmup steps: 1k
25
+ - lr decay: cosine
26
+
27
+ Example usage:
28
+
29
+ ```python
30
+ from transformers import AutoTokenizer, GPT2LMHeadModel
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained('Geralt-Targaryen/FantasyGPT')
33
+ model = GPT2LMHeadModel.from_pretrained('Geralt-Targaryen/FantasyGPT')
34
+
35
+ input_text = ["Daenerys kissed Gandalf, as the witcher hacked off Lord Voldemort's head with a brutal swing of Longclaw."]
36
+ input_tokenized = tokenizer(input_text, return_tensors='pt')
37
+
38
+ output = model.generate(inputs=input_tokenized.input_ids, max_new_tokens=256, do_sample=True, top_p=0.95, temperature=1)
39
+
40
+ print(tokenizer.decode(output[0]))
41
+ ```
42
+
43
+ Sample output:
44
+
45
+ > Daenerys kissed Gandalf, as the witcher hacked off Lord Voldemort's head with a brutal swing of Longclaw. And then the knight was on his horse and had no helm or helm or a lance. He flew to his feet.
46
+ >
47
+ > The knight roared and stamped. At the top of the helm he fell on his horse, and the knight grabbed the bridle, and the knight fell to his knees. The knight slashed at his shield.
48
+ >
49
+ > The knight caught hold of the blade of the knight and twisted his left foot off into the saddle. There was a moment of stunned silence. His blade went through its scabbard, and he fell to his knees, his sword raised from his belt. The blood of the knight’s blood spilled down the hilt of the lance. His sword flashed silver, and the hilt of the steel gleamed like burnished steel.
50
+ >
51
+ > The knight turned to obey. As he slashed at his chest, its sheath sheared free with a clang. His own longsword bounced and fell into a fist on his thigh, shattering the steel with his staff. The shield came from a blow and knocked him against the face of his foe.
52
+ >
53
+ > The knight did not hesitate. He saw his sword before him as the lance stabbed through the helm. The knight screamed, and the knight saw it. The knight grabbed the shield and held it before his neck.
54
+ >
55
+ > The sword
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "gpt2",
3
+ "activation_function": "gelu_new",
4
+ "architectures": [
5
+ "GPT2LMHeadModel"
6
+ ],
7
+ "attn_pdrop": 0.1,
8
+ "bos_token_id": 0,
9
+ "embd_pdrop": 0.1,
10
+ "eos_token_id": 0,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 1024,
15
+ "n_embd": 512,
16
+ "n_head": 8,
17
+ "n_inner": null,
18
+ "n_layer": 8,
19
+ "n_positions": 1024,
20
+ "reorder_and_upcast_attn": false,
21
+ "resid_pdrop": 0.1,
22
+ "scale_attn_by_inverse_layer_idx": false,
23
+ "scale_attn_weights": true,
24
+ "summary_activation": null,
25
+ "summary_first_dropout": 0.1,
26
+ "summary_proj_to_labels": true,
27
+ "summary_type": "cls_index",
28
+ "summary_use_proj": true,
29
+ "task_specific_params": {
30
+ "text-generation": {
31
+ "do_sample": true,
32
+ "max_length": 256,
33
+ "temperature": 1,
34
+ "top_p": 0.95
35
+ }
36
+ },
37
+ "torch_dtype": "float32",
38
+ "transformers_version": "4.25.1",
39
+ "use_cache": true,
40
+ "vocab_size": 50257
41
+ }
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:035b30000fd1d08d3acac589cbdf84b7d63b61f64e2dbb7d234afa6a1f803bf7
3
+ size 214328413
special_tokens_map.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "unk_token": "<|endoftext|>"
5
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": "<|endoftext|>",
4
+ "eos_token": "<|endoftext|>",
5
+ "model_max_length": 1024,
6
+ "name_or_path": "tokenizer",
7
+ "special_tokens_map_file": null,
8
+ "tokenizer_class": "GPT2Tokenizer",
9
+ "unk_token": "<|endoftext|>"
10
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff