r/computervision • • 17d ago

Discussion Codex built a handwritten digit recognizer without training it. It scored 95.1% using fixed weights and hand-written rules. Not sure how impressive this is?

Post image

I recently read that LLMs can write neural-network weights directly, and I wanted to see what that meant in practice. So I gave Codex (GPT6-Astra-Medium) a challenge : recognize the digits 0–9 as I drew them with my mouse on a 32×32 grid. One condition: no training.

Codex wrote formulas for pen strokes and varied their slant, curvature, and thickness. It even simulated what happens when a coarse scan makes a narrow gap disappear. Each synthetic drawing was converted into a weight vector, and a dot product measured how closely my digit matched it.

The recognizer ended up combining fixed weights with hand-written geometry.

The first version scored 66.4%. The final version got 1,709 of 1,797 digits correct (95.10%). The recognition code, including weight generation, came to 808 lines of Python, about 35.6 kB. No optimizer or backpropagation was used.

One caveat: the benchmark was scikit-learn’s 8×8 handwritten digits, resized to 32×32 and converted to black and white. We looked at mistakes on those same drawings as we refined the rules, so 95.1% is a development score. This took about 2h to do. Codex wrote the code and ran the evaluations. I set the challenge and tried it with my own handwriting. To me this is super impressive, what do you experts think?

100 Upvotes

75 comments sorted by

40

u/Wannabe-Davinci 17d ago

I guess the weights of lots of MNIST models are in the training set. If not, the weights would be fully explainable, as the model can predict them.

Try giving it an architecture that does not exist anywhere on the entire internet. Curious how it would perform

-2

u/GenJeppo 17d ago

I think it went another route and didn't use existing knowledge of weights at all. I started my experiment with detecting squares/triangles/circles and then it told me it didn't use weights but other stuff that was invariant that it could use to make the weights directly. I then asked it if this was possible to digit recognition and it said yes and then we tried that.

"The code generates detector weights from formulas for pen strokes. You can run that part without loading a single benchmark image or label. None of the 1,797 drawings became templates, and no algorithm fitted the weights to those drawings."

12

u/Wannabe-Davinci 17d ago

Assuming it uses convolutions (CNN): the filters that are learnt are basic shapes occurring across digits (arc, line, etc.). So for MNIST-like tasks, I guess you can predict the weights/filters as these should convolute/cross-correlate with the digits.

If it could do it for CIFAR, it would be more impressive. I don’t expect it to work at all for ImageNet, unless weights are in the training set

-3

u/GenJeppo 17d ago

Some of that went over my head to be honest (this is not really my field and I don't want to claim it is either by using AI generated response :D ), maybe I inspired you or someone else to do other more advanced stuff here :) The code is available here if you want to look at AI generated code - https://github.com/jesper-adolfsson-001/digits-by-hand

6

u/Wannabe-Davinci 17d ago

Nice experiment for your understanding and thanks for being open this is not your field of expertise. Personally, I will not spend time investigating this as it is not worth my time. I will keep on using backprop. All the best!

76

u/DigitalMonsoon 17d ago

So this is fairly impressive but I wouldn't say completely unexpected for current models. That being said I don't think I would have ever thought to try it.

This is a very common model with probably tens of thousands of different examples in repos so it is well represented in the training data for LLMs.

Cool result and and interesting thing to try.

4

u/GenJeppo 17d ago

Thanks for the feedback, I feel like I dipped my toes into a field (or lake maybe) that I have not that much knowledge of but I thought it was fun to share :)

-19

u/Similar-Bug-350 17d ago

it sounds like you did jack shit tbh

8

u/GenJeppo 17d ago

Did I claim I did something I didn't?

12

u/Expensive_Host_9181 17d ago

Who pissed in your coffee this morning?

0

u/ApprehensiveNerve623 17d ago

Freezing the rules and testing digits from a few people on the original drawing canvas could be a useful next step. A separate score there would check transfer beyond the resized benchmark.

-2

u/stddealer 17d ago

I mean the fact that there are tons of different examples of it should make it more difficult to one-shot for a LLM, as these examples are likely all using different solutions that were achieved by different training runs on different architectures, so finding a common pattern in the weights of all those models would be incredible.

1

u/DigitalMonsoon 17d ago

It wasn't a one shot

15

u/TheRealBobbyJones 17d ago

Granted most people probably don't use neural networks but digit recognition is a common computer vision assignment in college. I've done it. Someone probably could write one by hand with no machine learning that performs pretty decently. Maybe not record breaking scores but high enough to be noteworthy. With machine learning but no neural networks probably could end up over 90%

-26

u/GenJeppo 17d ago

Maybe I just speed ran the last 30 years of computer vision development in 2h doing this ;)

15

u/AFailedProduct 17d ago

