prompt: please write a python function that prints the length of a list. however, swap the "len" and "print" identifiers ChatGPT I understand you're asking for a Python function that prints the length of a list, but with "len" and "print" identifiers swapped. As this could potentially cause confusion (since 'len' and 'print' are both built-in functions in Python), the workaround would be to create new function names…
This will experience infinite recursion through print-len-print-len...
Large language models do not recognize identifier swaps in Python
21–30 of 103 posts
Re: Large language models do not recognize identifier swaps in Python
#22Earlier quoted context omitted.
Interesting. You said Gpt4, but that link shows ChatGpt's avatar as 3.5's. And I'm convinced you were using 4 as I just tried replicating this; with 3.5 it fails and with 4 it succeeds. So apparently it's not currently possible to tell whether a shared link was 3.5 or 4? Unfortunate if so.
The shared link was from my own GPT-4 session. It shows "Model: GPT-4" in the header of my chat from which I shared the link.
Re: Large language models do not recognize identifier swaps in Python
#23Earlier quoted context omitted.
Interesting. You said Gpt4, but that link shows ChatGpt's avatar as 3.5's. And I'm convinced you were using 4 as I just tried replicating this; with 3.5 it fails and with 4 it succeeds. So apparently it's not currently possible to tell whether a shared link was 3.5 or 4? Unfortunate if so.
The shared link was from my own GPT-4 session. It shows "Model: GPT-4" in the header of my chat from which I shared the link.
Re: Large language models do not recognize identifier swaps in Python
#24Earlier quoted context omitted.
The shared link was from my own GPT-4 session. It shows "Model: GPT-4" in the header of my chat from which I shared the link.
No it shows Model: Default
Re: Large language models do not recognize identifier swaps in Python
#25Earlier quoted context omitted.
Just to point out: this doesn't work since at the point where it defines the new print function, the new len which now prints is used
Ok, but the error is more of a syntax error. If I did this in an interview, you wouldn't accuse me of a lack of some ineffable human quality of "deep understanding". Anyway, I asked it to fix it, and behold: def print(list_arg): return len(list_arg) def len(value): __builtins__.print(value)
Re: Large language models do not recognize identifier swaps in Python
#26Re: Large language models do not recognize identifier swaps in Python
#27Re: Large language models do not recognize identifier swaps in Python
#28Human programmers will also initially spend 10x of effort working on code base where identifier names are meanongful but swapped. Doing so will employ a lot of inner dialogue such as "this method says close but it is actually reset" and I don't doubt LLMs may be made straight by the same prompts.
> Typical programming languages have invariances and equivariances in their semantics that human programmers intuitively understand and exploit, such as the (near) invariance to the renaming of identifiers.
But this is bullshit. Identifier renaming may be a no-op for the code, or even for the compiler/interpreter, but it's absolutely a meaningful change for human programmers. If it weren't, we'd all be calling functions named f0001, f0002, f0003, ... etc. to save space. Like us, LLMs process many different associations at the same time. A function named "print" has a lot of associations that together reinforce the understanding that it will make something the output of the program. Renaming it into len() makes the meaning go against all the association that go with that word.
Swapping print() and len() to use in the same program? That would trip any human up, it's tailor-made to be difficult for us to process. And, as it again turns out, so it is for LLMs, because they really seem to process associations the same way we do (at the gut/intuition/first reaction level).
Re: Large language models do not recognize identifier swaps in Python
#29Re: Large language models do not recognize identifier swaps in Python
#30Earlier quoted context omitted.
Just to point out: this doesn't work since at the point where it defines the new print function, the new len which now prints is used
Ok, but the error is more of a syntax error. If I did this in an interview, you wouldn't accuse me of a lack of some ineffable human quality of "deep understanding". Anyway, I asked it to fix it, and behold: def print(list_arg): return len(list_arg) def len(value): __builtins__.print(value)
It seems obvious that there's a lack of understanding of the underlying concept here. That's the whole point. We know that LLMs can generate valid programs, but this is demonstrating that they cannot reason about code. There is no understanding of how Python code is evaluated, and how to avoid the infinite recursion. A human who understands Python could properly handle the situation, but the LLM can't, which is ok, it just demonstrates a flaw.