Hello, everyone. Welcome to another episode, special episode today, because today we are going to walk through how to build from inception to actual implementation, a music generator, a music recommendation system. Yeah, got that right. So first, we're going to start with a proof of concept, just just a little overview of what we're going to be doing, followed by like getting into each of these individual components separately. It's going to be a long video, but it's going to be fun. So just keep following along if you can. Okay, so first of all, we have this like piece of audio right now, right? And then we want to pass it into this embedding generator. So what an embedding generating embedding generator does it is it'll take your song, and then it'll vectorize it convert it into like a bite vector of sorts, right? And, and, and then it takes that vector and then passes it into a recommendation engine, because now machine learning understands math. So this recommendation engine will then recommend the closest values that are to this original music audio. And so effectively, we're building a recommendation system or recommendation engine. Now, in order to build all of these components, we have three major resources that we use. The first is the audio set data set, which will provide us all the, you know, kind of like the YouTube videos and all those, you know, resources in general. Then we have the max audio embedding generator from IBM, which is a tool that helps you convert raw wave files into into a byte string or into like vectors in general. And then we have annoy, which is an approximate nearest neighbor's implementation by one of the guys from Spotify. And what it does is it basically takes your vector and then spits out neighboring vectors. And these vectors can of course be translated back into music, right? And so, well, that's actually the entire gist of the video, we're going to be walking through each one of these separately from audio data set, the max audio embedding generator and annoy. And we're going to be walking through certain examples, how they're used with code. So keep falling along. Okay. So right now, first is the audio set, right? This audio set data set, like I mentioned, it's a set of YouTube video IDs. It's kind of like this massive huge file, which consists of JSON like information, but it's not exactly JSON. We're going to have to do some conversions and processing later. So let me just let me just give you an example of a format. So this entire JSON looking structure is of one sample video in the entire corpus. And like this entire sample, they have like, I don't know, 13,000 of them. So let's just start with this, like, what does this actually mean, right? So first of all, it's saying that, okay, we have a video ID, which is right here. Now this video ID is basically like a YouTube URL kind of thing, you know, YouTube.com slash watch slash whatever that ID is that is going to be here, then start time and end time. So basically it's saying, okay, from this video ID, we want to take the timestamps from six seconds in the video till 16 seconds in the video. And that 10 second chunk is your music. That's your frame that you need right now. Right. Next is that we have labels. So labels are kind of like tags that are given to the video. It's like, okay, is this music? Is this within music is a guitar?  And all of these labels are kind of stored in a list. And the meaning of these labels, well, it says it can be found here, but it's actually in a in a CSV that I'll probably share with you later. And it's exactly like what I said those tags could be. And then we have feature lists, which is basically saying every second of audio or every part of that audio is now encoded into this 128 feature string. So the thing is that like, let's say that we have like a 10 second piece of audio. What it's doing is that we are chunking that 10 second piece of audio into like 10 chunks of one second each. And each of those seconds are encoded into a 128. Basically it's an array of 128 numbers, which is like a byte array. And so this is the first second of audio. This is the second second of audio. And like that we'll have like 10 lists for every second of the audio. And yeah, this is well, that's actually our entire data set like this. It's repeated the maybe 13,000 times. And it's a really big file. If you download it, it's like 2.4 gigs, right? You can get this entire data set by clicking on probably the US corpus yet this link right here. And then you just need to double click and extract that just extracted, right? And all of these files are essentially they are stored. I think I have it here. Yeah. So all of that is basically this thing, this audio set v1 embeddings, and they're stored in the form of TF records. So each of these records have exactly well, this kind of information for like 13,000 examples. And right now, the thing is that, you know, all of these features are like typically when you look at music raw wave data, right? They're kind of stored in like you see like CDs, for example, having 44.1 kilohertz, which is like saying 44,100 numbers are used to they're used to represent like one second of data, right? But, you know, that's a lot to work with machine learning. And that's why the output of this right now those 120 features is a lot less. And it also represents the same amount of information. So this is the embedding that we were talking about right in the in the video in the in this proof of concept right here. And these embeddings are actually pre generated by this max audio embedding generator. Yeah. And if this so we don't really need to do any of them, we don't need to do the embedding ourselves. They're already available in this data set. But let me just explain how that embedding generation works. So let me come to this screen. Okay, so this I'm running. Basically, I built an application. I mean, I didn't build it myself. But like I'm running an application that I clone from the IBM max audio embedding generator library. And what they do here is, well, you can basically let me just show you. So I uploaded a way file, right? Oh, this way file for like, it's just like a car horn weight way file. And why am I saving this? It's a car horn way file. And what's happening now is if you click like, you know, if you click to execute this, it will return a response right here. And the response is the embedding. So like I said, the embedding will be generated for, you know, every second of audio, this entire thing, you see this list of lists, right, this first list of till, yeah, until here is 128 numbers of bytes. And that represents one second of the car horn. Like that, this represents the other section, which is the second car, the second second of the car horn, this is the third second and so on. Now, I can, I'm going to explain exactly like how you can render this. So if you wanted to, you can see I'm running this on like local hosts on port 5000, right? And in order to do exactly this, you just need to go to the IBM's main repository was that yeah, the max audio embedding generator repository, you clone this repository, and then you follow the steps for running locally right here. So basically clone the repository, go into their main directory, then you need to have Docker installed, which will help you containerize the build, it helps you build containerize applications. So applications that can kind of run on their own with their own dependencies, just all in one bundle, right? So a good way to build applications these days. And then you just need to run the model.  And you can play around with it just to just to see how you can upload WAV files and then see their corresponding results. So hope that is super clear. Right now, okay, so we kind of got an intuition. Let's see, let's go back here. So we know what the audio data set is for. We know how to actually embed now the audio generating wall. At least we know, you know, using this tool how to create the embeddings. So now we have a vector, right? But the thing is that like we we don't want to we have like 13,000 of these vectors, right?  So the audio data set, like I mentioned, already has the fact they've already used the max audio embedding generator. But this is just for more for your reference to understand what's really going on, what the data in the audio set here, this represents. So cool. Yeah, we're cool, Professor Halthor Professor, what's no way. Okay. So now, so within IBM, you know, this I was actually here, right? Sorry if the explanation is jumping all over the place, because there's just a lot of files to go through. The idea is just for you to understand what's going on. As long as you do, I'm satisfied.  We can use that to pass in an audio file, like a WAV file via like a terminal command. And then we can get the response to, right? And so what we can do is they have like a demo notebook within this. Let me just open that. I think it's in samples. Internet. Yay. And then like there's demo IPI and B, right? So I'm not going to open it here, but I actually have it. I have it open over here. Yeah. So that same notebook that you saw is exactly what I have copied and pasted here. Hence all the licensing information is here. And what this will do is it's going to read away file and get the corresponding embeddings like I just mentioned, but via, you know, a code interface, right? I'm putting it here because I made a couple of changes just to make sure that the notebook works properly. But let's go through exactly what this notebook is doing.  Mouthplot live to just plot. We have like a plot of a chart coming up. Then like, yeah, see similarity, a cosine similarity again for, for getting similarity between two vectors. So cool. Also glob is used for getting it's used for getting like media type assets and fetching them kind of like how here we're using to fetch fetch everything in a directory. We're going to fetch the all the way files in demo assets, which was basically all the all the stuff in this repository right here. So all of these way files, we are going to fetch, right? And if we list out what exactly is being fetched, you see, right? So it's like a way file of a jazz guitar, a way file of birds chirping, a way file of gunshots. Yeah. Now the goal here is to convert these way files into the embeddings using the max audio embedding generator. By the way, just to make it clear, you know, an embedding is basically an array that has a representation of the corresponding file that is coming from in this case, the way file. And we just require it so that it's basically essentially a compressed representation that has all the meaning of the data. And because it's more compressed, we can deal with it in machine learning or like, you know, in general, right with like the nearest neighbor approach, whatever it is that we're going to be using later. All right. So now coming to this little section over here. So what we're doing is like for every single way file, we're going to execute this curl request, right? What it's going to do is I'm passing the audio way file. And I'm passing it to that URL that we just mentioned that we just put up right here. And then what it's going to do is it's going to run the prediction model, which is basically run it through our embedding that embedding generator. And when it generates an embedding, it's going to output it to a JSON file. Excuse me. Right. And that, yeah, that is basically the format of the response that we just shared. Right. Now, this is going to be like, let's say that you just extract the embedding, which is a list of lists where each list within that list is 128 characters of bytes. And now what I'm doing is I want the audio link to be cut at 10 seconds. So let's say that we have clips that are, you know, some clips are various lengths, right? But I only want audio clips that are at least 10 seconds. And for those clips, we cut it at 10 seconds so that we have so we make sure that every single audio clip is the same size. So in this case, we're just going to have like every if every single audio is now cut to 10 seconds, every single list of lists. So the list of lists will basically contain 10 lists. And each of those 10 lists will be 128 characters for bytes. That's exactly what's happening here. Right. And I'm just printing out every single column making there's like 19 or 20 calls. And I'm encoding every single one of those way files that I printed above into an embedding. So now, and what I'm doing now is since it's a list of lists right now of each of those lists is a 10 cross 128 for every single sample, I'm just flattening it. So now we have like a single vector of 1280 dimensions that represents a way file. Cool. So now that it's a much compressed more a much more compressed representation, we can do things like I don't know find the cosine similarity between them. So that that will inherently give us like, okay, if if we have the cosine similarity is higher, that means the two vectors are more similar in meaning to write. And so I'm just testing out a few values here. Like, I mean, you'll kind of see these later, it's a value between zero and one, this is the cosine similarities. So this is like the first way file, this is the second way file, and their corresponding cosine similarity. It looks pretty good. They're pretty high values for, for, for things that are similar, like two types of birds or two types of guitars. Right. And now what I'm doing is, well, let's print all of these into like a cosine similarity matrix, right. And so what we have is this little bad boy right here, cosine similarity between normalize embeddings. So x and y axes are, you know, the corresponding items that we're getting higher the better. So what stands out here is like here, okay, 0.89 is pretty high for a jazz guitar. What is 0.89? It's a normal guitar, which is what we would expect a jazz guitar is the most similar to a normal guitar. And then for birds too, well, it's most similar to birds one. Look at that. And then gunshots, well, 0.86 is the highest here. And that is, excuse me, more similar to fireworks, which makes sense, right. And so overall, the embeddings that are generated by this max audio generator, embedding generator are pretty good. They're pretty good to use.  But, you know, on a relative scale, it works for us. It's good enough. And so, yeah, we can now use this back to our proof of concept here. We can now, we now are able to basically, well, have a set of these vectors, and we can now pass them to recommendation engine. But of course, I just did it on random way files right now, executed on a random way files, but we need to execute it on our audio data set, which I do here. Right. So now we're going to the objective of this notebook, it's a second notebook, by the way, called audio set processing, where the objective is to read that audio set data that's in a convoluted like those TF records, essentially. And then we need to convert it into just like a single JSON file that will act as our data set. So this is the second of the third notebook, by the way. So you know what's coming. So the prerequisite is to download the audio set data set in that tar dot Z file, make sure the notebook is in the same directory as the uncompressed embeddings. And then, and that is like basically the same folder level as the audio set V1 embeddings, which was this, this little thing right here. Yeah, this one, this folder. Cool. Right. So now, okay, so now I wrote this file so I can explain stuff. Right. So we're going to be using some TensorFlow here. So you want to install that. The directory we want to be reading is all the all the TF record files that are in the eval folder. Now, what I'm trying to do is well, if it ends in TF record, I'm just storing it into my data set. So this data set will essentially be like a list of TF record files. I'm enabling eager execution because, you know, TensorFlow has this thing where I'm not sure if I require it right now. But when I was testing certain things out, TensorFlow has a lazy method of execution where it will like build an entire tensor graph, I guess, I forget what the appropriate terminology is. And then like when it really needs to form that execution, it will start executing only then and eager execution is like what you would typically expect. Like as soon as it sees like a particular function, even though it doesn't need to execute it, it will execute it. So yeah, I'm enabling that here. I'm converting it now since data set is a list of TF records, I want to just encapsulate it in a TF record data set object, which I call now raw data set. And now, well, we have a bunch now all these this entire data set could be representative of many types of audios. In fact, let me actually show you because like I have this there's like class labels, right? And I want to get all the labels that you know it can correspond to. So essentially, it'll look like this CSV file. So this these these are all possible, you know, labels that can be appended to the audio data set that is all the labels that can be in. So from if this is an example, all the labels that can be in this this value region, right? And that is what exactly we're seeing here. Right? So it's 88 response to click clop, whatever that is, 87 is the sound of a horse, and so on. We have like hundreds of these. Okay. So what I'm doing is I'm reading that CSV file and getting those labels. And then I only want to extract the ones we're only concerned with music, though, right, because this is supposed to be a music generator. And so what you do is I'm only going I'm doing like a string search for everything that contains the word music within those labels and extracting them only removing case sensitivity because obviously, and so we have a set of music labels that are stored here. Right? Next, now we are going to iterate over every single one. Now, this is the main meat of the code where, you know, we're converting all those TF records in that incorrigible form to a JSON data set that is more manageable. So, okay, so now we have for every single TF record in this data set, what we're going to do is we are going to kind of like TensorFlow has this internal object called example, where it helps in serializing TF record data, and it creates something called an example. I'll probably put this is a type of data structure in TensorFlow and how to process TF records. I have it in the resources down here. You can click this link for tutorials on exactly like how and why I'm using this right here. Right? So anyways, this is just to extract near that TF record data. Now we know that there's audio metadata associated with it, that audio metadata. Again, I'm going to keep referencing this audio metadata being this this chunk for this chunk, the context right here. Right? So that has like all the information of video ID start time and time and labels. And that's going back here is exactly what I am extracting. So we get the context dot features labels, and then you know, you just have to follow the tree down in order to extract the actual label value in the form of a list. So all the audio labels start time and time video ID, we store it all. Now when we store it, though, I want to check if this particular sample corresponds to a music label, right? Because what is essentially doing is like it's going to do like an intersection. So I just want to make sure that this audio label like one of the tags, at least it's going to have several tags, right? At least if one of them corresponds to a music kind of tag, I want to include it in our data set. But if it's not, then forget it, skip to the next one, skip to the next record, right? And so that hence that logic is right here. Now let's say that it is a music label, that's great. Now let's track the feature, the actual audio embedding. So that audio embedding is the second part of this, which is here. So you have to go down feature list, feature feature feature list, key is audio embedding, and then get the byte list for every second, which is exactly what I do here. Feature, yeah, feature lists, feature lists, audio embedding dot feature. And then, yeah. And for every feature, we get the byte list, right? And that is going to be our embed, this is going to be like a list of lists, of course, you know, this is going to be like a list of each list is 128 of size, right? But of course, they can be varying lengths because it depends on the length of the audio. But for the audio embedding that we're going to use for our data set, we want to, you know, we want to truncate it to just 10 seconds, num seconds is 10 seconds. So essentially, we're just going to get the first 10 lists in that list of lists, right? And finally, what we're going to do is, well, we are going to see if, yeah, so obviously the length has to be, yeah, that's fine. This is just going to be just to make sure that the if the if we're getting if we're dealing with like shorter audio, you know, like six second audio or three second audio, it's not going to be the uniform across, you know, the other audio, it's clipped at 10. So if it's small audio, we're just going to skip. And then all we're doing is encapsulating it into a little JSON right here. We have the label, the video ID, the start time, the end time and the audio embedding, which is going to be a list now of this is a flattened list. So it's a list of one of 1280 numbers, right, which corresponds to 10 second of audio data. And that is embedded. So very cool. We just append it to our list. I'm just showing a counter just to see the size of our data set. And then yeah, that's it. So we have like around 2000 files that are that are around processed, which is great. We have like over 2000 records for music to play with now. I'm now storing all of this. I'm dumping all of this into a JSON file. And this music set JSON is now our formatted data set that we can now use in our third notebook for generating recommendations. And that's coming up next. Luckily, and now you don't actually even have to execute this code at all, because I'm going to provide the music set JSON in, I think I'm going to provide it in the repository with the code that's going to be in the description below. It's a huge file. I think it's like 13 megabytes of just raw data, which is cool. Right. And I'm just like printing it out just so that you can show see like, okay, the first 10, this, well, this actually doesn't make sense. But this is like the first for the first example only the first 10 numbers of the 1280 for like four samples of data just to see if it's working. But honestly, you don't really need this. So cool. That worked. And notebook number two is complete audio processing. Now before we get into this third notebook on annoy, right? Let me explain exactly how annoy computes the nearest neighbors with a slide deck right here. So I'm getting this slide deck from the creator of annoy. I think it's Eric Byrne. He used to work at Spotify during this time at Spotify. He built this annoy index that helps you find approximate nearest neighbors. Why we want to use approximate nearest neighbors is that it's much faster than you know, trying to compute I think like, you know, it just so much so much faster than using like, you know, let's say if you have 10,000 pieces of music in your data set, you can't just do a brute force linear scan. Otherwise, it'll take forever. Right. A noise just like hundreds of times faster. And so we are going to use an approximate nearest neighbor algorithm to get, you know, pretty good recommendations. So this X is an excerpt from a 50 minute video that he has on YouTube explaining this entire concept. But I'm going to try to distill it down for what we require for this video. So for that, let's get into building the annoy index. So let's say that each of these points, these X's here, it's like an effector space of this is the embedding space, by the way, generated that max by that max audio and better. Here, it's like a two dimensional space. But let's just imagine that it was like, I don't know, let me open it up. Let's imagine that this was, I don't know, the 1280 dimensional space. But for the sake of understanding, it's a two dimensional space. Right. Now, how to do this is that you just pick any random two points in your embedding. And then you draw, you draw a line between them, and then split that line with a perpendicular line. Right. And now we have two separate house right here. Now what you're going to do is you're going to choose two points in the top in like this region and two points in this region, split it by two again randomly. And that's what we do here. And you just keep doing that split, selecting, you know, any random two points per region and performing a split until eventually you get, you know, these small itty bitty box regions. Right. So you would think that, okay, well, now this is a partition of an embedding space that you can also format as a decision tree. Right. So the first like node is like all, all of them are there. Then the first split would be, okay, not a decision tree, more like a binary tree. Right. Because let's see if they have this. Yeah. So this would be like, for example, all, all your points are in one.  Right. And you keep going down and down and down until eventually you'll end up at the circular leaf nodes, which basically correspond to, you know, these individual like this individual region of, you know, points and these three points are within those leaf nodes. Right. So yeah, now when you're searching for a point. Yeah. So now let's say that you want to search for a particular search for it.  And you want to find the nearest neighbors itself. So what do you do? So let's say that the actual point in the embedding space lies somewhere here, right, where this white X is. So you would think, okay, should I just, just traverse the tree, which is corresponding to just that region. So should we just recommend, you know, points within the leaf, this corresponds to a leaf in the decision tree? Should we just correspond to, you know, should we just like return these, but there's a problem with this because there might be some points here, like you can see like these X's over here that are very close to this particular point too, but they're not being recommended to you because they're in a totally different area. But all of this happened arbitrarily because of a random split. And so there are situations where, you know, when you're choosing the two points to create the split, the distance between those points could be extremely small. And so if it is small, we want to traverse both sides of the tree. That's what they do here. So let's say that, okay, you have, this is the main thing, you choose to split, you then have two regions here. And now our main point actually lies here, right? But the thing is when we're making the split right over here, let's say that the split is between two points that we're taking by random chance, right? All this happens randomly is going to be extremely close to each other. It's lower than some threshold. And because of that, okay, because it's lower than some threshold, we want to traverse both of these trees because, you know, that's a kind of where, like just to make sure that we're getting all of the points that are encapsulating, you know, both regions. So we not only have this region, but we also have like some one, two, three, four, five other regions that could potentially be our nearest neighbors, right? And so if you kind of highlight all of these five regions in the actual space, you get something like this, where we have, you know, all these five regions, and then we have the main region. So basically, what it's saying is that if we pass in something, like an embedding, some random piece of music that is at X, this red X, it'll be recommending all the points in this region, right? And that's pretty cool. So yay, cool. We were able to do that. Now, the thing with this is that the implement implementation wise, so you can let me look at this. So this entire thing, right, all this entire tree in general, and this entire searching for this nearest neighbor can be implemented by using heaps and a priority queue, well, heaps, which are implemented, sorry, priority queues, which are implemented by heaps. And with priority queues, you have basically a strut where, you know, a weight is given to every single node, right? And you sort it by, well, this, this part is a little opaque to me, honestly. So I really do suggest you to watch his video for specifically the implementation of the priority queue. But essentially, what's happening is that it's just another way to extract the nearest neighbors, kind of like we see in this graph, right? That's it. Now, the thing is that a problem that we're facing here now is that, well, so the problem that we're facing here is that this, this is formed by just one tree. Like for example, if this is like the embedding space that we got, it was, we get one tree and we have like a set of nearest neighbors. But this is just like one example. And it's always better to have multiple trees like this, we can build multiple trees like this so that, you know, that by random chance, you know, we won't be missing certain points. And the more trees we build, and we take all of these trees in consideration when making the decision for determining nearest neighbors, it becomes a lot more concrete. So for example, let's say with all the random splits on the same data set, we get this set of points, right, for the nearest neighbors that red X is like probably are the music that we put in. And then the all the nearest neighbors are within these, this purple region. And then with the same set of points, we're going to perform a noi again, we're going to do that random splits. But then this time we get splits over here. And then the last time again, we're going to do it. This is like a third time over here. So because of that, we have like, I don't know, let's say that we wanted to recommend 10 songs for each for each, right? So that means like there will be 10 in this recommended 10 here, 10 here, and they may be overlapping. But then we use all of this combined together in order to make a decision of which ones to actually surface as the nearest neighbors. So I think that's going to be more clear over here, right? So basically what we do, the steps that annoy takes is that, well, we'll basically search all trees until we have K items. So this K items is like, let's say that we wanted to build a recommender where we input a piece of music and we output 10 recommended items. In that case, let's take K to be 10 items here, right? So every single tree that we construct will output 10 items. So let's say if we do 50 trees, I think in the code, you'll see that I do 50 trees. So each of those 50 trees will do 10 items, which means that we have 500 items overall. But now if you take the union and remove duplicates, there's definitely going to be a lot of duplicates because annoy itself is already pretty, you know, even with one tree, it's going to get pretty good examples. So I wouldn't be surprised if all the other trees regardless of the random split would surface similar recommendations. And so let's say from a 500, I don't know, it distills down to like 500, but like 400 of them are duplicates, it distills down to 100 points now that we can use. And now since it's only like 100 points, we can actually compute raw distances for every single one of those 100 points from the query vector, which is the music that we want recommendations for. And it's not too bad. So once we do that, then we can sort them in a ranked order of nearest neighbors or the nearest distances. And all of that, I think, is represented visually here. So you have three decision trees, when in our case, we'll have like 50. We find the candidates, each of the leaves contain like maybe 10 examples, 10 pieces of neighbors. Then you get the union of all of these. So which would probably be like 100, like guys mentioned before, removing all the duplicates, you find the nearest neighbors for all of those 100 from the query point, which is our vector that we want the recommendations for. And then we can rank them to find the nearest 100 neighbors or the nearest 10 neighbors or whatever that is. Right. And that's it. That is the entire nearest neighbor algorithm with annoy using finding approximate nearest neighbors. And you'll find that this is blazing fast. Right. So with that intuition in mind, and I hope that was a respectable explanation, you can always watch his video just to get some more context. But I think this is enough for this video. And it's also a 50 minute video.  Now let's build the recommender with annoy. Very easy. So first of all, the objective is to get the top 10 recommendations for a piece of input music. So right now we need to for this to run this notebook, you need the music.json file from the previous notebook, and then you can run this notebook. But I'll provide it for you. So first install annoy. Now I need this literal eval because like I'm reading from a json file and I want to make sure that all of it is in a json structured manner. You'll see that actually right here when I'm reading the json file. And right now I am reading the class labels from that CSV that I showed earlier, this CSV with all the categories and classes. And let's go back. Where's that? Yeah. So yeah. And then, yeah, just yeah, you could say I'm just doing I'm creating a dictionary out of it. So it's like one would be speech, two would be, you know, whatever, male talking or something like that, just to create a dictionary. So it's easy to access. Now I'm taking the once I read the json file, I'm taking the length of the data set. Like I said, it's a 2000 examples. So we have 2000 pieces of music to play with. Now this is the meat of the code right here. And this is all you really need for annoy. Basically, it's saying, Okay, I want to create an annoy index where we now need to pass in the number of dimensions that each of our samples is, which is 1280. The length of the vector will be indexed. Yeah, cool. Then for every single, you know, every single piece of music in this, we want to add it to the index. Basically, we're saying, Hey, these are the samples we want you to use to kind of like find the nearest neighbors off. So this is our entire world, right? Now I could only pass in 1000 of these 2071 examples, because otherwise it'll crash the program. A way to to kind of, you know, get rid of that. This barrier is probably to decrease this dimensions, which you can do with other, you know, maybe like other dimensionality reduction techniques. But even with 1000, I think that this is perfectly fine. It'll work fine. Right. So now for every single one of these, I want to get the corresponding data, which will be the, you know, the actual vector 1280 dimensions. And we add that vector with an index. So I'm just indexing as, you know, one, two, three, four all the way. And we're just adding it to our index. Next, we don't want to build it. So basically what build is going to do is the, the heavy lifting of like creating those splits, random slips, like 50 times we create those trees that we talked about. Like I said, we have 50 of those trees. The more the better, it just gets you a more accurate representation of the best nearest neighbors and most mix the more approximate nearest neighbors, less approximate and more actual. So for more accuracy, you can use a higher number of trees to build the index. And then you can save the nearest neighbors in a graph in an an file. So cool. That's done. Now, when you want to get the nearest neighbors, well, here I'm indexing every item. Let's say that I want to get the nearest neighbors for item number 193 in the index like that we built here. So item number 193, I want to get that index and I want to get the 10 nearest neighbors for this index, right? This is what we're, yeah. So I want to build an index and get the 10 nearest neighbors for that index. Okay, cool. Right. And what I'm doing right here now, I know like 193 is like a weird number, but that's why I've also like printed out the entire music data set within that index, like all the 1000 examples so that you can see exactly like, okay, here's the index and here's the kind of the labels that are actually given to it. So you can kind of compare, okay, 193. That's like, it's opera music. Okay. So opera music, that's just for intuition so that you can understand. Right. And now what we do is now we have this nearest neighbor index for this will be like the nearest neighbors and I'll store it here. And what I'm doing for every single one of these nearest neighbors, I just want to print it out. Right. And that's what I'm doing. So the first nearest neighbor of course is the 193, which is obvious because that is the same music that we input to the data set. So obviously it's the closest because it will overlap. But the second one is this. So it's basically saying, let me explain every single one of these parts. So each part of these nearest, these are the 10 nearest neighbors, each part is for things in it. This is the index within annoy internally. This is the set of tags that are given to that piece of music. This is the, uh, this is actually YouTube URL that you can use to Google it. And I'll show you right now actually, and this is the starting and ending timestamps and seconds. So let's look at this first one here, right? X T G M R L O, whatever this is, right? So if you go to that YouTube video, that's right here. I pasted it right here. And we want to start at 30 to 40 seconds, right? 30 seconds to 40 seconds is the clip. So that's this. Let's start something like that, right? I'm not playing more because of copyright, but you, you kind of heard that, right? Pretty good opera music. And then, um, so that's the input. And that's also the first closest neighbor, but the, the actual closest neighbor, which it would have been is this song is this one. So it's this video at whatever this K 90 thing is at 80 to 90 seconds. So I think that's this video. Yeah. Can I T C right here? And then at 80 seconds is a basically a, you know, whatever one minute, 20 seconds. So let's play that pretty good, right? So they are actually pretty close to each other. And what you can do is you don't even need to use just, um, I'm just use recycling like whatever is in my index to find the nearest neighbors, what you can do actually in, in actual usage is that you can encode, you take your raw wave file and you can encode it using this, um, this audio set, um, yeah, this audio set processing, uh, actually not the audio set, this demo file. Yes. You can encode it using this demo file just by calling that curl command on your wave file, kind of like this. And then it'll output a set of, um, and then you can get like the embeddings information. And then you can use that embedding in, um, this annoying notebook right here. And in order to, to like feed it into our nearest and into, into this, this thing right here. So here I'm getting nearest neighbor by item, but you can also get nearest native neighbor by vector. So you'd be passing in the vector that you just created and you can get like as many nearest neighbors as you want to from the embedding set. Obviously I can only get a thousand because there's only a thousand here, but yeah, that's, that's pretty much it. Right. And that's, if you understood this, well, I mean, this is all of it, three notebooks, three resources, um, I'm going to put all of this down in the description below. Everything is going to be up on GitHub. The link to that will be in the description down below along with the class label CSV, as well as the data set. If I can get it uploaded, I'm sure like 12 megabytes is not too bad, but I hope this was helpful. I hope you all learned something, understood something, hope the explanations weren't too out of the way. I know that priority queue implementation is a little hazy, but other than that, you can read their entire GitHub too for more information. Please do subscribe, write some comments, start a discussion in the description, in the, you know, description down below in the comments down below. Oh God, long videos. What am I going to do? Okay. Well, I'm going to see you later. Okay. Just do, do what you got to do. Bye.