Or Astra did it because it’s been trained on existing handwriting datasets. It basically already knew the answer to your test. Tens of thousands of CS students faced the assignment and some fraction of those posted it on the internet where GPT was trained. 

5

u/chief167 16d ago

Please respect the history of the field and the complexity that goes into these problems. This comment of yours shows you understand nothing at all, and more scarily, with a lot of confidence.

Learn the basics maybe?

1

u/exoman123 10d ago

I'd considering continuing to take the meds doctor prescribed to you.

19

u/Infamous-Bed-7535 17d ago

'how impressive this is?'

Not at all.
I would be happy to explain, but this was a long day.

Please check a few facts.

'One condition: no training.' -> 'We looked at mistakes on those same drawings as we refined the rules'No swimming. -> We jumped into the water and started moving our hands.

Some questions.
How does your rule adjustment comparable of the ' LLMs can write neural-network weights directly'.
Based on the description you are doing some kind of template matching whose 'weights' has nothing to do with a neural network.
The original article was not even about writing weights from scratch, just edited existing ones to avoid fatal loops that greatly improved the model's score. (not read the article, but something similar).

Your whole description sounds like a mess and misses the basics of machine learning, data engineering, etc..

2

u/GenJeppo 17d ago

ok, thanks for the feedback.

6

u/Infamous-Bed-7535 17d ago

Sorry I meant no harm. Computer vision is complex, especially if you include machine learing, deep learning, data engineering, etc.. These are kind of different roles with huge depths.

3

u/GenJeppo 17d ago

No offense taken and thanks for actually saying sorry here on reddit. I could also have answered in a nicer way. I know this field is super complex and I did not mean to disrespect anyone so If I did I'm sorry about that.

10

u/LucasThePatator 17d ago

It's also an extremely low score on MNIST. A very simple MLP does 98% easily. Frankly it's a sad state of affairs when this type of stuff gets upvoted here. OP provided nothing and somehow people get impressed.

OpenAI's results also came from a mistake and they've basically been disproven now

2

u/Chemical-Year-6146 17d ago

Is it possible for an expert in this field to handcraft weights for something simple like digit recognition? 

Honestly just curious. 

2

u/chief167 16d ago

Probably not, but I am not sure we can claim that Claude crafted the weights "by hand" either, without seeing the calculations it performed. Mnist is a super popular problem to solve in an entry level machine learning class, and documented in many books. I'd be completely unsurprised if it just somehow had the weights in the training set and got reasonably close without any effort at all.

1

u/Certain-Cod-1404 15d ago

Didn't people use to make convolution filters by hand? But then they just let the network learn them?

2

u/chief167 15d ago

A 3x3 or 5x5 is easy to craft by hand, or even brute force all possible options. And for educational purposes, you can craft them by hand for simple problems.

But anything else will require back propagation. It's even very educational to do the back prop by hand to see how it learns.

Alle these things are part of learning computer vision and machine learning at college. 

But it's absurd to claim an LLM can just come up with the weights without training or without backprop

1

u/Certain-Cod-1404 15d ago

I know im a data science student, just mentioned one way people used to manually come up with weights but its limited to convolutional filters not like dense layers and stuff. This is a classic AI slop post.

0

u/Chemical-Year-6146 15d ago

What's stopping future LLMs from being trained on backprop steps? 

It's both verifiable and there's effectively infinite data for it 

Isn't it possible that we get the same degree of emergence that gave us talking computers? Smells like RSI.

3

u/Certain-Cod-1404 14d ago

Because its cheaper to run backprop on the model than to have a bigger model simulate backprop? And you'll be bottlenecked by the bigger model, one possible use case for llms during the training process is having like dynamic optimizers where an LLM at certain step intervals or events like a big loss spike can modify the LR, roll back checkpoint and change something or even the optimizer function itself

0

u/Chemical-Year-6146 14d ago

Imagine you are flying above a rolling landscape. You can see there's a deep valley. Someone looking at their feet and walking downward cannot see it. We can see in 3 dimensions.

Of course we cannot see in a ~thousand dimensions (for digit recognition) or 10 billion+ dimensions (for LLMs), but I see nothing blocking a transformer from modeling these spaces and navigating that landscape far ore efficiently that backprop.

3

u/Certain-Cod-1404 14d ago

Have you ever trained a neural network?

→ More replies

1

u/chief167 14d ago

I say this with the utmost respect, but please don't try to be an expert in something you are clearly not. Don't disrespect people who spent years learning computer science with your AI dreams. What you say makes no sense at all.

We obviously know about gradient descent. Backprop is already multidimensional by design (look up: what is a jacobian) and therefore locally mathematically optimal. LEARN MATHEMATICS

→ More replies

1

u/chief167 15d ago

