File size: 1,774 Bytes
253fd26
30cd581
 
 
 
253fd26
 
4d2a753
 
 
 
 
 
 
 
b900220
 
 
 
 
 
 
4d2a753
 
 
 
 
 
 
 
 
 
 
 
 
101975f
b900220
101975f
 
4d2a753
 
 
 
 
 
 
 
 
2790989
4d2a753
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
language:
- en
tags:
- text-generation
license: apache-2.0
---

# GPT-2 fine-tuned for short story generation

Gpt-2 for short story generation with genres.

## Model description

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):
- Romance (romance)
- Adventure (adventure)
- Mystery & detective (mystery-&-detective)
- Fantasy (fantasy)
- Humor & comedy (humor-&-comedy)
- Paranormal (paranormal)
- Science fiction (science-fiction)

Heavily inspired by https://huggingface.co/pranavpsv
## Intended uses & limitations

This can be used for text generation.

### How to use:

```python
>>> from transformers import pipeline, TextGenerationPipeline, GPT2LMHeadModel, AutoTokenizer
>>> model_name = "aspis/gpt2-genre-story-generation"
>>> model = GPT2LMHeadModel.from_pretrained(model_name)
>>> tokenizer = AutoTokenizer.from_pretrained(model_name)
>>> generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
# Input should be of format "<BOS> <Genre token> Optional starter text"
>>> input_prompt = "<BOS> <adventure>"
>>> story = generator(input_prompt, max_length=80, do_sample=True,
               repetition_penalty=1.5, temperature=1.2, 
               top_p=0.95, top_k=50)
>>> print(story)

[{'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;'}]
```

## Training data

The model was trained using the BookCorpus dataset by getting the different genres per book and dividing the text into paragraphs.