Transformer Neural Net makes music! (JukeboxAI)

CodeEmporium · Beginner ·🧬 Deep Learning ·6y ago

Key Takeaways

JukeboxAI utilizes a Transformer Neural Net to generate music in various styles and artists, as described in the research paper available on OpenAI's blog and the main paper on the topic.

Full Transcript

take me to church I'll worship like a dog at the shrine of your lies I'll tell you my sins so you can sharpen your knife offer me my deathless death good God let me give you my life no masters or kings when the ritual begins there is no sweeter innocence than our gentle sin in the madness and soil of that sad earthly scene only then I am human only then I am clean there's this AI that can generate music in the style of famous singers it can make it rapping Bruno Mars a rock-and-roll Katy Perry and so much more but how does it do this we're going to try to reconstruct this model intuitively and get into more details as we go in doesn't matter how much you know about AI you should just be able to walk away with some knowledge of how this works at any level of detail so let's get started so in the first pass we'll build this intuitively we have this AI that takes in some lyrics genre and an artist and it generates a song and it does so in fixed sized chunks the AI generates a chunk it can then take this chunk and use it to generate the next chunk of audio and it repeats this until we get the entire song this type of AI model takes in an audio sequence and generates the next audio sequence and hence it is a sequence to sequence model in deep learning literature transformer neural networks are the best at dealing with sequence data at least for now so we can replace the AI model with a transformer neural network pretty cool but we run into a problem when building this out this raw audio waveform it's huge you've seen songs on CDs have a sampling rate like forty four point one kilo Hertz that means that we use 44100 numbers just to represent one second of audio it's far too big for our model to handle so we need to compress the waveform while retaining the key aspects of the music and this compression is done through a type of neural network architecture called an autoencoder this autoencoder network can take in a raw waveform and learn to compress it and it can also learn to take a compressed audio and learn to decompress it back to the original waveform the jukebox uses the auto encoder and transformer together and we build this jukebox in two phases training and generation during the training phase we train the auto encoder to compress and decompress audio and then we train the transformer to take in some information about the song to generate and train it to generate a compressed vector representation of the song one chunk at a time during the generation phase though we use both of them together pass in the lyrics genre and artists to the transformer and have it generate the compressed vector 1 audio chunk at a time and we can pass each of these compressed vectors through the auto encoder to get back the raw audio waveforms stitch them together and we have the generated song if we build our jukebox out in this way it might sound something like this hey jukebox how the anonymous celebrity rap to lose yourself by Eminem music to my ears it sounds like this because we built this only based on intuition but there are some key details and modifications we need to make before this is usable and now let's take a look at these in pass to building the real architecture we're using an auto encoder to compress and decompress a waveform this is split between two parts of an auto encoder its encoder for compression and it's decoder for decompression during training the normal auto encoder seeks to minimize the reconstruction loss only it doesn't really care how we compress the vector as long as it's able to reconstruct the input as good as possible and so it learns some arbitrary function to compress and decompress data this is fine for training but it's a problem when generating music during generation we don't have the encoder and we're working with just a decoder since we don't know the function our auto encoder learned chances are if we pass in a compressed vector to the decoder this is going to generate gibberish particularly I'm talking about the last leg of the flow and that's why the anonymous rapping sounded so Shh or beautiful this is where variational auto-encoders are better like normal auto-encoders they minimize a reconstruction loss but with the added constraint that it learns to do so with a specific distribution typically like a standard Gaussian distribution in other words we know how the compression and decompression is happening so during the music generation phase we don't really have the encoder and we can sample a vector from the standard Gaussian distribution pass it to the decoder and it will give us some meaningful audio so replacing our auto encoder with a variational auto encoder let's see what we get with our jukebox hey jukebox have the anonymous celebrity rap to lose yourself by Eminem okay getting better are via learn to convert a continuous distribution of vectors to a sound but not all of these vectors produce meaningful and clear audio and this is one of the reasons why some muddled nests and unclarity is still there in our generated audio to remedy this we can have our VA e to learn to encode a specific set of discrete vectors to a clear sound this is the basis for vector quantized variational auto-encoders during training we pass in a raw audio the encoder compresses it to a vector and we determine the closest discrete vector and then decode that as the sound and during generation the output of our transformer will be mapped to one of these discrete vectors and we can get a meaningful audio output so the vector quantized V II's can get clearer sounds but we can make further improvements on this by using multiple vqv AES at different compression levels this draws inspiration from a study on hierarchical vector quantizer AES used in image compression the goal is to generate even more realistic images by using a hierarchy of two vqv AES so we have a top v QV AE and a bottom v QV AE both of these learn different compressed representations of the image the top-level vqv a II only learns about the global information of the image like the contours and the large strokes but the bottom level vqv AE is larger and it learns about local pixel information like texture shading and color gradients and both of these learn representations are fed into the bottom level decoder to reconstruct the original image the bottom representation is conditioned on the top representation so that it doesn't need to learn the entire representation itself it makes the best use of its space leading to stunning images during the generation phase so like this we have three levels of VQ v's that we train in our case atop a middle and a bottom the top is the most compressed and the bottom is the least compressed but we don't feed the top to the middle in the middle to the bottom like we saw in the image case this is because the researchers observe that the top and the middle were passing all the information to the bottom and that made them useless it's it was similar to just having a single vq via e and so they just trained three v QV II's separately and in parallel it's interesting how we went from auto-encoders to using variational autoencoders to vector quantizer variational autoencoders and then to a hierarchical structure of the same each of them making improvements to generate better and better audio here's the initial structure that we've built in past one but now this autom encoder is actually three v QV a ease with different compression levels but to have these representations interact with each other we introduced three transformers the top transformer takes in lyrics genre and artist information to give the top level compressed representation and the second transformer converts this to the middle compressed representation the third transformer converts it to the bottom compression representation and then we pass this into the bottom vqv a decoder that we trained previously to get a newly generated audio the song hey jukebox have the UH nonnamous celebrity rap to lose yourself by Eminem his palms are sweaty knees weak arms a heavy there's vomit on his sweater already mom's spaghetti he's nervous but on the surface he looks calm and ready to drop bombs but he keeps on forgetting this is the final architecture and the end of past - things are looking a lot more concrete now but how exactly are we training this thing so in past three let's start with the vq ve training and then move on to transformer training we start by training our 3 v QV II's in parallel raw audio is a continuous stream so we need to break it down into fixed sized chunks let's say that we're dealing with a 20 second piece of audio here the top layer we'll break it down into five chunks the mid layer we'll break it down into 10 chunks and the bottom layer let's say it breaks it onto 20 chunks we pass the chunks one at a time through the encoder to get these individual colored bars note that each color bar has the same vector dimensions despite the width being different this top blue bar for example represents like four seconds of audio encoded into a 64 dimensional vector this first purple bar in the middle is the first 2 seconds of audio encoded into a 64 dimensional vector this first bottom brown bar is just one second of audio that's encoded into a 64 dimensional vector passing in all these chunks through the encoder gives us the compressed representations now we perform vector quantization for each of these colored pellets we determine the closest codebook vector the codebook is a list of vectors the blue one here ran in the top level is closest to vector 3 the purple one is closest to the 5 and this magenta one is closest to the 4th and for the codebook lookup we replace each of these numbers with the actual corresponding codebook vector and then we just decode each vector one at a time to get back the audio chunks and stitch that to get the original signal during this training we want to minimize the reconstruction loss we want to learn these codebook vectors and we also have a commit loss to stabilize the encoder so that's the bulk of this hierarchical vqv a training now once all these are trained we train our transformers we take a piece of audio pass it through our three vqv AES to get the top middle and bottom vector quantized representations these are then used to train our transformers the Transformers have an encoder decoder architecture the top level transformer takes in the lyrics artist genre and other conditional information to generate some intermediate vectors the decoder then takes these vectors and a start token to just generate the first highly compressed vector that represents a part of your generated song this is compared to the top level vq v AE vectors to minimize the difference during training time and it does this sequentially generating one vector at a time by our decoder transformer now that's a top level transformer moving on to the mid level transformer this takes one of the top level vectors of the vqv a II take some lyrics some genre and artist information all to generate some encoding vectors and the decoder will use this to generate two vectors generated one at a time during training these vectors are compared to the mid-level vqv a representation to minimize the difference the input vector should represent two seconds of data but the transformer converted it into two vectors that represent one second of data each I say - assuming that the compression rate of the mid level v QV a is two times that of the top level in the actual implementation though the says four times as much but I think you get the idea the bottom level transformer works in a similar way it takes a vector generated from the mid-level vq v AE as input this along with lyrics and genre is encoded into vectors these are passed into the decoder to sequentially generate two vectors one at a time they are compared to the bottom vqv vectors to minimize that difference if the input corresponds to one second of audio the output would be two vectors corresponding to half a second of audio each and in this way we can pass in a number of audio clips - or transformers to train them sweet so now during generation time we would get lyrics genre and artist information all encoded into vectors pass it to our top level transformers to get a very compressed representations pass each of these to the mid level transformer to decompress and pass each of these to the bottom level transformer to further decompress and then pass each of these vectors to the bottom level vqv a decoder to generate audio chunks stitch them together and we get view music and that's it I hope this covered different levels of understanding there's still a lot of detail that I did leave out but if you made it this far I'll add some references down in the description below of research papers reference papers and blog posts that you can check out thanks for watching and I will see you soon bye bye