But that makes no sense. Why approximate a mathematical function that you already know and can calculate very efficiently and is very sensitive to errors? 

And stop using the word emergence, it gives away you don't understand the theory behind deep learning 

0

u/Chemical-Year-6146 14d ago

Because there is a high dimensional landscape that human brains cannot visualize. A model trained to think in these dimensions could possibly help another model skip or navigate in training. It seems worth exploring.

Now to my rant about your last comment.  I don't know if you're a reductionist, but emergence is the core of everything interesting. 

To prove my point, consider a universe with one particle. Functionally, there is no distance, no gravity, no electromagnetism. Certainly no chemistry.

It takes two particles for distance to emerge. But the forces would stabilize immediately and then be unnoticeable for eternity (ignoring QM for a moment). Only with 3 particles can we observe multiple forces competing. It takes many particles to achieve atoms and molecules.

Regarding DL, of course it's emergent. The high dimensional landscape forms from many data points, to say nothing of the underlying reality creating those data points.

1

u/Certain-Cod-1404 12d ago

Backprop and gradient descent doesn't require human brains to visualize the loss landscape.

0

u/Chemical-Year-6146 16d ago

It also wouldn't surprise me that if a frontier LLM was fed as much weight data as math/coding data it developed the emergent capability to handcraft weights as generally as it can code and solve math.

Not only are the solutions fully verifiable, but even the steps down the gradient descent are verifiable.

The question then is, how much weight and training step data are in the training corpus now?

1

u/LucasThePatator 17d ago

You could probably archieve something. But if you were to try to do it by hand without actual training, probably you would use classical template matching

1

u/everyday847 16d ago

It depends on what "handcraft" means and whether you're controlling for the agent's access to, for example, very rapid arithmetic. You can write down a convolutional filter for "how many horizontal lines are there" but it would take you a while. Maybe that would feel satisfying to some people!

2

u/raddawg 17d ago

While it wasn't in the headline, writing from scratch was definitely in the study that was done. You'd have to read it to know

Writing From Scratch: In benchmark experiments, GPT-6 Astra was asked to generate raw neural network weights from scratch to play MinAtar games (like Breakout and Pong). The LLM successfully outputted the numerical matrices directly, producing high-performing game policies instantly without seeing a single training loop.

Link

1

u/Infamous-Bed-7535 17d ago

Had a look. It is impressive and not at the same time. Technically it implemented a program using the NN architecture and the network. I remember when I learned NN and played with small ones learning simple and & or logic gates. Adjusting the weights the boundary surfaces moving around.

Impressive, but beats the whole purpose of deep-learning (no handcrafted rules, let the universal approximator learn to minimize the error)

4

u/nicman24 17d ago

95 is kinda bad tbf

-5

u/GenJeppo 17d ago

Explain how this is bad achieving this in under 2h with codex?

5

u/LucasThePatator 17d ago

It's worse than what was achieved more than 30y ago by stuff that definitely is in the training set of Astra. Its 'kinda bad'. It's slop

2

u/chief167 16d ago

With sklearn you can get 99% in a 30minute tutorial

0

u/nicman24 17d ago

Can you rely on it? 

-1

u/GenJeppo 17d ago

Rely on it in what sense?

2

u/Academic-Local-7530 17d ago

So you cant rely it, is what your rhetorical question implies.

2

u/Lethandralis 17d ago

How are you sure that some kind of training (not necessarily backprop) is not applied here?

-5

u/GenJeppo 17d ago

I'll let Codex answer that question since this is not really my field of expertise (I can share the code also if you want)

The code generates detector weights from formulas for pen strokes. You can run that part without loading a single benchmark image or label. None of the 1,797 drawings became templates, and no algorithm fitted the weights to those drawings.

But we did use labeled examples as feedback. Codex inspected mistakes, changed rules, reran the benchmark, and kept changes that improved the score. For example, seeing 3s mistaken for 9s led to a rule about the notch on the right edge of a 3. If you count that feedback loop as a kind of training, I think that’s a reasonable use of the word. “Without training” was too broad.

The more precise claim is: the weights were generated from hand-written formulas, and the rules were tuned by hand using benchmark feedback. That’s also why I call 95.1% a development score. We’d need fresh handwriting collected after freezing the code to measure how well it generalizes.

1

u/Lethandralis 17d ago

Thanks, interesting stuff

1

u/GenJeppo 17d ago

Here is the repo if you are interested to look at ai generated code lol - https://github.com/jesper-adolfsson-001/digits-by-hand

1

u/AlbertV999 17d ago

Could you try it over another datasets?

1

u/GenJeppo 17d ago

Sure, give me some links with other datasets and I'll try, the ai generated source is here https://github.com/jesper-adolfsson-001/digits-by-hand

1

u/PetroHIV 16d ago