Patriot Prime Reviews is a channel for adult collectors and may not be suitable for children under 13 years of age. Viewer discretion is advised. Hey, what's going on guys? Patriot Prime here once again and yes, I made it home safe from Baltimore. That was a long drive. It took me five hours from Baltimore back home to West Virginia and that was a long ride when you're by yourself. And as you can tell by my voice, I'm going to apologize. It's a little strange. I did a lot of yelling at TF Con.  I mean, we joked around when we found out we were going to be able to do a panel at TF Con that maybe five people would watch us. That room was almost packed and it was very engaging. I was really surprised. I know Rodimus Primal was able to film that and it's probably going to be up on his channel later on. So that was quite humbling to be part of the opening ceremonies of TF Con 2020. So that was really, really cool. Now, this video is going to be a haul video. I know we did one live with myself, Bert the Stormtrooper, Deluxe Baldwin, Kato and engineer Hoist. But unfortunately, it was a live video. It was kind of grainy at first and it actually derailed into a great train wreck. We had so much fun together. I mean, I'm already missing those guys so bad. And they all made it home to everybody's home safe. I think Hoist is on the road now. Last check-in he had, I believe he was in North Carolina. He had to leave really early. He was the last one to take off. But everybody's made it home or on their way home. Everybody's safe. And yeah, it was an amazing time and it was so cool. Not only hanging out with my YouTube bros, meeting you guys. That was awesome.   I know your YouTube name and your icon, but it was hard to put faces to names and all that good stuff. But still, it was really, really cool once everything got ironed out and we constantly kept running into the same people. People wanting our pictures. It was just surreal, yet awesome at the same time. And I miss it already. It was like when I left the service and all the good friends I made over there. And then you leave and we never know when we're going to see each other again, which sucks. But that's the glory of the internet. So, you know, people complain about social media a lot, but I've made some great friends via this right here. So, without further ado, let's go ahead and get into the haul that I have. The very first item I got was from a member of the channel, Rico Redstar. Excuse me, I apologize. I told you, Rico Redstar, he came up to me, says, hey, I got you this. I know you're a Megatron fan. I got you the Funko Pop GameStop Exclusive Megatron. And he got Kato, a G.I. Joe Funko Pop Exclusive. These are GameStop exclusives. These are the ones that came in the Lunchbox 10. So what makes this Megatron special here is, let me get him opened up, he has the flail on his arm. So he has no fusion cannon, but he does have the flail weapon. So that is really cool. I know a lot of Transformer fans and a lot of toy collectors always piss on Funko Pops, but I think they're fun to collect. I mean, I got a whole wall of them over there. I'm not going nuts getting every one. Transformer ones, but they're cool.  What's next? Oh, next individual came up to me was my buddy Slade that I met at TFCon 2019. He is known as Biohazard Prime. He makes pins and other different accessories, really cool stuff. I'm going to put a link to his channels and not channels, those you got. Instagram and Twitter. So I'm going to put a link to these in the description of this video. So what he gave me, a nice little goodie bag here. Please recycle this bag. I have, I'm going to use this a lot. Okay, this is the big surprise. We'll hold that off. So I got this little plastic Biohazard bag and in it, everything laid out. I got a eraser, Megatron and Optimus Prime. Now I gave Optimus Prime to Bert because Bert's the big that's just prime guy and I kept Megatron and that is sweet. Then let's see, I got a Dreadnock's Patch, a patch of his logo, which is awesome. I like that design. He even has that tattooed on him. So that's really cool. I have a key chain with his logo and I need to make some of those with mine. I like that. That's awesome. Kind of a rubbery logo. Then we've got some pins. I've got, these are the metal pins. Got Grimlock. That's where Wheelie smacks him with the slingshot. A Dreadnock's pin and the Optimus Prime face palm pin. So that was pretty slick. Slade thanks so much for the pins. He also gave me a hat with his logo. So there you go. So that looks really cool. Got to keep mine on though. That's my trademark. I got a lanyard with his logo on it. A flag. I know this is from Transformers Animated. It is the Elite Guard. So I got this little Elite Guard flag or handkerchief, whatever you want to do with it. Let's see. And that was all I got from, no, no, the big thing. He gave me a set of the Magic Square stunnacons, Dragstrip and Dead End or Pillage and Contain. Now I don't have any of these Magic Square legends. I know Deluxe Baldwin and Kato and everybody else just raves about these. I've never messed with any. So I was so grateful. He's like, man, I know you like stunnacons. Here you go. I accidentally ordered two. So Slade, thank you so much. And because of you, I spent $300 on figures I wasn't intending to. But still, awesome gift. Thank you so much. And as I said, I'm going to put a link to his contact information in the description of this video. So let me get all this stuff out of the way so we can move on. Oh, he also gave me, as we were leaving, a Transformers Challenge Coin. You've got Autobot on one side, Decepticon on the other. So if you're at the bar, you're not sure what drink to get. There you go. So Slade, once again, you are awesome. Thank you so much. Get with you. And I want to find out how to make Patriot Prime lanyards and pens and keychains and all that cool stuff because you got some awesome products, brother. All right, so move these out of the way. Next up was I ran into my buddy Fire Talks who had made some special 3D printed rollers for the show. See his logo embedded in the front of that one. So a nice green and gold roller. And he also gave me a Army version that's black and green, completely different. I love his rollers. Oh, wait, I didn't even see this. 2021 right there on the side. That's cool. Yeah, 2021. That's awesome. So yeah, Fire Talks was there. Great meeting him. So that's pretty much all I got while I was waiting in line for the dealer room. Once I got in the dealer room, I had two objectives. Bob Budiansky's autograph, Gary Chalk's autograph. Bob Budiansky had just sat down as I was walking up, I was able to get fifth in line and I had him autograph my Transformers issue number three. There's his autograph right there. As I've said many, many times, this book right here, this is what introduced me to the world of the Transformers and I couldn't think of a better, more fitting thing for him to autograph than my issue number three. So very pleased to have that. I'm going to get this out of the cardboard and plastic. See if I can find a frame for it to put it somewhere in here. And of course, next up, Gary Chalk was running a little late. So I'm just walking around, you know, deciding what I'm going to buy. When Gary Chalk shows up, once again, I just happened to be right place, right time, got right in line. I think it was fifth or sixth again. And I got his autograph on the reissue Optimus Primal. I almost bought the kingdom version, but then I realized that he was kind of heartbroken that he wasn't picked to voice that character. And this is the character I know him from. So I've got Gary Chalk's autograph right there. And again, my buddy who I've talked about before, Brad, the Texas toy hunter, he actually bought both of these for us. And he said, I'll buy the figures, you get the autograph. So I got both of these autographed one for me, one for Brad. So that was cool. And even better was Gary is a veteran as well. I was field artillery back in the day. He was artillery as well. And what happens when two veterans get together? Talk, talk, talk, talk, talk. And it got to the point where I could feel the knives going in my back from everybody in line who'd been waiting.  So I shook his hand, appreciate everything he did. And I moved on, but I probably could have talked to that gentleman for another hour. He is a great individual and just super friendly and he really, really appreciates the fans. Next up, thanks to engineer hoist. I was able to get the TF Con Exclusive Chosen Prime Pistolonics, which is a legend scale version of Megatron, like a mini masterpiece Megatron in black. And I didn't do this in a live show, but I will open these up a little bit so you can see what we got. I'm going to take everything out and remove the clamshell. So there's what he looks like.  I love the collars on that guy. So that is pistolonics. We'll get him back in here. I don't want to drop anything. The problem with these legends figures is everything's so damn tiny. If I lose it in here, then I've got Dipper sleeping right below me. He's will hear it hit the floor and he'll chew it up and swallow it. So I got that. Then next up, because of Slade and giving me those Magic Square Stonokons, I had to get the Magic Square Motor Master or Overlord, which I think is ironic since that's the one figure I really want that I've always wanted and he's called Overlord. But this guy is great. He's heavy. This guy is really, really heavy. So pop him out so you can take a look at him. And he comes with a lot of stuff. I guess all the Minasaur attachments come with him. You've got the truck, the trailer, two different swords, two different guns. I've got a book of extra pieces and parts here. A magazine sized instruction manual. So that's going to be cool. So then after getting Motor Master and the other two, I'm searching all over because I've got to get Breakdown and Wild Rider. Come to find out that was one of the first sets released. Nobody had one. So when Bert and I went upstairs to take a little break and head to lunch, here I have this gigantic dealer room floor of Transformers below me. And I'm on eBay and I ordered the other two. So once I get all of those in, I'll do a review on them. Unless you guys want to see, just pop them out now and then do a big review later on once I get them combined. Okay, so then I'm just wandering the floor. I mean, I'm looking at so much stuff and I'm talking myself out of so much stuff because I only brought a certain amount of money because I paid for the hotel with my credit card because I can get points and miles on that and only brought X amount of cash. So I didn't want to break the bank, which I easily could have because there was so much cool stuff. Then running into the G1 tables, it was so bad because I have so many G1 figures and like, ah, got that, got that, got that. So this trip was mainly third party and after walking around, we're getting ready to leave. I mean, that's all I've got so far. I've got to buy something else. I need something big, something unique that actually fits with my collection. And I bought the Generation Toy Tyrant. This is the Stealth Bomber Megatron from IDW. This is one version of Megatron that I don't own. I had the little deluxe figure a long time ago. I guess I ended up selling it or it broke or something but I don't have him anymore and I thought this guy looks pretty cool but the box, you don't have any idea what he looks like but fortunately with the chosen prime who I bought, can remember I said who I bought from or not bought this from chosen prime, they had a display, huge glass display with all of these figures where you could actually take a look at him and once I found this guy and stared him down I was like, I have got to get this guy because this is a beautiful looking figure and from what the other guys told me this is a re-release and he is included with a flight stand oh, all the stuff's falling out of you he's got a flight stand he has a massive blast effect okay, so here all these clamshell on top of clamshell alright, so here is the figure dropping everything I really don't have much room alright, there is I'll go ahead and take him out so there's the figure he is a pretty decent sized figure love the collar ski moning look at that head sculpt this guy is wicked and of course here is the massive blast effect that you get also, let's get back in there with him you get like I said, there is a flight stand let me see if I can get this open too there we go, you got the flight stand here his fusion cannon and the little clip that you attach to the flight stand what mode you want to display him in so there is the Tyrant so now I can get him all packed up probably edit this later so you don't have to waste your time watching me repack robots so that's it, that was everything I got on Saturday, day one day two we go down and it's slim pickings everything's been gone through but there was one eye, oh almost forgot, I'm trying to go in order tonight, after we got out of the after Bert and I left the lobby bar which we were there quite often there were some people set up in the lobby selling, they brought down like toads of transformers and they were selling parts of their collection, one part of the dealer floor these are just guys there, you're trying to make an extra buck or two so I'm looking through all this stuff and who was it was it Rico again, I think Rico Redstar once again brought down a tub of stuff and he said hey, whatever you see in here dollars, I'm like, well sweet, so I'm looking and he shows me he says, I know you're a Megatron guy I've got this K.O and there's the box I have no idea what it is, Yoo-hoo Yoo-hoo Deformation Figured, it is a K.O Cyberverse Megatron now I've always steered clear of Cyberverse because I thought, man they just look too kitty-fied, but my god look at this guy this is the K.O. Cyberverse Megatron and that's diecast metal right there how sweet is that and he just looks so good though he doesn't need a proper toy hacks Decepticon logo right there, but once I realized that was diecast that was like an instant sell so this is like becoming my Megatron trip I'm not sure if that's his gun or not he's fusing cannon right here I may, that looks like Prime's gun maybe huh oh well free toy inside, free toy inside UHF reference alright so that finishes up day one so the next day we go down and I've got like 60 bucks cash left I'm like okay I want to get something I don't want to break the bank though and there was this item I was looking at over and over again on this one guy's table it's a figure I've been wanting for a long time and he had it for 50 bucks and I asked him, I said ma'am he's been sitting here for two days I will give you 40 for him if that's cool 40 cash right now and he agreed and I got the 2003 robots in 2003 robots in disguise destructicon Scourge this was a KB toys exclusive back in the day he is a repaint of the robot heroes g2 hero he was a repaint of the g2 Optimus Prime man Scourge here is a repaint of the g2 hero Optimus Prime and the hero figures were the ones that had the bellows where you put the missile in, you punch the bellows and the missile flies across the room now I had the Optimus Prime years ago and did not like him he was white, yellow and red and I got him, he was in the collection for a while, ended up selling him I kept the Megatron, I did a review of Hero Megatron which is really cool and a couple years ago I realized there was a version of this guy as Scourge or Nemesis Prime so I've been looking on eBay for a while and I could never find a decent one or one that came complete because he's got the two missiles, you got the gun you got the little air hose and all that stuff, he even has a card I believe right there so really cool looking figure I love Nemesis Prime and the color scheme of Nemesis Prime and what I really like about this one is he's got this really bright yellow bellows right here that the toy does not have, he is black, gray, turquoise and red like Nemesis Prime or Scourge out of B so I cannot wait to get this guy and I'm going to disappoint some mint in box, mint on card collectors because I will be opening this guy up alright so I'm making it home and this isn't really a TF Con haul box but I might as well add him into the video because right before TF Con I was approached by XTransbots wondering if I would review their new and improved 86MXXI Warrior lock this is their version of Cup I have no experience with the previous version which I heard had some issues I also don't have any experience with XTransbots so this is going to be something new for me completely and a big shout out to Mike who helped hook me up with XTransbots to send this my way so you got a great picture a lock right there on the side I love the fact you got like a G1 inspired tech specs right there of course we'll get more into that when I actually review the figure and let's take a look at it I haven't even taken him out of the box yet my wife he came Friday or Saturday and I found him on the dining room table when I got up and went downstairs to get my caffeine infusion so yeah my wife doesn't tell me when I get items in the mail I can't tell you how many toy hacks decals I've almost thrown away so let's go ahead and cut this open it's sealed by XTransbots since 2008 let's see what we got ooh he's in foam you don't see that often anymore so here we got the instructions and we got a little card I'm not going to open all that just yet let's see if the card was metal or cardboard we have his weapons he's got a shark to con tail and his gun and there you have lock him that's a big figure you got lock himself get him out of here oh sweet that's awesome he's got two target masters he's got one two okay two different face sculpts and two different hands that's sweet like I said I have no idea what to expect with it and he's diecast this guy is heavy excuse me I've been holding that coffin for a while so this is really cool I can't get over how heavy this guy is where's something metal listen diecast man you cannot ever go wrong with diecast so like X Transbots thank you I definitely want to know the guy learn him a little bit and I will get that review up ASAP and that's it that's my haul from TF Con it wasn't a massive haul like some of the guys I know Burt when he started packing his stuff up and realizing how much he spent he was in the corner of the room just like it was fun it was worth it I mean we all saved up we all announced we saved up every month to go to this thing I mean other than putting the room on my credit card it was money that I saved that I did not touch our joint account with I told the wife I said this is my trip that I saved up for let me geek out and I want to affect our bill paying whatsoever so it's one of the advantages of doing a couple different jobs working full time and saving up for a responsible adult is what led to all this it's not that I'm YouTube rich by any means but I'm so glad that I actually was an adult this time reeled it in and saved up to get some awesome items that I cannot wait to get in front of the camera and do a full review for you guys and once again you guys you are why I do this and it was so awesome once again it was so many of you to shake your hand to say hi there was so many bro hugs given at TFCon there hadn't been a bro hug break it record oh and speaking of bros yesterday was the biggest mismatch of people you've probably ever seen in your life because there was a football game down the road that was playing at one o'clock yesterday so our hotel was full of Transformer fans and football fans and Bert and I are sitting at breakfast and we're trying to figure out the teams I don't know I'm not a sports guy I'm a big guy and everybody's like hey what team you like and I'm like the Avengers I'm not a sports guy I've never been a sports guy and Bert and I are on our phones trying to figure out okay well we got some fans in orange some fans in purple wonder who's playing and this guy and his son sitting at the table over are listening to us and he finally looks over and goes you guys don't know what teams is playing and we're like no that's why we're looking it up we're not into sports and he goes why you some of those comic book guys like no sir we're Transformer guys and the look on his face was just like just and he just kind of went back to eating and I was making fun of his voice for probably an hour hey what Transformers you got in that bag you make any good purchases today it was funny just I wish I had a camera for the look on his face it was like so many stories this video could go on and on forever with that so big shout out to TFCon thank you so much for hosting the event big shout out to the staff and volunteers I know we got fussed out a lot for not having our masks on but still you were doing your job and kudos to you big shout out to all the fans there was no issues we never saw any fights any arguments nothing everybody it was peace and harmony and just it was perfect it was a great event and as I've stressed in many videos we didn't give a damn what's your religion race color any of that stuff you are a Transformer fan you were one of us and we had a ball oh and we did the Pocky Chip Challenge if you saw that live the guy who watched at the end of the video he is fine we did a follow up video with him and he was a good sport he was like that was interesting I loved meeting you guys I will never eat one of those again I doubt if I ever eat anything spicy in my life ever again so all as well that ends well it's one for the record books it's one that I will always remember and I can't wait until the next one and as I will end this with the new slogan that we all joked about because of that individual it's just oh well when he collapsed we were so worried but he's fine he's great and in honor of you good sir don't forget to like don't forget to subscribe and always remember we almost killed a guy this is Patriot Prime signing out