Original Description

JukeboxAI can generate music in the voice of any artist with any style. Please subscribe to keep me alive: https://www.youtube.com/c/CodeEmporium?sub_confirmation=1 SPONSOR Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite. Love it! https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=codeemporium&utm_content=description-only REFERENCES [1] The blog for more info: https://openai.com/blog/jukebox/ [2] The main paper: https://cdn.openai.com/papers/jukebox.pdf [3] Variational AutoEncoder Tutorial: https://jaan.io/what-is-variational-autoencoder-vae-tutorial/ [4] Vector Quantized Variational AutoEncoders (VQ-VAE) - the main paper: https://arxiv.org/abs/1711.00937 [5] Hierarchical Quantized AutoEncoders: https://arxiv.org/abs/2002.08111 [6] Generating High quality images with VQ-VAE-2: https://arxiv.org/pdf/1906.00446.pdf [7] Disadvantage of Variational AutoEncoders is "Posterior Collapse". Learn more here: https://datascience.stackexchange.com/questions/48962/what-is-posterior-collapse-phenomenon [8] More reasoning on why posterior collapse occurs: https://papers.nips.cc/paper/9138-dont-blame-the-elbo-a-linear-vae-perspective-on-posterior-collapse.pdf
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from CodeEmporium · CodeEmporium · 49 of 60

