Ask HN: How does ChatGPT understand code and how to refactor it?

1 points by rqtwteye ↗ HN
A few days ago I threw 500 lines of pretty bad python code (lots of copy/paste and unnecessary repetition) at ChatGPT. First I asked to simplify the code. It introduced some vsriables. Then I asked to extract functions for repetitive code and it did. Then I asked to add type annotations and it did that too.

I was blown away. It did quickly almost exactly what I would have done but much faster.

Now I wonder how this works. I understand that it calculates probabilities of what should come next based on the learning data. But how does this work for refactoring. Has it seen so much python code that it can also guess from that learning data?

I am definitely very impressed and want to figure how this works especially for specialized domains.

I hope the question even makes sense.

0 comments

[ 3.1 ms ] story [ 12.0 ms ] thread

No comments yet.