Now, this may sound rather odd, but sometimes the best in the squad is the one with the cross who can smite like a boss by harnessing the bitch-slap of God. With a maze that even ogres will flee, you'll cast and crush things with glee. Some think they're not strong and those people are wrong.  The support is someone everyone wants on their team, but nobody wants to be.   Having the same armored proficiencies as a fighter and the self-sustaining capabilities of a paladin that's been juicing with unicorn hooves and dragonborn acid. They have so many teeth grindingly infuriating spells at their disposal on top of all that that dungeon masters all over the world universally agree to ban clerics from the game so as to not make encounters absolute nightmares to give proper challenge without throwing approximately 20 black dragons at one cleric alone to keep it balanced. Spells like Flash, Gordon, Buddy Cop, Weapon, and Does My Hand Smell Bad To You are so stupidly strong at such a low level it's easy to forget why so many uncultured swine consider the cleric a designated healer. Anyone who does has either never played the class or considered the sword and shield a viable weapon in Monster Hunter. Wait, unlike most other classes you pick your archetype at first level, and you have oodles, canoodles, and toaster strudels to choose from.  Seriously, with how versatile and independently strong you can build a cleric you can make up an entire party full of purely priests, call it the Amen, and bust down Tiamat's door demanding her lunch money, and she would just build her own toilet to give herself swirly so she wouldn't have to endure the kind of bullying you're about to give her.  Or as useful as Guiding Strike where you can choose to add 10 billion points to your attack roll so you'll be able to swat one flight with another fly's deuce being whipped around on a string like a yo-yo strung around your pinky toe while blindfolded. The only downside is that you'll get a pitiful amount of uses, like a gym two weeks after New Year's.   And now you know how to play cleric, Amen.