1 Linear Regression and Multiple Regression
Linear Regression and Multiple Regression
CodeEmporium
2 Logistic Regression - THE MATH YOU SHOULD KNOW!
Logistic Regression - THE MATH YOU SHOULD KNOW!
CodeEmporium
3 Generative Adversarial Networks - FUTURISTIC & FUN AI !
Generative Adversarial Networks - FUTURISTIC & FUN AI !
CodeEmporium
4 Deep Learning on the Cloud - GPU TO LEARN FASTER
Deep Learning on the Cloud - GPU TO LEARN FASTER
CodeEmporium
5 Deep Mind's AlphaGo Zero - EXPLAINED
Deep Mind's AlphaGo Zero - EXPLAINED
CodeEmporium
6 Mask Region based Convolution Neural Networks - EXPLAINED!
Mask Region based Convolution Neural Networks - EXPLAINED!
CodeEmporium
7 Attention in Neural Networks
Attention in Neural Networks
CodeEmporium
8 Depthwise Separable Convolution - A FASTER CONVOLUTION!
Depthwise Separable Convolution - A FASTER CONVOLUTION!
CodeEmporium
9 One Neural network learns EVERYTHING ?!
One Neural network learns EVERYTHING ?!
CodeEmporium
10 Neural Voice Cloning
Neural Voice Cloning
CodeEmporium
11 AI creates Image Classifiers…by DRAWING?
AI creates Image Classifiers…by DRAWING?
CodeEmporium
12 Unpaired Image-Image Translation using CycleGANs
Unpaired Image-Image Translation using CycleGANs
CodeEmporium
13 K-Means Clustering - EXPLAINED!
K-Means Clustering - EXPLAINED!
CodeEmporium
14 Random Forest Classification
Random Forest Classification
CodeEmporium
15 Data Science in Finance
Data Science in Finance
CodeEmporium
16 Hypothesis testing with Applications in Data Science
Hypothesis testing with Applications in Data Science
CodeEmporium
17 A/B Testing - Simply Explained
A/B Testing - Simply Explained
CodeEmporium
18 The Kernel Trick - THE MATH YOU SHOULD KNOW!
The Kernel Trick - THE MATH YOU SHOULD KNOW!
CodeEmporium
19 Support Vector Machines - THE MATH YOU  SHOULD KNOW
Support Vector Machines - THE MATH YOU SHOULD KNOW
CodeEmporium
20 Principal Component Analysis (PCA) - THE MATH YOU SHOULD KNOW!
Principal Component Analysis (PCA) - THE MATH YOU SHOULD KNOW!
CodeEmporium
21 History of Calculus - Animated
History of Calculus - Animated
CodeEmporium
22 Curiosity in AI
Curiosity in AI
CodeEmporium
23 DropBlock - A BETTER DROPOUT for Neural Networks
DropBlock - A BETTER DROPOUT for Neural Networks
CodeEmporium
24 Autoencoders - EXPLAINED
Autoencoders - EXPLAINED
CodeEmporium
25 Recurrent Neural Networks - EXPLAINED!
Recurrent Neural Networks - EXPLAINED!
CodeEmporium
26 LSTM Networks - EXPLAINED!
LSTM Networks - EXPLAINED!
CodeEmporium
27 Building an Image Captioner with Neural Networks
Building an Image Captioner with Neural Networks
CodeEmporium
28 10 Machine Learning Questions - ANSWERED!
10 Machine Learning Questions - ANSWERED!
CodeEmporium
29 How do neural networks work?
How do neural networks work?
CodeEmporium
30 Evolution of Face Generation |  Evolution of GANs
Evolution of Face Generation | Evolution of GANs
CodeEmporium
31 How does Google Translate's AI work?
How does Google Translate's AI work?
CodeEmporium
32 How to keep up with AI research?
How to keep up with AI research?
CodeEmporium
33 How does YouTube recommend videos? - AI EXPLAINED!
How does YouTube recommend videos? - AI EXPLAINED!
CodeEmporium
34 Variational Autoencoders - EXPLAINED!
Variational Autoencoders - EXPLAINED!
CodeEmporium
35 Logistic Regression - VISUALIZED!
Logistic Regression - VISUALIZED!
CodeEmporium
36 Gradient Descent - THE MATH YOU SHOULD KNOW
Gradient Descent - THE MATH YOU SHOULD KNOW
CodeEmporium
37 Boosting - EXPLAINED!
Boosting - EXPLAINED!
CodeEmporium
38 Transformer Neural Networks - EXPLAINED! (Attention is all you need)
Transformer Neural Networks - EXPLAINED! (Attention is all you need)
CodeEmporium
39 Loss Functions - EXPLAINED!
Loss Functions - EXPLAINED!
CodeEmporium
40 Optimizers - EXPLAINED!
Optimizers - EXPLAINED!
CodeEmporium
41 NLP with Neural Networks & Transformers
NLP with Neural Networks & Transformers
CodeEmporium
42 Batch Normalization - EXPLAINED!
Batch Normalization - EXPLAINED!
CodeEmporium
43 Activation Functions - EXPLAINED!
Activation Functions - EXPLAINED!
CodeEmporium
44 Data Scientist Answers Interview Questions
Data Scientist Answers Interview Questions
CodeEmporium
45 Why use GPU with Neural Networks?
Why use GPU with Neural Networks?
CodeEmporium
46 How do GPUs speed up Neural Network training?
How do GPUs speed up Neural Network training?
CodeEmporium
47 BERT Neural Network - EXPLAINED!
BERT Neural Network - EXPLAINED!
CodeEmporium
48 ConvNets Scaled Efficiently
ConvNets Scaled Efficiently
CodeEmporium
Transformer Neural Net makes music! (JukeboxAI)
Transformer Neural Net makes music! (JukeboxAI)
CodeEmporium
50 What do filters of Convolution Neural Network learn?
What do filters of Convolution Neural Network learn?
CodeEmporium
51 We're hosting a Machine Learning Conference!
We're hosting a Machine Learning Conference!
CodeEmporium
52 MLconfEU 2020: Machine Learning Conference for Software Engineers
MLconfEU 2020: Machine Learning Conference for Software Engineers
CodeEmporium
53 Are Neural Networks Intelligent?
Are Neural Networks Intelligent?
CodeEmporium
54 Time Series Forecasting with Machine Learning
Time Series Forecasting with Machine Learning
CodeEmporium
55 Few Shot Learning - EXPLAINED!
Few Shot Learning - EXPLAINED!
CodeEmporium
56 How does a Data Scientist Fight FRAUD?
How does a Data Scientist Fight FRAUD?
CodeEmporium
57 How would a Data Scientist analyze Customer Churn?
How would a Data Scientist analyze Customer Churn?
CodeEmporium
58 Expectations with Machine Learning
Expectations with Machine Learning
CodeEmporium
59 Why Logistic Regression DOESN'T return probabilities?!
Why Logistic Regression DOESN'T return probabilities?!
CodeEmporium
60 How you SHOULD code Machine Learning
How you SHOULD code Machine Learning
CodeEmporium

