Dataset Viewer
audio
audioduration (s) 1.4
30
| text
stringlengths 35
604
| source
stringclasses 1
value |
---|---|---|
If you're using large language models in production, you'll want a way to log the prompts and the responses. This is useful to evaluate the performance and check for quality in the responses, and it's also useful to gather data that can later be used for fine -tuning. This is true whether you're using private models like OpenAI or Anthropic, or your own custom fine -tuned model. | 0 |
|
Now there are a number of approaches, including using services like Braintrust or HumanLoop, or using libraries like Langfuse, which provide a hosted offering and also offer a way for you to do it on a self -hosted basis. But today I'm going to show you a very simple approach that allows you to take any OpenAI -style endpoint and ensure that all of the data is being logged to a Postgres database. You can run that Postgres database locally, or you can run it on a server, for example on DigitalOcean. | 0 |
|
I've put the scripts up on Trellis OpenAI Logger. This is an open -source and public repo on GitHub. It's also a package that has been pushed to PyPy, so you can easily install this with pip install Trellis OpenAI Logger. I'll start by showing you a very quick example of how to use this logger to log the results or the response that comes back from a quick chat completion, and then I'll show you how to set up a local database very quickly and also set up a database in two different ways using DigitalOcean. | 0 |
|
Now I've just git cloned the repo over into Windsurf, and I've opened up the readme here, and I want to show you how to quickly start and use the Trellis OpenAI Logger. It's very much the same as if you're normally importing the OpenAI library. So instead of importing OpenAI from the original library, you import it from Trellis OpenAI Logger, and you use it in very much the same way. You set up a client by initiating it with OpenAI. | 0 |
|
You pass in optionally your API key and your base URL if you're going to be using your own custom URL or API key. If you're just using OpenAI, you don't need to specify these, but there's one extra parameter you pass in when initializing your client, which is the Postgres URL here. And here I've just put in a local Postgres database, but I'm going to show you how to also put in a remote one that's running on a DigitalOcean server. So let me show you a very quick example. | 0 |
|
I'm going to set up a temporary folder. I'll just make a directory here called temp, and I'll move into that temporary directory. Then I'll create a virtual environment with UVVenv, and I'll install Trellis OpenAI Logger, which is just like installing OpenAI, because this is a wrapper that will send and log your data to Postgres. Now I'm going to run a simple script that will import OpenAI, define a client, point to the Postgres database that I've set up locally. | 0 |
|
I'll show you how to do that later, and get a response from OpenAI using GPT 4 .1 Mini, and print the response. So I'm going to copy all of this. Now before I do that, there's one more step I need to do, which is export my OpenAI API key. So I need to paste it in there. I'm just going to do that off screen now. Okay, I've entered my API key, and now I'm ready to start a Python interpreter. You could just save this little script to a file and do uvrun the script .py. | 0 |
|
I'll paste in that little snippet, and press Enter. And you can see I get back a response, and it's got the answer 1 and 2 added is 3. So that's good. And I'll exit now my interpreter with Control -D. So at this point, I've just sent a query to OpenAI, and now it should be logged. We can take a look at what the log looks like. | 0 |
|
If we go all the way down to a section here on querying the logs, we can connect to the Postgres database locally, and I'll go through this more slowly in a moment. And we can then make a query to inspect the last conversation, just like this. And here you can see the latest record. So you can see the time, the model, the input messages, of which there's just one. The system message would be there if it existed. | 0 |
|
The assistant response, there's no tool calls, latency, and the total tokens. So there you have a very simple example. And now I'm going to show you how you can set up that local database, or how you can point Trellis OpenAI logger to a database that's running on a digital ocean droplet. So first I'll show you that local setup. Just go to the database section, and you're going to have to set up some environment variables. | 0 |
|
Already you can add in your OpenAI key. This will be handy for testing in the same way that I just tested out with the quick demo above. And also you should set a secure password. I recommend not using your secure password. You should put in something else. So you want to create a .env file with these variables. You can just copy paste this code and run it if you wish. Next, we'll actually set up the local Postgres database. If you're on Mac, you do brew install Postgres version 15 and start the service. | 0 |
|
You can find the instructions for Windows or Ubuntu on ChatGPT. Next, we're going to create a database. Now, it'll probably say it'll fail because I've already created it. That's fine. And once it's created, we're going to run this local setup here. Now, I actually should be back here in the logger folder, and I'll run the setup. | 0 |
|
And just to show you what's happening with the local setup here, we're installing dbMate, which is being used to update the database to the structure we want. We're then setting a database URL for dbMate, which will help us with the migrations, and then we're running the migrations. And the migrations are set here in this dbMigrations folder. And it's setting up the way that we store the data. | 0 |
|
So we want to store the model name, the endpoint, the input messages, which is a list of messages, raw response, latency, status code, prompt tokens, completion tokens, total tokens, and then metadata. So this is the format that we're going to store everything in. And then we can run a quick test just to check that the local database is working. And it looks like it is because we successfully connected. That's a simple connection test. | 0 |
|
And if you do want to delete that database, you can do drop db with LLM logs. So this is how we create the local database. If you want to do a test, you can go to logging traces and you can run a ready -made script I have, which is just example .py. So to run that, you first want to source the environment variables, which basically will pass in the database password and then run example .py. | 0 |
|
And when we check this here, this is not working because in my environment variables, I have got an old database URL. And this is actually the correct approach to use if we're going to run from a droplet because we want to point to a remote URL. But we can just set the database URL for the local database like this here at the same time as running. | 0 |
|
So if we just take this command, I should have used the local command here because we are trying to run the local database. You can run it. And what it does is it sends a request. I'll show you the code in a moment. It gets a response and then it logs it. And the request you can see here in example .py, it's getting the connection info for the database from a URL. | 0 |
|
It's testing the connection and then it's going to load up the database URL and create a client using that URL. It's creating a trial -so -openei logger client and then it's getting a response to a simple question here which just says hello. And then it's going to query the log data to make sure that it is actually present and telling us that it has successfully logged and found logs within the database. | 0 |
|
So that's just a simple script you can run to test your database is working. If you want to more manually query the database, you can do exactly what we did in the quick start example which is connecting to the database. This is how it's connected to the local one. And then you can run a simple SQL command like this and it should show us. Let's just run that again. It should show us the last request. | 0 |
|
Indeed, it says hello and here's the response and the latency and then the total tokens. So that's how you set up a local database pretty fast. I'll now show you ways to set up a remote database. This is what you would want to do in production. You want to have a server that is saving your logs. You want those logs to be stored on that server and then you can retrieve them later. And I'll talk much more about retrieving the logs and how to use them for doing evals and doing fine tuning in a later video. | 0 |
|
So let's look at how we set up a remote database this time, a remote Postgres database. And for that, we go up to option two. Now there are basically two ways you can do this with DigitalOcean and the same would apply if you're looking at other providers. You could run an AWS instance, you could run an Azure or Google Cloud. The simplest, well, I don't know what is simplest, but let me describe the two ways. | 0 |
|
The first way is you set up a Ubuntu server and you'd install Postgres and you use that as your database. The second approach is DigitalOcean and other providers will directly provide databases. And so you can directly set up a database using DigitalOcean. That's called a managed database. Now, if you set up a droplet, it will probably be a little bit cheaper, but the managed database has more capabilities, things like backups, for example. | 0 |
|
Now you can enable backups on a standard droplet too, but the managed database probably has got more tailored functionality for running databases robustly. So maybe use this if you're doing a more serious production application. I'll also note that to run Postgres comfortably, you probably want to have two gigabytes minimum of RAM, maybe four, ideally four to eight. So it's going to be hard to run it with the $6 per month droplet. | 0 |
|
And therefore probably it's going to be about $12 per month if you go with the specs that are like this here in my default. So I'll show you how to run both. First, we're going to make sure that the DigitalOcean client is installed with brewinstall .tl or D -O -C -T -L. That's DigitalOcean client. And we're going to then authenticate. So for this, when you run it, you'll be asked for an API key, and then you're going to log in. Now to connect to your droplet, you're going to need to have an SSH key. | 0 |
|
So we're going to create an SSH key, and then we're going to add it to DigitalOcean so it can be used to access the droplet. So here's how you would generate an SSH key. I've already generated this one. And here's how you would add it to DigitalOcean. Okay, and with the SSH key generated, we can now proceed to the automated scripts for creating the droplet. So I'm just going to run those, and then I'll go over to that script and explain how it works. | 0 |
|
It will delete any droplets of the same name if you've created any in advance. So that's what it's doing right there because I had created one for testing earlier. And then it should move to starting up the next droplet. I'll show you now what that startup script looks like, is the create droplet script here. It's going to start off by setting up the droplet name, the SSH key name, that's a default database password, which will be grabbed from your .env file, and I recommend customizing it. | 0 |
|
If there is none, it's going to then use this default, not very secure password here. So here is a quick validation and a warning if it's using the default password. Then it's going to create an SSH key if it doesn't exist already and you haven't created it. And once that is created, it'll move on to delete any droplet that has the same name. Then it's going to create a cloud initialization configuration. This is going to allow us to run the migrations. | 0 |
|
So these migrations match the migrations in the migration file here. I know this isn't ideal really from a coding standpoint. You should have one source of truth. So if you do need to update the migrations, you do need to do it in two places right now. And there's a warning on that in the readme. But this format here matches the logging format we talked about before. And once this cloud init has been set up, I should mention also that dbmate is going to be installed because that's what's actually running the migrations. | 0 |
|
The migrations directory needs to be specified. Then there's going to be a symlink here for dbmate's expected structure. So this is allowing dbmate to run the migrations. And once we've run the migrations, then we have to define the run command, which is going to involve creating this database here. | 0 |
|
First of all, starting Postgres, creating the database, then updating the password, making sure the list and addresses are set, creating the cryptography extension, and then restarting Postgres here. And then we're going to run the setup db script, which should allow us to have the database in the right format with the correct tables. | 0 |
|
So with that script defined, this is a script that will run after initialization, after the droplet is created. We then actually create the droplet here. We're going to specify a 2GB droplet with this droplet name. And once the droplet is ready, we're then going to, well, the cloud init should start. Once the droplet is ready, we'll get the IP. | 0 |
|
We'll then create the droplet and we'll print out the droplet IP and the connection string once that's all been done. Then we'll have to wait a minute or two for the droplet to be fully set up before we're able to update the database URL and then run the example on that remote droplet. So you can see here, this matches what you can see in the script. We've got the droplet being created. We've got this database URL. I'm just going to copy this over into my .env file now. | 0 |
|
And with that done, I can try sourcing my environment variables and running the example. So it looks like we've successfully connected to the remote and we've logged this example here. And again, we can connect manually to see the logs if we like. This time, rather than connecting to the local database, we can source the environment variables, which will set the database URL and connect in this way. So now we're connected to the remote database. | 0 |
|
And again, we can use this query to check what is logged and see the contents of that latest log here. Okay. So we now have shown how to set up a remote database using a droplet and how to query the logs from it. I'll show you now the last way to set up the Postgres database, which is by directly creating a database on DigitalOcean. Just before then, if you want to clean up your droplet, you can run this cleanup droplet script. | 0 |
|
First, you need to exit from the Postgres, which I can do here, just with Control -D or slash Q. So let me now clean up that droplet and move to setting up a direct managed database. I'm going to say no, I won't delete the SSH key from DigitalOcean. So for a managed database, I'll take you through the steps here. | 0 |
|
First thing is, we're literally going to create a database using the creation command from DigitalOcean. We're going to call it LLMloggerDB. And once we've got that created, we're going to try and get the connection URL. Now, actually, the connection URL is already available. So if you want to get it, again, you could run this command, but we can actually find the details here. And you want to put this into your .env file. | 0 |
|
And I recommend putting it in between double quotes. So the way you want to paste it in is something like this here. So I'm going to take that and put it into my .env file. Okay, so with that added into my .env file, I can now source that database URL and run this script, manage DB setup. And all this does is it runs the migrations that are in the DB migrations folder. | 0 |
|
So this is setting up the structure again that we want the logs to be stored in. Now, I can't run this just yet because I need to wait until the database has started up. I can maybe try it and we'll see. So yeah, it's saying no such host. And that's just because the database needs a moment to start up. Once it is started up, though, it will install DB Mate, run the migrations, and then we should be ready to test the connection. | 0 |
|
And I've just given it a moment so I can run this script again. And I think that is run successfully, so we're in a position to run the example file. It's connecting to a remote database, and you can see it's connecting this time to the managed DB on DigitalOcean, and it's logging. | 0 |
|
And yet again, we can go down to the logging section of the readme, and we can query those logs, first by connecting to the database, by sourcing environment variables, and then by running our command here. And we should be able to now see, again, let me just run that. And you can see here the log of the command that we've run through the example. | 0 |
|
So that rounds up the three different ways that you can create a database very quickly with Postgres, locally using a droplet, the cheapest approach that has Postgres installed, or directly creating a database on DigitalOcean. And you now are able to very easily log all of the traces, including the response times and the token usage of any queries you make to an OpenAI -style API. | 0 |
|
I've just shown you how to use actual OpenAI's API but you can also use any other APIs that provide you with an OpenAI -style endpoint. In the next video, or in a future video, I'm going to cover how to use these traces. They're incredibly useful for evaluating the performance of your services. | 0 |
|
They're also very useful if you need to do some fine -tuning because you can take these responses from customers, you can filter out the private data, potentially, and then you can improve on the answers and use those to improve the performance of your LLMs through fine -tuning. That's it for this video, folks. Hope you enjoyed it and let me know your questions below in the comments. Cheers. | 0 |
|
Arc AGI is a set of challenges that are reasonably easy for humans to solve, but quite difficult for large language models to do so. And this is particularly true with the latest set of questions, Arc AGI 2, where there is a rather large prize outstanding for someone who can solve it, albeit not themselves as a human, but using the best possible approach they can come up with programmatically. | 0 |
|
In this video, I'm going to show you the three main strands of approaches I see for trying to tackle Arc AGI problems based on what's been done in previous year's competitions. I'm going to start off by showing you some very minimal examples just to give you a feel for how the approaches work, and then I'll go into quite a lot of depth actually solving the problems from Arc AGI 1. | 0 |
|
Now, before I start, Trellis Research will be submitting a team to Arc AGI 2, and applications are open if you would like to submit to be part of the Trellis team. I'll discuss a lot more about that right at the end of this video. Before I show you how to solve Arc with some kind of programmatic approach, let me show you how I solve it as a human. I'm here on arcprize .org, and I'll put this link in the description where you can try out some of the challenges for yourself. | 0 |
|
Now, I don't think I've tried this one, so I'm going to have to figure it out for myself. The goal is given some input examples that map onto outputs. So here's an input, and it's converted to an output. Here's another input converted to an output. I have to figure out how this input here is going to convert into some kind of output. | 0 |
|
So I'll start off by just reflecting that I see different numbers of holes here on the top, and I suspect that that is going to reflect the color mapping. So here I have no holes, and this is mapping to the one with no holes, and the one with three holes is mapping to the one with three holes. Is that correct? Yeah, that is correct. And here, this is also the case, and this is also the case here. | 0 |
|
So let me see if I can, and it looks like I have two test challenges I have to try out. So is there a way I can copy from input? Yeah. So I've clicked copy from input, and now I'm going to use the fill. So if I have five holes, then I'm going to fill in yellow. If I have four holes, I'm going to fill in with this magenta color. | 0 |
|
And if I have two holes, I'm going to fill in with blue color, which looks good. And I don't have any plan for these other ones. So I suspect I will just leave them. Oh, I see. Actually, over here, this one is omitted, because it's got two holes, and it's not present. So it seems that I actually need to just blank these ones. | 0 |
|
Okay, so I got that right. And the next one here, actually not sure how I guess I just copy from input as well. And if I find one hole, I'll just solve it like this. And if I find two, then I'll do like this. If I find two here, sorry, that's actually three, so that should be red. That's three as well. And there's none for one. So I'll just back these ones. And I think I can submit. And it looks like I'm wrong. | 0 |
|
What did I do wrong? This one here is four, actually, so that should be blue. All right, great. So you can see these tasks, I wouldn't say very easy. But given five minutes, if you're taking your time, you can work your way through them. And I'd recommend playing around with these, you can try out the first evaluation set. These are maybe a little bit easier from the first series of arc. And the second series here is quite a bit more difficult. Now, let's move to the three broad classes of solving these. | 0 |
|
And the three I'm going to cover our first is, let me just describe them in lay terms. The first is coming up with a set of basic operations, for example, flipping the grid by 90 degrees or mirroring it across. And if you have a long list of these basic operations, you can just exhaustively try to combine them and see if eventually you get from the input to the output. | 0 |
|
This is called domain specific language, domain specific language approach, you're essentially writing a language because you're writing these basic operations that you'll then combine. And this approach was winning for a long time by IceCuber. It was winning up as far as I think, just a year or two ago. So that's the first approach we'll go through. The second one, then, is using a large language model. And in the actual test, you're limited on the amount of compute. So you can't use a latest model like all three, for example. | 0 |
|
But we can use it for the purposes of demonstration today. And with a large language model, you could directly try to predict the output grid. But an other approach is to predict a Python program that will convert the input grid to the output grid. And this is nice, because if you have a Python program, you can test whether it is correct on the samples. So you could check whether it's right on these three trailing examples. And there's a good chance that if it's right, not guaranteed, we'll see that. | 0 |
|
If it's right on the training examples, you'll be able to apply it to the test input and know with reasonable confidence that your output is going to be correct. So those are the first two approaches. The first is combining these little operations. The second is writing a program, just using a language model. And by the way, you can write many programs, and you can test them and only keep the ones that actually work, and then use the ones that work to submit your final answer. Now, the third approach, then, is to train a neural net. | 0 |
|
So you take these examples, you feed them into a neural net that's predicting the output, and you do lots of training and back propagation, like fine tuning a language model, and it will be able to predict an output grid. And this is a general description for the winning approach last year, it was by training a neural net. But there are some modifications that improve the performance on that, which I will get into. | 0 |
|
One is that in addition to training it on lots of sample examples of ARC, including ones you make up synthetically, you get a lot of boost in performance, if you additionally, at the time of making a submission, you grab these training samples, and you further train the model during the competition, if you like, because that specializes the knowledge of the model, and gives it a better chance. | 0 |
|
So you can take a model that's been a neural net that's been trained in lots of examples, then you further train it at the time of being in the competition on these training examples. And then you run the test example. And this is called test time training. And I'll go through how that works. And there's one further addition that can help you refine your choice of final grid, that's called depth first search. So if you've watched a lot about ARC, you might be familiar with that, but I'll cover it in a bit more detail later. | 0 |
|
So there we have the three approaches, the main specific language, these little programs that we write, and then we try to combine them. Then we've got the LLM approach to writing Python programs. And then we've got the neural net training approach. So I'll now explain each of those in very simple terms with the help of chat GPT. And then I'll go into much more detail by showing you a repo that I'm going to make public when this video is launched called trellis research minimal arc. | 0 |
|
And within it, you will find links to very basic examples for each of those three approaches I described. And then you will find folders. So you'll find one detail folder for domain specific language, one for LLM, LLM GS, that's LLM guided search, which is inspired by the approach Ryan Greenblatt took. I don't use a lot of his improvements, because I keep it very basic, but he took it a lot further. | 0 |
|
And then there's test time training, and I'll go into pretty big detail with running all three of these. So let's take a look at a simple level how the DSL approach works. And we can start by considering a much easier example than the ones I showing you here on arc. And the example we look at. So the little riddle or task that I'm going to create is as follows, we're going to start with an input grid, just of ones and zeros. So you can consider just two colors. | 0 |
|
And we're going to have a training input that just has a column of ones, columns, and a training output where there's a row of ones. So you can probably see already that the operation here that's happening in the training example is a rotation, we're just rotating the grid. So the rows become columns. And the question we're posing in this task is to consider this input, and see if we can predict what the output should be. And given this is a rotation here, the correct answer to this input here is going to be a rotation. | 0 |
|
And the specific way I want to solve this is using a a domain specific language. So I want to set up a battery of basic operations. And then I want to run a search that combines these operations, and see if we can find one that matches the training example. And if it matches this, then we'll apply it to the test example. And then we will have our answer, hopefully. So I've input this here, I've said consider this training grade of ones and zeros. | 0 |
|
And this test input, I want you to write a very simple domain specific language type program, with some very simple primitive operations and run a search to find a series of transformations that matches the training example, then apply that program to the test. So here we have ChatGPT 03, just rephrasing the problem, the task that I've posed. And here's ChatGPT coming up with some primitive operations. So pretty basic stuff, identity, rotations, and then some flips. | 0 |
|
Now, obviously, this is a very easy problem. Because if we have a primitive rotation, and the problem I set is rotation, I'm setting us up for success. But you can imagine how this generalizes by having a combination in the training or in the test questions, a combination of these different operations. Okay, so we have the primitive operations, they've been identified here in some kind of a dictionary. And then we're going to apply the operations. And we're going to do a brute force search. | 0 |
|
And we're going to search for combinations of up to three of these primitives. So we're going to look at applying up to three, we don't need three, because it's just a simple operation. So it'll converge very fast after just trying one. But in principle, and you'll see later on, we do need three or even four. In fact, IceCuber uses four. And it's kind of amazing, just four gets you pretty far, at least on ArcGGI 1. So this script is run, and I'll share this link, so you can check it yourself. | 0 |
|
But basically, the solution that's found is rotation by 90 degrees. And if you do that, you're going to get this output here, which indeed is rotated by 90 degrees. And then if you apply it to the test problem, you take this test problem and rotate it, you do get the correct answer here. So yeah, this is pretty much it. This is the essence of the main specific language. And to make it work, I'll talk much more about this later. | 0 |
|
You need to have a very good set of primitives. And by primitives, I mean simple programs, not just flipping, not just mirroring, but you need some more complicated ones like filling in the border of a color of a yeah, of a color, maybe a patch of a certain color, filling in the right hand side, slicing out the middle. So you can think up of all these basic primitive operations. | 0 |
|
And of course, the more you come up with, the higher the chance you might be able to get the right combination, but also the larger the search space. So if you have 40 different primitives, there's a lot of ways you can combine those. So it's going to take you longer to brute force search through all of the options. There are some things we can do to reduce the search space. So what we find is a lot of the operations, they will result in the same intermediate grids. | 0 |
|
And we can avoid ourselves recomputing intermediate grids by just keeping a table of those we've already considered. So there are tricks like that we can do to reduce the search space. But broadly speaking, this DSL approach is all about defining some basic programs, and then combining them brute force, one after another, to see if we can get a match on the training pairs. And if we do, we then apply it to the test pair. | 0 |
|
Okay, let's move on to looking at this time, the LLM guided approach. So here, the idea is the same. Well, the problem, I'm going to pose it as the same as this basic rotation. So we expect it to rotate this and get the right solution. But I want chat GPT to write a very simple Python program based on the training transformation that predicts the output of the test input. | 0 |
|
So yeah, we're literally using O3 to come up with a Python program. In my later example, I'm going to use Gemini, which it's not as strong as using a model like O3. But for illustrative purposes, I've picked a cheap model I can run quickly. But here we're using O3, and it's easy. So O3 is going to get it. We've got a rephrasing of my problem. | 0 |
|
And O3 recognizes right away that one way you can match the training input to the output, one transformation, one way you can describe that you can describe it with a rotation. But this is probably testament to me picking a bad example. You can also achieve it by doing a transpose, which is a flip. And you can get from input to output. And if you apply that flip, you will also actually in this case, get the same result as if you do a rotation. | 0 |
|
So chat GPT or O3 predicts the output for the training example correctly, and then predicts the output for the test correctly as well. And again, a very simple example. But if you expand this to more difficult problems, you're again going to try and ask your language model to create some kind of Python program, you will then run the program. | 0 |
|
And if the program does match on the training example, you can consider there's a good chance it's going to be the correct program, particularly if there are multiple training examples, and it's correct on all of those. That means the program is pretty likely to give the correct test output when given the test input. Now, why wouldn't it give the correct test output? There may be different ways to achieve the training transformations. And we'll see that actually in one or two of the ArcGGI 1 problems. | 0 |
|
And this is probably part of the reason why in ArcGGI, you can submit not just one answer, but two answers. So even if there were kind of two ways to get the training transformations, you can submit two answers for the test, which allows you a bit more flexibility and definitely makes overall the challenges a bit easier. Now, why doesn't this work very generally? Well, when you have small grid grids, the language model doesn't have much problem recognizing the structure. | 0 |
|
But as the grids get bigger, it's very difficult for a language model to see patterns, particularly messy patterns like the one that I solved earlier. So here, well, I'm on the first task. But if you go back to one of the ones that I solved, like this one here, this is going to be very messy. | 0 |
|
And if you ask a language model to describe this in abstract terms and say something like, there are two green blobs on the left that have one hole of size two, and to the right of that, there are two yellow blobs. And then just below that, there's a red blob with three holes of size one each, it will have a very difficult time giving that kind of description that I just gave. And if you can't describe abstractly what's happening here, that makes it very difficult to understand what the transformation is. And that's why it's called ARC abstract reasoning challenge. | 0 |
|
And yeah, that's what makes this very difficult. So this is the second approach. The third approach now is neural net. So with neural net, the idea is you take lots of examples, and you train a neural net given these examples, and given a test input to predict the correct the correct output. So let's take a look at this one. And my prompt here, let's consider the following task, my task is the same. | 0 |
|
It's just that rotation, or transpose, it turns out, I want you to write a very simple program in numpy to train a tiny neural net that is auto regressive and uses attention. Now, you don't have to do this doesn't have to be auto aggressive. But since transformers are working in many domains, the winning approaches, at least in the 2024 have also been transformers. And they typically use small LAMA models, sometimes a T4 or T5 model from Google. | 0 |
|
I'm not sure that much of the language ability is really being leveraged. It's really just that they are transformer models that contain attention, which means they are able to characterize the relationship between all of the input tokens. So I'm going to ask GPT here, what you should do is define a training dataset with some basic transformations, they should have train and test examples. So I'm basically trying to get it to make up some training data here. | 0 |
|
Now, it's definitely a bit cheating that it knows in advance what the test problem is going to be. But nonetheless, I wanted to create some training data. And when making the training dataset, do not use the task I showed above, because that would be cheating. Do create a variety of simple task examples involving various operations to generate them. So I'm actually kind of getting it inspired to use a DSL type approach, domain specific language approach, where it's using basic programs to create test examples. | 0 |
|
If you want a repo or an approach that does that, you can look up rearc or rearc to generate lots of synthetic data. Be trained the small neural net, just train on CPU, because I know that now chat GPT will not provide me access to a GPU here, although maybe sometime it will, that would be cool. By the way, data for the training should have a train example followed by a test example. And focus on the and focus the loss on the test output. This is a nuance we get to later. | 0 |
|
But we have to flatten the whole problem. So we're going to flatten the whole examples, we're going to have the problem part, and we're going to have the solution part. And when we back propagate through the weights, we typically want to weigh this way the update on how far the solution is. We don't want it to be trying to predict what the next part of the problem is. Now, you can kind of see intuitively why that might make sense, because you want the model to really focus on getting the answer right, less the problem. | 0 |
|
Actually, it's empirically found to be the case, too. It turns out that you want it to be good at finding the solution to the test problem, but also the solution to the training problems. Because remember that the full task description is a series of training problems, which will go training input, training output, training input, training output, then test input, test output. And it turns out you do well by turning the loss on for all of the outputs, the training outputs and the test outputs. If that's not clear, don't worry, because I'll go over in more detail later on. | 0 |
|
And then C, run the neural net on the example above, and see what you get out. It taught for 10 minutes and 10 seconds. So I mean, this is this is pretty good. The result is pretty good. So we have a tiny autoregressive net with attention in numpy. I didn't use PyTorch because I was worried it might try and use CUDA or something. We're going to have a sequence length of 27 because we've got nine training inputs, nine training outputs, and then we've got nine inputs. | 0 |
|
Now, you know, in arc, there are typically multiple training examples. So this is a simplified version, only one training example, and then one test input. It's going to make a pretty small model with just eight embeddings and a vocab size of two. So we're doing binary arc zero and one instead of having the full possible 10 colors. Now it's created a few helpers here to make up some test questions like rotating flattening, make meta sequence. | 0 |
|
And it's then going to set up the embeddings and attention weights. So we are going to have attention within this, which is defined here, here's your, your cue, your query, your key and your values matrix. So we're defining attention here, we're making the features, we're making some examples here, and we're defining a training loop. So we're just it's a really simple loop, that's going to train this very small neural net. | 0 |
|
And when we're finished training, and it defaults to a very large number of epochs, actually, it had, it's a very high learning rate, too, but it's a tiny neural network, a large number of epochs. And then it's going to run once it's trained the net, it's going to run the actual example. And we're going to see what we get. And we do actually predict the correct test output. So yeah, this is pretty much how the neural net works. | 0 |
|
And it works very well, if the problems are easy, once the problems get harder, it does not work so well. But we will see some tricks that help improve. And one of those tricks is, well, let me start with one of the problems, one of the problems with this approach here, when you try and predict the output using a neural net, you don't know if the output you're predicting is correct or not. Because obviously, you don't have the answer when you're doing the competition. | 0 |
|
And since you're not predicting a program, you can't check if the program is correct on the training examples. And moreover, you're using those training examples to train, because we're doing test time training, where we train the model initially, and then we train on the examples. Now here, I didn't actually train on the specific example, at least directly. So I'm, I'm not taking the full test time training approach. But we don't have a way to know when we do make a prediction if it's going to be correct. | 0 |
|
And because if you're familiar with language models or any neural networks, there's this concept of temperature, which introduces randomness in how we select the next token, we actually can generate multiple outputs by varying the temperature. And we don't really know which one of those we should we should submit as a final answer. | 0 |
|
Now typically, we will set the temperature maybe to a low value, so that we will pick the most likely, most likely next token, I should be careful not to say the most likely sequence of tokens, because there's a nuance there. But typically, that's called greedy decoding, we'll take the most likely prediction, so it will predict zero, then zero, then zero, then zero. And maybe it's like 51%, 51, 51, 56, 59, 60, 70%, 90%, 90%, something like that. That's how greedy decoding would work. | 0 |
|
But we could also sample at each point. And we would result, we would have different sequences. And actually, you can leverage this to our advantage. So we can decide to do a few different statistical approaches. The easiest to understand is called beam search. So what beam search does is it's going to consider a certain number of parallel streams. So we're going to decode the most likely token, but also the second most likely token, which in this case, there are only two tokens at the first step. | 0 |
|
And then we will proceed step by step. And we will hold on to the two most likely sequences, as calculated by the tokens we've we've seen so far. So we can actually continue on this prompt here and say, Okay, this is good. Let's extend and run the script to do two things. Let's do beam search with a width of three. Now, it's going to be a max width of three, because at the first step, it can only be too wide anyway, and print the outputs and the probabilities of each. | 0 |
|
And then we're going to do another approach, which is called depth first search, which works out well. We'll see that later on with a threshold of 5%. And how depth search first works is instead of keeping a beam of the possible tokens along the way, we actually calculate one sequence all the way to the end. So we make a full prediction, we predict a full grid, like this grid here. And then we backtrack. | 0 |
|
So we will kind of say, Okay, I have this full sequence, this sequence is a probability of 15%. And usually we'll have a threshold percent we want to be above to keep considering it. And I'm going to say, Okay, can I find another sequence that's above the threshold by backtracking by one step. So we'll throw away that zero. And let's look at the next most likely token, which in this case can only be a one. So we look at the one. | 0 |
|
And we'll see what's the probability of this if it ends with a one, and maybe the probability is point one percent. So it's too low. So we'll throw it away. Then we backtrack again. And we say, Okay, what if this zero here was the next most likely color. So here we'd say it's a one. And then we've got this as a one. And we go forward again. And we take the next most likely token. If this here is a one, then we look at the most likely one after that. And we calculate the full sequence probability. And again, check if it's above a threshold like five. | 0 |
|
So this is called depth first, basically, you run out a full sequence to the end, and you start backtracking. And you only keep sequences that are above some probability threshold. And where this works well is, it provides a very exhaustive search. If you set a threshold, and if you also have kind of spikiness in the probabilities. | 0 |
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 72