I'm a Brigade Safety Officer and my secondary job, I'm a Black Hawk instructor pilot. So for my primary job, just helping people out, ensuring that they stay safe, to try to meet the commander's intent. And my secondary job, I get to fly an expensive Uso equipment and do my job at the same time and get paid for it. I've been in the cab probably two and a half years and what I like about the cab, it's very eclectic, but there's a lot of cohesion here even with being very eclectic. The first part I like of Northern Strike is how many people here, the operations going on. The first time that I've been a part of is we're doing something with inner service, so understanding them, getting smarter and learning something different. I'm Stephen Harper, I am the Maryland National Guard.


We are on kickkick.com. We are live But by the time you see this we probably won't be so just leave a like comment subscribe turn on your post notification bells Let's continue to grow the family from Chicago to the UK If we go live and you happen to miss it and you just want to see some highlights if we have any They'll be on this channel above me. We also got the patreon five three five shows running per week Monday through Friday Might miss some times, but you know, this is everything that's actively on there or has been on there Don't forget the merch you get me And we also got the discord everything is down in the description below the links to all of this. That's in my link tree G4's Exposed for abuse on teenagers in the UK younger offenders jails So all these documentaries if you talking about be hearing about I'm ghosting a little proof or whatever Viewer discretion is advised. I'm here only for Educational purposes. This is on the BBC, right? Undercovering a pretty and G4 is a private security firm isn't for teenagers, right? Undercovering a prison for teenagers Home to these 12 to 18 year olds I would be such a star. He deserves to keep custody officers controlling by menace Even brutality I Understand that these are prisoners, but they are still children at the end of the day I don't think you should be able to work in a younger offenders prison Unless you have children if you don't have kids You wouldn't be a younger offenders prison like you're more likely to like not give up not care You're not more likely to not care that they're children and not realize it One of the world's biggest security firms G4 s is paid millions to look after these young inmates But not like this I See to me like that's that that type of behavior You would never do that in a real prison Like this guy right here in the blue you would never do this to a real prisoner because he might get his get back He might spend a block on you Like you're he's a weirdo to me. That's weird. He's weird If it's around adults and authority figures That behave in such a manner It's not gonna fix him. It's gonna make it worse Tonight we ask is G4s failing some of the most vulnerable youngsters in the country Medway Secure Training Center near Rochester in Kent This is a prison not like other prisons It's home to around 70 boys and girls age 12 to 18 who are accused or convicted of crimes from theft to murder Good little bit of journalism from the BBC finally Here to investigate or did they normally The teenagers are being mistreated bullied and even abused by custody officers I've got a job with G4s who run medway as a custody officer the inmates here are called trainees There's up to eight in each unit looked after by two or three custody officers like me So he went undercover disguised as a prison officer, they're sent here specifically because they're vulnerable or at risk They're also challenging This is Billy not his real name He's 14 years old He's been in and out of trouble for most of his life And is now at medway because he attacked someone He's just arrived from a secure children's home, which couldn't cope with him I bet you 60% at 70 80% of the people in here young offenders are coming from single-parent homes or no-parent homes It's very important as a man to be in your kids life Rather is a whether it's a daughter or a son is very important.  I don't care what type of relationship You want with your baby mama or that you don't like Your kid ain't got nothing to do with it because this is what happens As much as he drives me to the brink of going I just can't do it And you know why that they show this much aggression to male authority figures because they never had one growing up And any type of male authority figure that ever steps in is trying to step in over aggressively Yeah, I remember I was one of these little kids So I know I know I tell you exactly what it what the problem was when when people tried to step in like you Oh, I don't have a father figure. I was not raised by men.   They're not going to respond to it nicely Simple it's still a little boy in there who is just lonely Doesn't know what to do. It's pretty sad really It's Medway's job to keep Billy and the other young inmates say provide high-quality education and rehabilitation Before starting work at Medway G4S provides all new recruits with eight weeks of basic training There are three main grades of custody officer training center assistants like me Team leaders and the most senior duty operations managers We're taught that we must keep youngsters in our care safe and that if there's trouble we may have to restrain them But only if absolutely necessary If we use excessive force we can be disciplined or even prosecuted Prosecution out of the training room and in the prison. It's a different world It's my 13th shift and I'm in a classroom I'm waiting with a female custody officer and three inmates for the next class to start One of them is 14 year old Billy He's shouting at Gareth a team leader who's outside in the corridor with Chris a duty operations manager Gareth comes to the door and tries to get in Then it looks like Billy may be trying to reach for the female officer's radio or keys. I Don't expect what happens next First response means emergency He restrains Billy and I have to help Other officers arrived Including Chris the most senior officer present. He's the one with the red watch He has his fingers on Billy's throat During training we were repeatedly told to always protect. Yo, he has him like this in a headlock It airways Choking anyone is never allowed Dr. Andrew McDonald is one of the most published experts on how to handle challenging behavior Including physical. How's this not child abuse? Like they say these dudes whoever these dudes are these g4 officers that are violating the Violating the handbook and violating these children. This is child abuse.  It's child abuse still He's got his fingers right in there. I can actually see them in there. There's applying pressure there I can't breathe He's telling you he can't breathe. So let go of him That to me is an example of actually excessive force while applying restraint Hurting inmates in this way is against the rules It may also make these youngsters more likely to reoffend If I was a young person in that situation, I just don't hold them like that. I'd be pretty angry Also, these people are role models.   You're pushing 40 your hairline is receding.  I don't know how much weight Garret's putting on Billy's arm and wrist all of it But it looks painful Well, that's a 14 year old probably very traumatized boy The fact that these kids have actually been involved with crime some of them don't make commit some serious crimes Doesn't make them any less human It takes the team of custody officers nearly eight minutes to get Billy into his cell This is like over overkill for sure. They overdid their job He acts tough, but Billy has mental health issues and behavioral difficulties So he has documented mental health issues and this is it only gets worse At the end of it all he looks broken He's scared.  It was not necessary at all. I didn't see the necessity in this I know when these children Wines you up the way was winding that officer up. It can be hard But they are there to do it. So this Billy's mom I hope she's soon the F out of them Bob and to help that child to rehabilitate and I can't see how they're gonna do that Seeing that just completely blows everything I thought out the water Gareth the team leader who began the restraint tells us how he's going to justify it Billy may have been reaching for the radio, but he wasn't trying to grab Gareth Billy was trying to defend himself You know what's crazy? Was trying to have been reaching for the radio, but he wasn't trying to grab Gareth Billy was trying to defend himself Some similar happened to me my sophomore year my junior year. There was an off-duty cop that worked at my high school meathead Definitely did steroids like one of those And I had talked to my Dean already She said if you ever having some issues or you ever angry and you want to leave school Just leave your junior. You're almost a senior like Yeah, cuz we can look we could do that at my school. We could just leave whenever we wanted to cool So one day I was arguing with my girl I don't I don't even I didn't even have a class next. I had an empty mod. No class That's what a my modules were 15 minutes. I think four modules were a class A 40 minute class right 30 an hour class.  I'm like nothing. It's like I see arguing with the girl. I was like, yeah, that's my girlfriend You see people arguing with their girlfriends all the time in school And then I told him I was like, yeah, my Dean said if I need to leave if I'm angry I could just leave you can call her and that's and I told him it's not so don't tell me what to do. I'm like, mm-hmm Okay, so he grabs like I'm like, all right, I don't even want to go there with you I continue to walk. They're not supposed to grab you in high school. They're not supposed to grab Security guys are not supposed to grab you Not supposed to touch you they're not supposed to initiate any contact unless you do unless they're defending themselves So this guy I got my backpack on he you know how the top of your backpack got that little Hook right there. He grabs the top of my backpack and remember in high school. I'm I'm still this big I'm a big I'm not this big. I'm this tall And my junior year in high school. I was like six one I was six one. I was like 190 180 or something but I was pretty skinny.  I swear to god my pinky grazed his lip like this He got on the walkie-talkie and said I've just been I've just been struck by a student I'm like, bro I just laugh I just I get up against the wall. I'm like, I ain't even for the fight you know Like but he's trying to man handle me, but I'm six one But I'm I'm six one. I lift weights. I lift. I'm big. I'm in there I don't lift weights. I'm naturally strong six one and he's a meathead jot like he's in the gym all the time He's trying to man handle me and I'm looking I'm and I'm just holding my ground My center of gravity is just better than whatever he was trying to do And I'm making it very hard for him to move me And I can see it in his eyes his ego is his pride Is so hurt that he lifts weights every day and he cannot move this 16 year old kid I'm like, oh man, dude So and I'm like I tell them I'm like Yo, don't you guys have cameras? There's cameras. I've never struck that I got expelled from school for this For this situation. I got I got expelled For this situation And I'm like, there's cameras. Why am I getting expelled? I didn't hit this dude Y'all can clearly see me walking away and him grabbing my backpack That's enough right there. Y'all don't need to see if I hit him He grabbed my backpack. So at any effort, I'm defending myself. Why are you grabbing my backpack if I'm clearly walking away from Like come on So and me like man, the school wasn't cahoots with everybody they didn't want them I went to keep in mind I'm I went to a predominantly white school. So I'm not saying nothing about the teachers. I'm not saying nothing about the students but but Them handling like the security guards there were bad man. They couldn't They didn't know how to handle like what I came I was coming from like Evanston predominantly black You know I'm saying north side chicago predominantly black Coming to a white school There was no, you know, I was like one of the first People to come over there It was just weird. They're all weird G4s investigates Keep in mind my junior year I had turned it around. I was on honor roll my junior year I was doing all the things that I was supposed to be doing my junior year They ain't getting out. They don't care Gareth and two other custody officers say the restraint was justified You didn't see anything until it happened or No, not really It literally happened in like 30 seconds. Yeah, you're gonna stick together to continue our investigation I feel I have to stick to the story too Three weeks later Gareth is allowed back to work Before broadcast we informed the authorities about our evidence G4s currently runs England's three secure training centers But later this year it will stop running one of them Rainsbrook. Oh man after man, I can I can tell y'all more about this guy, man That security guard that same security guard that did that to me. He was a pedo So I promise you like I literally was walking to class one day. I was late and it was this girl named I ain't gonna name her but like she was she always used to wear Like a little the colorful two tops the shirt I don't know what they called and then she used to wear jean dresses The jean skirts It's this guy. I seen him running full speed To catch her walking up the stairs to look up. I'm like this guy is You're weird like I saw I had knew he was a weirdo already And I think that's what really made him do that type stuff to me. That's what made him take it there You know what I'm saying? Because he knows that I know about him I wish I remembered his name bro because I like thinking back on it is angry at me In spectra of prisons found evidence of abuse G4s still has the contract here at medway. Oh, I named the school. This is Niles north high school I had still hate them to this day. There's nothing that Niles north high school could ever do to make me not like There was some good teachers in there man. Mr. Chan. Shout out mr. Chan. That was my history teacher He made school worth coming to to this day. I love that dude and he don't even know that he made school worth me going there I went to school just because mr. Chan was cool salute to him There are some deep questions to be asked about what was happening here that go beyond Individual star behaving badly. Also, it's got really concerning echoes Of what we found at Rainesbrook secure training center Many of the staff I meet are okay A few are amazing But some really worry me like this man Anthony He was an ordinary officer like me for 18 months before being promoted to team leader I'm supposed to learn from him Here he's boasting openly in the kitchen about hurting a 14-year-old child That's the exact same person that that officer was at that school It's not just Anthony After work at the staff area another team leader also seems to revel in aggression Fingers in the throat Ben his wrist up is that Wait, that's not pissing me off. You little What was he doing? Been rude It's Anthony though who talks most often about hurting the inmates Where Are you going? Yeah Yeah a little bit I laugh a long telling you a lot of this is mid the Ego, that's why if you don't have kids, you shouldn't be working around kids me personally. That's my fault And so he'll continue to trust me, but it's not funny I'm skeptical about these claims until I see Anthony in particular with kids with my own eyes He can be an effective. Is this Billy again team leader, but he can also be a bully Well It's 14 year old Billy who was restrained in the classroom who Anthony picks on a lot I'd reported to Anthony that Billy hadn't cleaned his room It's uncomfortable to see because I've got a good relationship with these lads and they're still kind of laughing and joking But you can tell that they're uncomfortable. I mean essentially it's just bullying bullying kids And bullying them into doing what you want This is another male team leader Matt Billy is difficult and sometimes attacks staff, but it's beginning to look like he's being targeted I was definitely being targeted three times in the last 15 minutes three different staff members Matt tells me he's looking for an excuse to hurt Billy and tries to enlist my help Billy knows what will happen if he gives Matt that excuse To protect the youngsters and staff at medway CCTV cameras record pictures, but not sound except in places like bedrooms classrooms and in the kitchen Like here when Billy mocks Liverpool football club So what does matter hooligan or something like what what's going on?  Like football is a you know, I'm saying But don't touch like it ain't that this is a 14 year old kid This is what I'm talking about these people have no data He Matt cannot have a child because he wouldn't be doing this to a child because if somebody did this to his child He would be you know, I'm saying like on 10 Like that's why I'm glad I'm a dad now. I just hope I just hope all of these teachers And all of these people in put power just know what's going on and I'm in florida don't play with me The rules is different in florida. He got like part of his knuckle and kind of dug it into the back of his head like around there There are no cameras here and Matt knows it His inappropriate behavior is hidden I find it harder to deal with them the violence if I'm honest I mean you think of Abusing these situations and you think it'd be sort of one member of staff Slightly digging a child when nobody else is around but looking at this it's so openly obvious that it is just a day to day Management strategy for them for sure. If he was a full grown adult, they would never go working like adult prisons these dudes Which is despicable It's bedtime Because at the end of the day in an adult prison, you know what the adult's going to do to do? Sugar cattle You got me, you know, that's what's gonna happen Billy up in his cell It sounded like Billy was in pain, but I didn't know why After the late shift at the staff area outside Anthony explains I just keep grabbing it Anthony knew Billy had an injured hand The other custody officers listen and apparently do nothing Key line of defense He's a professional staff Who are prepared to say This isn't right here. I'm not happy with this. I'm prepared to do that It takes staff to blow the whistle And you have to ask yourself the question about why did nobody say look I'm not happy with what's going on here Especially these female officers, they might have kids or something like the older ones like what's going on? Somebody they probably blew the whistle like he just said G4S has had the government contract to run medway since 1998 Last year it was paid more than 10 million pounds My colleagues now trust me. They give me their take on how that contract works G4S gets fined if it officially loses control in any way Like trainees fighting Anthony tells me some staff have found a simple way around it That means they don't report it If you have an incident with four kids, it will get split up into two separate teams That's how they do it, so they don't get fined Anthony claims some duty operations managers have pressured him to lie to avoid fines He tells me that once even when three groups of lads had a fight it wasn't reported. It was covered up And what it didn't go down is It never does. Why didn't unit jumps a kid to dive it down? No, because it's classed you've lost control And we're not here to lose control. No Yeah, I was told that because I was misreporting to avoid fines could be fraud It could be is definitely fraud. I think that is a very serious allegation And I think that something that needs to be specifically investigated And I wonder what has happened since this this interview certainly if that was done with the knowledge of managers at G4S Then I think that would That would be a very serious thing to add to Very serious thing for them to have to answer. I think it would be very disturbing I don't know is whether that in itself is something that needs the attention of the police I've now been undercover at medway for two months Today is my last shift This is Lee not his real name He's 16 years old and an orphan He's my See what I said So billy has no father. It looks this would seem to be This guy has no mother or father Common dad both died before he was 10 years old He has a conviction for robbery and came here from care The second he got up in the morning. I knew he was out of character And I could tell that he was really sad and he's been he's been down for the past couple of weeks This week is the anniversary of his mom's death Earlier Lee was rude to Anthony Anthony's still cross about it L ego from anthony once again Letting a 16 year old who is a 16 year old orphan. What's going on y'all? Who is currently It's his mother's anniversary of it like come on, bro Anthony needs some counseling No, I'm blurry hold on Sadly Anthony's right Lee has a history of self-harm He's treated in his cell put on constant monetary and his room is stripped The last thing to be removed is a towel Lee doesn't want to let go of it My camera only gets a glimpse of what happens, but I see it clearly Anthony came from behind and Pulled him in a reverse choke And pulled him down onto the bed and choked him from behind Really really hard and then he kind of slammed him onto the bed quite hard Anthony needs to be prosecuted in a court of law He needs time. He doesn't need a suspension Doesn't need a suspended sentence. He doesn't need a fine.  Yeah For over three minutes start physically restraining Okay, stop there. He's saying bend his wrist. Yeah, and then he does bend his wrist, right? I mean, it's pretty obvious what you're saying there, which is that the more you struggle and fight The more it's gonna hurt It's as simple as that Um, again, that's an improper use Of those kind of techniques The restraint continues and liars once again on the floor That so much be going through my mind that I can't say when I be watching this type of stuff That's why I just be having a straight face like I'd be like man, listen It's just an abuse of power and it's abuse of methods and child abuse When it's over just like Billy leaves alone in his cell In the staff room Gareth and two other custody Gareth and two other custody officers are gonna be acting like victims Officers concoct a story to justify their actions Okay, there's no cctv in the bedrooms. So it will be their word against the trainees They tell me what to write down Anthony the meat head Stumbled to Anthony looks like he works out and he's on gear How did Anthony stumble to the ground from From from from the I forgot his name the orphan child No offense, but that's what I remember. How Did they be like who reviews these who reads these papers and be like, okay, that sounds plausible That sounds believable like bro Anthony wasn't assaulted yet. I'm told to say that he was When I won't go along with it they try another approach I won't say Lee hit Anthony so they decide I couldn't have seen everything But I did I was at the door throughout He appears to think it's funny Anthony describes what he did to Lee move by move Yeah G4s haven't responded to us about our allegations Didn't have allegations when they were on camera claimed the filming was illegal and that the program shouldn't be broadcast G4s told BBC news They thoroughly met their staff and that external monitors had not raised any concerns These are extremely Shocking allegations and have no part in our business or in any Establishment that looks after young people We were unaware of these allegations until the panorama sent them to us and took immediate action To report them to the police and local authority G4s is paid nearly 140 000 pounds per year per inmate 108 youngsters left here between April 2012 and April 2013 Nearly two-thirds reoffended within a year I've never give up I can't Can't have people treat him like that just because he's in an institution for doing wrong To try and take him the right way is the only way to get him fixed and If he's around adults and authority figures That behave in such a manner It's not going to fix him. He's going to make him worse Since we informed G4s of our evidence They have suspended seven custody officers Gareth who unnecessarily restrained Billy Duty operations manager chris who choked him And team leaders matt and antony who were bullying him Four people Billy has finished his sentence and is out of medway Kent police have launched an investigation Children are currently not being sent here That's good That's good, man I mean That's a start at least man.