Live data from Hacker News

Reverse engineering a neural network's clever solution to binary addition

cprimozic.net

31–40 of 160 posts

Re: Reverse engineering a neural network's clever solution to binary addition

#31

Earlier quoted context omitted.

What's an analog implementation of a Fourier transform look like? It sounds interesting!

Depends on what kind of “analog” you want. In an NN context, given that you already have “transform with a matrix” as a primitive, probably something very much like sticking a https://en.wikipedia.org/wiki/DFT_matrix somewhere. (You are already extremely familliar with the 2-input DFT, for example: it’s the (x, y) ↦ (x+y, x−y) map.) If you want a physical implementation of a Fourier transform, it gets a little more f…

> Another is that far-field (i.e. long-distance; “Fraunhofer”) diffraction of coherent light on a semi-transparent planar screen gives you the Fourier transform of the transmissivity (i.e. transparency) of that screen

Ooh, yes, I’d forgotten that! And I’ve actually done this experiment myself — it works impressively well when you set it up right. I even recall being able to create filters (low-pass, high-pass etc.) simply by blocking the appropriate part of the light beam and reconstituting the final image using another lens. Should have mentioned it in my comment…

Re: Reverse engineering a neural network's clever solution to binary addition

#32
post #19

Earlier quoted context omitted.

A 32-bit adder is just 4 8-bit adders with carry connected. I don't see why it'd be significantly more difficult.

Yes, but the adder that the NN came up with has no carry.

Carry is just the 9th bit?

Re: Reverse engineering a neural network's clever solution to binary addition

#33
post #3

That's awesome - the network's solution is essentially to convert the input to analog, perform the actual addition in analog , and then convert that back to digital. And the first two parts of that all happened in the input weights, no less.

So that's how savants do it ...

Re: Reverse engineering a neural network's clever solution to binary addition

#34
post #27

The essay linked from the article is interesting: http://www.incompleteideas.net/IncIdeas/BitterLesson.html

I think there is no doubt that there must be more efficient model architectures out there, take for example the sample efficiency of GPT-3: > If you think about what a human, a human probably in a human’s lifetime, 70 years, processes probably about a half a billion words, maybe a billion, let’s say a billion. So when you think about it, GPT-3 has been trained on 57 billion times the number of words that a human in h…

I cannot wrap my head around that. I listened to the audio to check it wasn't a transcription error and don't think it is.

He is claiming GPT3 was trained on 57 billion billion words. The training dataset is something like 500B tokens and not all of that is used (common crawl is processed less than once), and I'm damn near certain that it wasn't trained for a hundred million epochs. Their original paper says the largest model was trained on 300B tokens [0]

Assuming a token is a word, as we're going for orders of magnitude, you're actually looking at about a few hundred times more text. The point kind of stands, it's more, but not billions of times.

I wouldn't be surprised if I'm wrong here because they seem to be an expert but this didn't pass the sniff test and looking into it doesn't support what they're saying to me.

[0] https://arxiv.org/pdf/2005.14165.pdf appendix D

Re: Reverse engineering a neural network's clever solution to binary addition

#35
post #3

That's awesome - the network's solution is essentially to convert the input to analog, perform the actual addition in analog , and then convert that back to digital. And the first two parts of that all happened in the input weights, no less.

Sometimes when doing arithmetic with sed I use the unary representation, but usually it's better to use lookup tables: https://en.wikipedia.org/wiki/IBM_1620#Transferred_to_San_Jo...

Re: Reverse engineering a neural network's clever solution to binary addition

#36
post #14

Earlier quoted context omitted.

An 8 bit adder is too small and allows such 'hack'. He should try training a 32 or 64 bit adder, decrease the weights accuracy to bfloat16, introduce dropout regularization (or other kind of noise) to get more 'interesting' results. Addendum: another interesting variation to try is a small transformer network, and feeding the bits sequentially as symbols. This kind of architecture could compute bignum-sized integers.

Yeah, the current solution is similar to overfitting, this wont generalize to harder math where the operation doesn't correspond to the activation function of the network.

Is this true? If it can add, it can probably subtract? If it can add and subtract it may be able to multiply (repeated addition) and divide? If it can multiply it can do exponents?

I don’t know, but cannot jump to your conclusion without much more domain knowledge.

Re: Reverse engineering a neural network's clever solution to binary addition

#37

I liked this article a lot, but > One thought that occurred to me after this investigation was the premise that the immense bleeding-edge models of today with billions of parameters might be able to be built using orders of magnitude fewer network resources by using more efficient or custom-designed architectures. Transformer units themselves are already specialized things. Wikipedia says that GPT-3 is a standard tra…

Transformers are specialized to run on our hardware, whereas the article is suggesting architectures which are specialized for a specific task.

Are transformers not already very specialized to the task of learning from sequences of word vectors? I'm sure there is more that can be done with them other than making the input sequences really long, but my point was that LLMs are hardly lacking in design specialized to their purpose.

Re: Reverse engineering a neural network's clever solution to binary addition

#38

The essay linked from the article is interesting: http://www.incompleteideas.net/IncIdeas/BitterLesson.html

In the years since this came out I have shifted my opinion from 100% agreement to kind of the opposite in a lot of cases, a bitter lesson from using AI to solve complex end-to-end tasks. If you want to build a system that will get the best score on a test set - he's right, get all the data you possibly can, try to make your model as e2e as possible. This often has the advantage of being the easiest approach.

The problem is: your input dataset definitely has biases that you don't know about, and the model is going to learn spurious things that you don't want it to. It can make some indefensible decisions with high confidence and you may not know why. Some domains your model may be basically useless, and you won't know this until it happens. This often isn't good enough in industry.

To stop batshit things coming out of your system, you may have to do the opposite - use domain knowledge to break the problem the model is trying to solve down into steps you can reason about. Use this to improve your data. Use this to stop the system from doing anything you know makes no sense. This is really hard and time consuming, but IMO complex e2e models are something to be wary of.

Re: Reverse engineering a neural network's clever solution to binary addition

#39
Impressive. Am I right that what is really going on here is that the network is implementing the "+" operator by actually having the CPU of the host carrying out the "+" when executing the network?

I.e., the network converts the binary input and output to floating point, and then it is the CPU of the host the network is running on that really does the addition in floating point.

So usually one does a bunch of FLOPs to get "emerging" behaviour that isn't doing arithmetic. But in this case, instead the network does a bunch of transforms in and out so that in a critical point, the addition executed in the network runner is used for exactly its original purpose: Addition.

And I guess saying it is "analog" is a good analogy for this..

Re: Reverse engineering a neural network's clever solution to binary addition

#40
post #14

Earlier quoted context omitted.

Yeah, the current solution is similar to overfitting, this wont generalize to harder math where the operation doesn't correspond to the activation function of the network.

Is this true? If it can add, it can probably subtract? If it can add and subtract it may be able to multiply (repeated addition) and divide? If it can multiply it can do exponents? I don’t know, but cannot jump to your conclusion without much more domain knowledge.

> If it can add and subtract it may be able to multiply (repeated addition) and divide? If it can multiply it can do exponents?

It was just a simple feed-forward network. It can't do arbitrary amounts of repeated addition (nor repeat any other operation arbitrarily often).

Post reply on HN