Update README.md
Browse files
README.md
CHANGED
@@ -8,3 +8,43 @@ tags: []
|
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
10 |
Midwest indie band 24thankyou lyrics generator, finetuned from gpt2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
10 |
Midwest indie band 24thankyou lyrics generator, finetuned from gpt2.
|
11 |
+
|
12 |
+
|
13 |
+
## How to use:
|
14 |
+
|
15 |
+
|
16 |
+
You can use the following code to generate lyrics
|
17 |
+
|
18 |
+
```python
|
19 |
+
|
20 |
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
21 |
+
|
22 |
+
# load model
|
23 |
+
model_name = "smgriffin/24thankyou-lyrics-generator"
|
24 |
+
model = GPT2LMHeadModel.from_pretrained(model_name)
|
25 |
+
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
|
26 |
+
|
27 |
+
# create text generation pipeline
|
28 |
+
text_generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
29 |
+
|
30 |
+
# prompt for lyrics
|
31 |
+
prompt = f"Lyrics:"
|
32 |
+
|
33 |
+
# generate and print
|
34 |
+
generated_texts = text_generator(
|
35 |
+
prompt,
|
36 |
+
max_length=150,
|
37 |
+
num_return_sequences=1,
|
38 |
+
temperature=0.9, # less than .9 results in a lot of repeated lyrics
|
39 |
+
top_k=50,
|
40 |
+
top_p=0.95,
|
41 |
+
do_sample=True,
|
42 |
+
)
|
43 |
+
|
44 |
+
print("Generated Lyrics:")
|
45 |
+
print(generated_texts[0]["generated_text"])
|
46 |
+
|
47 |
+
|
48 |
+
```
|
49 |
+
|
50 |
+
|