chomayouni commited on
Commit
5d59d15
1 Parent(s): ed15da6

The v1.3 commit

Browse files
Files changed (2) hide show
  1. README.md +48 -16
  2. app.py +32 -2
README.md CHANGED
@@ -11,21 +11,53 @@ license: apache-2.0
11
  ---
12
  # Song Generator Guessing Game
13
 
14
- This program generates a song using a language model and then presents a multiple-choice question to the user to guess the artist of the generated song.
15
-
16
- ## Models Used
17
-
18
- The program uses the following models:
19
-
20
- 1. **Language Model**: This model is used to generate the song.
21
 
 
 
22
 
23
- ## Custom Dataset
24
-
25
- The program uses a custom dataset of songs and artists. The dataset includes the following columns:
26
-
27
- - 'Song': The lyrics of the song.
28
- - 'Artist': The artist of the song.
29
-
30
- The dataset is used to generate the multiple-choice options for the guessing game. One of the artists in the options is the artist that the language model was conditioned on to generate the song.
31
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
  # Song Generator Guessing Game
13
 
14
+ ## User Guide
 
 
 
 
 
 
15
 
16
+ ### Introduction
17
+ This program generates a song using a language model and then presents a multiple-choice question to the user to guess the artist of the generated song.
18
 
19
+ ### Usage
20
+ 1. Select a language model from the dropdown.
21
+ 2. Click the 'Generate Song' button to generate a song.
22
+ 3. Guess the artist of the generated song by selecting an option from the radio buttons.
23
+ 4. Click the 'Submit Answer' button to submit your guess.
24
+ 5. The correct answer will be displayed below the radio buttons.
25
+ 6. Repeat steps 2-5 to generate and guess more songs.
26
+
27
+ ### Documentation
28
+ Detailed documentation of models, data, and frameworks used. This should explain how the demo works, the core components used, how the data was processed from user input to output, and details about the pretrained models and datasets used.
29
+
30
+ #### Models
31
+ - The core component of this application is a GPT2 traned language model. The model was trained using the datasets listed below.
32
+ - In addition to this special dataset, the demo also uses untrained versiosons of GPT2-medium, facebook/bart-base, and GPT-NEO for comparison
33
+ - You can access the model [here](https://huggingface.co/SpartanCinder/GPT2-finetuned-lyric-generation)
34
+ #### Data
35
+ The data for this project was generated using the genius API. I created two data sets of the same size, approximately 26,000 tokens, each containing the artist and a portion of one of their top songs. You can find the datasets linked to below.
36
+ There are approximately 135 different artists used in this data set and they range from a myriad of decades and genres
37
+ when the program runs it will pick randomly from from the set of classifiers and that will be what is used to generate the song snippet
38
+
39
+ https://huggingface.co/datasets/SpartanCinder/song-lyrics-artist-classifier
40
+ https://huggingface.co/datasets/SpartanCinder/artist-lyrics-dataset
41
+
42
+ #### Frameworks
43
+ This application uses the following frameworks:
44
+ 1. Gradio: Gradio is used to create the user interface for the application. It provides various components such as buttons, dropdowns, and radio buttons for user input, and text boxes for displaying output.
45
+ 2. PyTorch: PyTorch is used as the backend for the language model. It provides the necessary functions and classes for loading the model, processing the input, and generating the output.
46
+ 3. Transformers: The Transformers library, developed by Hugging Face, is used for loading and using the different models. It provides a high-level API for using transformer models.
47
+
48
+ ### Contributions
49
+ My main contributions for this project were the building of two datasets and the training and fine tuning of the GPT 2 model. As I was looking to start this project I realized that there was no data set that currently existed that allowed me to train any model for the type of lyrics that I wanted to generate, so I knew I would have to create that myself. The overall intention was to build two models the a special text generative model that would be good at generating lyrics and a classifier model that would go along with it and classify the lyrics that it generated so that the application would show the likelihoods of all of the options that are able to be selected. The second model was created, but due to time constraints I was not able to get it to work properly with the specially trained transformer model. I detail why in the limitations section.
50
+
51
+ ### Limitations
52
+ I did not want to use GPT 2 for this project because of my past experience and my struggles getting it to work slash even generate text after I trained it. However I ended up going with it for the final implementation after much fiddling because I simply wasn't able to get another lightweight language model to output anything reasonable to what I wanted. I think this was in part because of the limitations of my data set. After doing some digging i realized that other GPT 2 models that output more accurate text have significantly larger data sets. The data set I created only had 26,000 tokens and I only ran training on my model over 5 epochs. Well I think a larger data set would aid in the training, I also think repeating the training multiple times with the same data set would also yield different results. What's more, I found some other models that have been trained previously to generate songs like our real life artist and those GPT 2 models were only trained on a single artist and were very accurate to the source material. They didn't say how much they trained, but in the future i think this might be a better Ave. For training for specifically what I want to do.
53
+
54
+ I trained the model it simply would not output anything making it less useful than a default model, but after some tuning I realized part of this was because of how I had the model generating text. After I tuned the model to use beam search to generate text it started producing lyrics much more frequently. However, it only produces lyrics in the style of an artist about 56% of the time. Part of these limitations are due to the data set, but also i think part of the reason why it struggles to generate relevant lyrics is based on what artist is randomly chosen. Because GPT 2 is trained on Reddit and Twitter comments, it naturally has more information to go on regarding newer pop artists. In my testing I used Taylor Swift as an example and about 70% of the time it could generate relevant lyrics for Taylor Swift. However if it picks an older artist the model might just ramble on about not having heard the song before. There is also a case where the program picks an artist that the model just doesn't know what to do with and it generates either numbers or YouTube links to their non existent channels.
55
+
56
+ ### Citations
57
+
58
+ - Gradio Docs
59
+ - Github CoPilot
60
+ - Dr. Wilson
61
+ - W3 Schools
62
+ - [Tranformer docs](https://huggingface.co/docs/transformers/v4.40.0/main_classes/output)
63
+ - [Classification Docs](https://huggingface.co/blog/Valerii-Knowledgator/multi-label-classification)
app.py CHANGED
@@ -35,7 +35,7 @@ def generate_song(state, language_model, generate_song):
35
 
36
  #Call for a random artist from the dataset
37
  correct_choice = pick_artist(dataset)
38
- input_text = f"Write a song in the style of {correct_choice}:"
39
 
40
  # Tuninng settings
41
  max_length = 128
@@ -117,7 +117,15 @@ def generate_multiple_choice_check(options, correct_choice):
117
 
118
  with gr.Blocks(title="Song Generator Guessing Game") as game_interface:
119
  gr.Markdown(" # Song Generator Guessing Game")
120
- gr.Image("https://huggingface.co/spaces/SpartanCinder/NLP_Song_Generator_Guessing_Game/blob/main/RobotSinger.png")
 
 
 
 
 
 
 
 
121
  state = gr.State({'options': []})
122
  language_model = gr.Radio(["Custom Gpt2", "Gpt2-Medium", "facebook/bart-base","Gpt-Neo", "Customized Models"], label="Model Selection", info="Select the language model to generate the song.")
123
  generate_song_button = gr.Button("Generate Song")
@@ -126,6 +134,28 @@ with gr.Blocks(title="Song Generator Guessing Game") as game_interface:
126
  user_choice = gr.Radio(["A", "B", "C", "D"], label="Updated Options", info="Select the artist that you suspect is the correct artist for the song.")
127
  submit_answer_button = gr.Button("Submit Answer")
128
  correct_answer = gr.Textbox(label="Results")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
 
131
  generate_song_button.click(
 
35
 
36
  #Call for a random artist from the dataset
37
  correct_choice = pick_artist(dataset)
38
+ input_text = f"A Song in the style of {correct_choice}:"
39
 
40
  # Tuninng settings
41
  max_length = 128
 
117
 
118
  with gr.Blocks(title="Song Generator Guessing Game") as game_interface:
119
  gr.Markdown(" # Song Generator Guessing Game")
120
+ # gr.Markdown("![Image](https://huggingface.co/spaces/SpartanCinder/NLP_Song_Generator_Guessing_Game/raw/main/RobotSinger.png)")
121
+ # gr.HTML("<img src='/NLP_Song_Generator_Guessing_Game/RobotSinger.png'")
122
+ gr.Markdown("""
123
+ ## Instructions
124
+ 1. Select a language model from the dropdown.
125
+ 2. Click the 'Generate Song' button to generate a song.
126
+ 3. Guess the artist of the generated song by selecting an option from the radio buttons.
127
+ 4. Click the 'Submit Answer' button to submit your guess.
128
+ """)
129
  state = gr.State({'options': []})
130
  language_model = gr.Radio(["Custom Gpt2", "Gpt2-Medium", "facebook/bart-base","Gpt-Neo", "Customized Models"], label="Model Selection", info="Select the language model to generate the song.")
131
  generate_song_button = gr.Button("Generate Song")
 
134
  user_choice = gr.Radio(["A", "B", "C", "D"], label="Updated Options", info="Select the artist that you suspect is the correct artist for the song.")
135
  submit_answer_button = gr.Button("Submit Answer")
136
  correct_answer = gr.Textbox(label="Results")
137
+ gr.Markdown("""
138
+ ## Developer Notes:
139
+ - The 'Custom Gpt2' model is a custom fine-tuned GPT-2 model for generating song lyrics.
140
+ -- It was trained using a custom dataset of song lyrics from various artists that I created using the Genius API.
141
+ -- It uses beam search to generate text, and is much faster compared to the other moodels
142
+ -- However, it still has trouble producing prompts
143
+ -- I found that artists like "Adele" and "Taylor Swift" are more likely to have coherent lyrics
144
+ - The 'Gpt2-Medium' model is the GPT-2 medium model from the Hugging Face model hub.
145
+ -- It uses beam search to generate text, and is slower compared to the custom GPT-2 model
146
+ -- Without tuning, it is more likely to produce a general response to the prompt
147
+ -- Oddly enough, had a tendency to produce lyrics that were more coherent than the full GPT-2 model
148
+ - The 'facebook/bart-base' model is the BART base model from the Hugging Face model hub.
149
+ -- The model only workd 20% of the time
150
+ - The 'Gpt-Neo' model is the GPT-Neo 1.3B model from the EleutherAI model hub.
151
+ -- It performs well, but is slower compared to the GPT-2 models
152
+ - The 'Customized Models' option is a placeholder for any other custom models that you may have.
153
+
154
+ #### Known Issues:
155
+ - The 'facebook/bart-base' model has a tendency to produce empty responses.
156
+ -- This is likely due to the model's architecture and the way it processes the input data.
157
+ - Ocasionaly, the Custom Gpt2 model will produce a result that is just numbers. This has only happened once or twice and both times where when is was generating a song for the Weekend.
158
+ """)
159
 
160
 
161
  generate_song_button.click(