This video discusses JukeboxAI, a music generation model that uses a Transformer Neural Net to create music in the style of various artists. The model is based on research papers available on OpenAI's blog and other sources. Viewers can learn about the technical details of the model and its applications.

Key Takeaways
  1. Read the research paper on JukeboxAI
  2. Understand the basics of Transformer Neural Nets
  3. Learn about Variational AutoEncoders and their applications
  4. Apply the concepts to music generation tasks
  5. Experiment with different styles and artists
💡 The Transformer Neural Net can be used for creative tasks such as music generation, and the Variational AutoEncoder is a key component of the JukeboxAI model.

Related Reads

📰
Trained a neural net to reconstruct Bad Apple in real-time.
Reconstruct Bad Apple in real-time using a trained neural network and learn how to apply deep learning to video processing
Reddit r/deeplearning
📰
AI/ML Under the Hood — Part 29: CNN Breaking News: Proximity Matters
Learn how proximity affects CNNs with kernels, feature maps, padding, and strides
Medium · Deep Learning
📰
Deep Learning Scientists — Claude Cowork: The Deep Learning Scientist’s New Lab Partner
Meet Claude Cowork, a new tool for deep learning scientists to optimize their workflow and reduce the scarcity of compute and attention resources
Medium · Data Science
📰
Why Qwen3.8 27B Looked Brilliant in Testing but Failed to Ship My AI Newspaper
Learn why a high-performing AI model like Qwen3.8 27B failed to deliver in real-world application and how to avoid similar pitfalls
Medium · Deep Learning
Up next
Machine Learning Rust Candle Hugging Face Part 4
Stephen Blum
Watch →