Updated README
Browse files
README.md
CHANGED
@@ -5,3 +5,47 @@ tags:
|
|
5 |
- text-generation
|
6 |
license: apache-2.0
|
7 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- text-generation
|
6 |
license: apache-2.0
|
7 |
---
|
8 |
+
|
9 |
+
# GPT-2 fine-tuned for short story generation
|
10 |
+
|
11 |
+
Gpt-2 for short story generation with genres.
|
12 |
+
|
13 |
+
## Model description
|
14 |
+
|
15 |
+
Gpt-2 model fine-tuned on sample of BookCorpus dataset for short story generation, allows for the following genres (tokens to use as input under parenthesis):
|
16 |
+
- Romance (<romance>)
|
17 |
+
- Adventure (<adventure>)
|
18 |
+
- Mystery & detective (<mystery-&-detective>)
|
19 |
+
- Fantasy (<fantasy>)
|
20 |
+
- Humor & comedy (humor-&-comedy)
|
21 |
+
- Paranormal (paranormal)
|
22 |
+
- Science fiction (science-fiction)
|
23 |
+
|
24 |
+
Heavily inspired by https://huggingface.co/pranavpsv
|
25 |
+
## Intended uses & limitations
|
26 |
+
|
27 |
+
This can be used for text generation.
|
28 |
+
|
29 |
+
### How to use:
|
30 |
+
|
31 |
+
```python
|
32 |
+
>>> from transformers import pipeline, TextGenerationPipeline, GPT2LMHeadModel, AutoTokenizer
|
33 |
+
>>> model_name = "aspis/gpt2-genre-story-generation"
|
34 |
+
>>> model = GPT2LMHeadModel.from_pretrained(model_name)
|
35 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(model_name)
|
36 |
+
>>> story_generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
|
37 |
+
#
|
38 |
+
>>> input_prompt = "<BOS> <adventure> He was trapped in the pirate's house"
|
39 |
+
>>> story = story_generator(input_prompt, max_length=80, do_sample=True,
|
40 |
+
repetition_penalty=1.5, temperature=1.2,
|
41 |
+
top_p=0.95, top_k=50)
|
42 |
+
>>> print(story)
|
43 |
+
|
44 |
+
[{'generated_text': '<BOS> <adventure> "How come they got that one?" asked Louran. The leader of the House, a young man with blonde hair and an odd grin...that didn\'t look so bad to her if she did have a smile on its face. She had known about this before. And now he\'d admitted it himself;'}]
|
45 |
+
```
|
46 |
+
|
47 |
+
## Training data
|
48 |
+
|
49 |
+
The model was trained by manipulating the BookCorpus dataset by getting the different genres per book and dividing the text into paragraphs.
|
50 |
+
|
51 |
+
|