MNIST Digits dataset is available in Python sklearn in it's full 28*28 grayscale glory https://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html

Edit: typo

1

u/Cold-Conflict6047 16d ago

I tried the same for barcode scanning. The result was the currently best open source barcode scanner: tapirscan.
I think if you have a nice test set for the ai to optimize for, it will work very good. So get a bigger, better test set and you will reach perfect scores. Also I noticed that stronger AI models are able to optimize even further. So Opus 5.5 will find improvements when Astra stops finding any. And Fable 5.2 find improvements once Opus stalls.

1

u/GenJeppo 16d ago

Cool ! I’m using Astra/OpenAI pro plan now and dreaming of using Fable 5.2 seeing its capabilities. Hope OpenAI releases a new model soon :)

1

u/Cold-Conflict6047 15d ago

Yeah, now after the new fable version dropped they just have to update their model as well. Maybe they want to be nice to anthropic and release it after their IPO.

1

u/Certain-Cod-1404 15d ago

Aren't you describing overfitting?

1

u/Cold-Conflict6047 15d ago

of cause you can get overfitting when your set of images it too small, so whenever you reach a state that is getting harder to optimize you could get a bigger set of images. But a better llm is able to figure out better algorithms in the first place, that would lead to better final results, also on an independent test set.

1

u/Certain-Cod-1404 15d ago

you're describing optimizing for the test set, thats by definition overfitting no matter the size, the test set is supposed to be unseen data you use to evaluate your systems performance in the wild, and LLMs aren't really finding brand new algorithms when theyre used in this manner ? they like try to map rules into the model's weights and don't seem to do a good job, OPs system got to 95% accuracy which is like not good for mnist at all

1

u/Cold-Conflict6047 14d ago

I mean you should still split all your data in a train test and evaluation set. Then you tell your AI to only optimize on the train set. The bigger the train set and the better the AI you are using the better will be the result. You can later on check it out with your other sets.

1

u/traderemi 17d ago

Have it thought of using RAG + vector stores for that purpose? That wouldn't imply any ad-hoc formula, just examples of images for each class and similarity computing.

1

u/madeInSwamp 17d ago

I think for this simple examples build a neural network can be easy since LLMs have probably seen tons of them during training.

Even modifying the weights of a larger NN can be possible if we ask to solve a specific task. However if that NN was solving a bunch of other problems (i.e. the NN is a LLM itself), well I think the generalisation is not reliable anymore.

1

u/DadAndDominant 17d ago

One caveat you say, hmm?

1

u/dev-rsonx 15d ago

This is impressive to me. Early neural nets were hand-crafted too, before backpropagation came. If AI can genuinely figure out the weights to produce good features for a given task without hours of multi-epoch training, that would change how we build deep models.

1

u/SmileLonely5470 13d ago

Honestly I feel like with such a constrained problem you could probably just write a script without any NN to detect digits and get a decent score, just using a buncha heuristics with weights tweaked by hand. When I first started programming that was the approach I did but for an identity resolution kind of problem (take Spotify track data and resolve the matching Youtube video for the song based on yt vid metadata).

Although I guess if u tweak the weights by hand that's technically an optimization step 🤔.

1

u/Some_Anonim_Coder 12d ago

From https://github.com/Anyidoho/MNIST-DIGIT-RECOGNITION

Early machine learning approaches adopted by LeCun et al. [3] included linear classifiers (with error rate ranges from 7.6 to 12%), K-nearest neighbors approaches (KNN, ranging from 1.1 to 5%), non-linear classifiers (about 3.5%), support vector machines (SVM, from 0.8 to 1.4%), neural networks (NN, from 1.6 to 4.7%) and convolutional neural networks (CNN, from 0.7 to 1.7%)[2].

[2] C. J. C. LeCun, Y.; Cortes, C.; Burges, “The MNIST Database of Handwritten Digits. 2012,” 2012. [Online]. Available: http://yann.lecun.com/exdb/mnist/. [Accessed: 23-May-2020].

Link to [2] is broken, unfortunately, but as we can see 5% of error is achievable with classical ML approaches like KNN and SVM, so your performance results are not that awesome. On the other hand, getting this results with manually selected weights is an interesting thing. I wonder if it's just overfitting to test, as you've admitted to using test set in training, and I'd love to see what are actual test results(with a new test set model didn't see)

0

u/Axelwickm 17d ago

In my book that's very cool. I think 'hand' programmed ai models are kinda up and coming

1

u/anime_bruh-69 17d ago

If you look at the repo, it is fairly straightforward what the LLM seems to have done. The thing is, MNIST, is fairly straightforward dataset to apply these rules over.

The LLM rewrote code for functions like skeletonize and created rules to classify digits. As OP describes in other comments, it also adjusted the rules based on failures, so I wouldn't really say this is "fixed weight" per se.