Ask HN: How is ChatGPT able to run code?
In https://news.ycombinator.com/item?id=33847479 it seems that ChatGPT was able to "execute" Python code (https://www.engraved.blog/content/images/2022/12/image-10.png). I somehow understand how ChatGPT can generate code (it has been trained on billions of lines of code)... but I don't fully understand how it can execute code. Execution of code requires 100% emulation of a given compiler. If X can emulate 100% a compiler, then effectively X is a compiler. Now, perhaps ChatGPT cannot execute 100% ANY Python snippet of code, but only some subset?
Or is it "just" that the AI has been trained on so much code (and the output of the code executed) that it effectively can replace a Python compiler (or any other compiler)?
4 comments
[ 4.6 ms ] story [ 21.3 ms ] threadOutputting code and poems is one thing (there is no "correct" poem nor piece of code). Executing code is another: there is only one correct execution output for a given piece of code.
I don't know if rigorous CS proofs of "Turing Machine-Emulation" also hold for a Language model.
It gave me the correct code (which shows all 120 permutations when ran in Python) :
It then showed the output, but got it wrong. It listed 24 permutations, then said ‘As you can see, there are 24 possible permutations of the word "safer".‘Interestingly, if you ask it how many permutations “safer” has, not asking about code, it invents some maths that produces 24 (see my reply in another post), so I guess it’s the understanding of permutations which is off.