Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# GPT2-Horoscopes
|
2 |
+
|
3 |
+
## Model Description
|
4 |
+
GPT2 fine-tuned on Horoscopes dataset scraped from [Horoscopes.com](https://www.horoscope.com/us/index.aspx). This model generates horoscopes given a horoscope *category*.
|
5 |
+
|
6 |
+
## Uses & Limitations
|
7 |
+
|
8 |
+
### How to use
|
9 |
+
The model can be used directly with the HuggingFace `pipeline` API.
|
10 |
+
```python
|
11 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
12 |
+
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained("shahp7575/gpt2-horoscopes")
|
14 |
+
model = AutoModelWithLMHead.from_pretrained("shahp7575/gpt2-horoscopes")
|
15 |
+
```
|
16 |
+
|
17 |
+
### Generation
|
18 |
+
|
19 |
+
Input Text Format - `<|category|> {category_type} <|horoscope|>`
|
20 |
+
|
21 |
+
Supported Categories - *general, career, love, wellness, birthday*
|
22 |
+
|
23 |
+
Example:
|
24 |
+
```python
|
25 |
+
prompt = <|category|> career <|horoscope|>
|
26 |
+
prompt_encoded = torch.tensor(tokenizer.encode(prompt)).unsqueeze(0)
|
27 |
+
sample_outputs = model.generate(prompt,
|
28 |
+
do_sample=True,
|
29 |
+
top_k=40,
|
30 |
+
max_length = 300,
|
31 |
+
top_p=0.95,
|
32 |
+
temperature=0.95,
|
33 |
+
num_return_sequences=1)
|
34 |
+
```
|
35 |
+
|
36 |
+
### Training Data
|
37 |
+
Dataset is scraped from [Horoscopes.com](https://www.horoscope.com/us/index.aspx) for 5 categories with a total of ~12k horoscopes. The dataset will be made public soon.
|
38 |
+
|
39 |
+
### Training Procedure
|
40 |
+
The model uses the [GPT2](https://huggingface.co/gpt2) checkpoint and then is fine-tuned on horoscopes dataset for 5 different categories. Since the goal of the fine-tuned model was also to understand different horoscopes for different category types the *categories* are added to the training data separated by special token `<|category|>`.
|
41 |
+
|
42 |
+
**Training Parameters:**
|
43 |
+
|
44 |
+
- EPOCHS = 5
|
45 |
+
- LEARNING RATE = 5e-4
|
46 |
+
- WARMUP STEPS = 1e2
|
47 |
+
- EPSILON = 1e-8
|
48 |
+
- SEQUENCE LENGTH = 300
|
49 |
+
|
50 |
+
### Evaluation Results
|
51 |
+
|
52 |
+
Loss: 2.77
|
53 |
+
|
54 |
+
### Limitations
|
55 |
+
This model is only fine-tuned on horoscopes by categories. They do not, and neither attempt to, represent actual horoscopes. It is developed only for educational and learning purposes.
|
56 |
+
|
57 |
+
## References
|
58 |
+
|
59 |
+
- [Rey Farhan's - Fine-tuning GPT2 Notebook](https://colab.research.google.com/drive/13dZVYEOMhXhkXWfvSMVM1TTtUDrT6Aeh?usp=sharing#scrollTo=_U3m6wr3Ahzt)
|
60 |
+
|
61 |
+
- [Jonathan Bgn - Building a Slogan Generator with GPT-2](https://jonathanbgn.com/gpt2/2020/01/20/slogan-generator.html)
|