TristanBehrens
commited on
Commit
·
3d52a00
1
Parent(s):
9774a25
Update README.md
Browse files
README.md
CHANGED
@@ -8,30 +8,52 @@ tags:
|
|
8 |
|
9 |
widget:
|
10 |
- text: "PIECE_START"
|
|
|
|
|
11 |
|
12 |
---
|
13 |
|
14 |
|
15 |
# GPT-2 for Music
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
|
19 |
## Model description
|
20 |
|
21 |
-
|
22 |
|
23 |
## Intended uses & limitations
|
24 |
|
25 |
-
|
26 |
|
27 |
### How to use
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
### Limitations and bias
|
32 |
|
33 |
-
|
34 |
|
35 |
## Training data
|
36 |
|
37 |
-
|
|
|
8 |
|
9 |
widget:
|
10 |
- text: "PIECE_START"
|
11 |
+
- text: "PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=60"
|
12 |
+
- text: "PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=58"
|
13 |
|
14 |
---
|
15 |
|
16 |
|
17 |
# GPT-2 for Music
|
18 |
|
19 |
+
Language Models such as GPT-2 can be used for Music Generation. The idea is to represent pieces of music as texts, effectively reducing the task to Language Generation.
|
20 |
+
|
21 |
+
This model is a rather small instance of GPT-2 trained on [TristanBehrens/js-fakes-4bars](https://huggingface.co/datasets/TristanBehrens/js-fakes-4bars). The model generates 4 bars at a time of Bach-like chorales with four voices (soprano, alto, tenor, bass).
|
22 |
+
|
23 |
+
If you are contribute, if you want to say hello, if you want to know more, find me on [LinkedIn](https://www.linkedin.com/in/dr-tristan-behrens-734967a2/)
|
24 |
|
25 |
## Model description
|
26 |
|
27 |
+
The model is GPT-2 with 6 decoders and 8 attention-heads each. The context length is 512. The embedding dimensions are 512 as well. The vocabulary size is 119.
|
28 |
|
29 |
## Intended uses & limitations
|
30 |
|
31 |
+
This model is just a proof of concept. It shows that HuggingFace can be used to compose music.
|
32 |
|
33 |
### How to use
|
34 |
|
35 |
+
You can immediately start generating music running these lines of code:
|
36 |
+
|
37 |
+
```
|
38 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
39 |
+
|
40 |
+
tokenizer = AutoTokenizer.from_pretrained("TristanBehrens/js-fakes-4bars")
|
41 |
+
model = AutoModelForCausalLM.from_pretrained("TristanBehrens/js-fakes-4bars")
|
42 |
+
|
43 |
+
input_ids = tokenizer.encode("PIECE_START", return_tensors="pt")
|
44 |
+
print(input_ids)
|
45 |
+
|
46 |
+
generated_ids = model.generate(input_ids, max_length=500)
|
47 |
+
generated_sequence = tokenizer.decode(generated_ids[0])
|
48 |
+
print(generated_sequence)
|
49 |
+
```
|
50 |
+
|
51 |
+
Note that this just generates music as a text. In order to actually listen to the generated music, you can use this [notebook](https://huggingface.co/TristanBehrens/js-fakes-4bars/blob/main/colab_jsfakes_generation.ipynb).
|
52 |
|
53 |
### Limitations and bias
|
54 |
|
55 |
+
Since this model has been trained on a very small corpus of music, it is overfitting heavily.
|
56 |
|
57 |
## Training data
|
58 |
|
59 |
+
The model has been trained on Omar Peracha's [JS Fake Chorales](https://github.com/omarperacha/js-fakes) dataset, which is a fine collection of 500 Bach-like chorales.
|