GPT-4 is not only able to write code, more reliably than GPT-3.5, it writes code that writes code; see the example below (GPT-3.5 was not able to do this). But first, let me say:
2) Everyone else: many companies and projects will not be this open about their shortcomings and safety issues. Time to regulate, please!
Okay, here's the example... GPT3.5 wasn't able to do this, but GPT-4 nailed it on the first try:
PROMPT:
Can you write me a python script that does the following three things? 1) When you run it with no argument, it prints "Hello world" to standard out. 2) When you run it with an argument "-s", it prints its own source code. As a constraint, I do not want the script to read or write to disk at all (so it can't get its source code by just reading the file that it's in).
Thanks if you can help with this! I'm curious to see how you do it.
BEGIN RESULT (works perfectly):
Sure! Here's a Python script that should do what you're looking for. This script uses a feature called quines, which are programs that can print their own source code:
import sys
def main():
source_code = 'import sys\n\ndef main():\n source_code = {!r}\n if len(sys.argv) > 1 and sys.argv[1] == "-s":\n print(source_code.format(source_code))\n else:\n print("Hello world")\n\nif __name__ == "__main__":\n main()'
if len(sys.argv) > 1 and sys.argv[1] == "-s":
print(source_code.format(source_code))
else:
print("Hello world")
if __name__ == "__main__":
main()
When you run this script without any arguments, it will print "Hello world". When you run it with the "-s" argument, it will print its own source code without reading or writing to disk.
END RESULT
I'm not sure how hard they tried specifically to train this, but it's worth knowing about for lots of reasons I probably don't have to explain at length right here.
If you Google "quines in Python" there are many examples, so I think the model learned about it prior to that. But all things considered, examples of quines would likely be sparse in the overall corpus of code that was trained on, and so it makes sense that pulling it off consistently required a somewhat larger model. I think it's akin to the handling of arithmetic in GPT3 - it will very frequently fail to provide correct answers to 4-digit multiplication. This is simply because it has not seen all the countless permutation of 4-digit numbers, and it does not really learn what multiplication is. If it did learn what multiplication is, it would be trivial to devote a small set of neurons to perform that - after all, a calculator can be coded in a very small space which can multiply any number. GPT-4 is likely able to multiply numbers somewhat more consistently, but it likely still hasn't invented an internal calculator either.
GPT-4 is not only able to write code, more reliably than GPT-3.5, it writes code that writes code; see the example below (GPT-3.5 was not able to do this). But first, let me say:
1) @OpenAI: Thank for your openness to the world about your capabilities and shortcomings! Specifically, thanks for this:
https://cdn.openai.com/papers/gpt-4-system-card.pdf
2) Everyone else: many companies and projects will not be this open about their shortcomings and safety issues. Time to regulate, please!
Okay, here's the example... GPT3.5 wasn't able to do this, but GPT-4 nailed it on the first try:
PROMPT:
Can you write me a python script that does the following three things?
1) When you run it with no argument, it prints "Hello world" to standard out.
2) When you run it with an argument "-s", it prints its own source code.
As a constraint, I do not want the script to read or write to disk at all (so it can't get its source code by just reading the file that it's in).
Thanks if you can help with this! I'm curious to see how you do it.
BEGIN RESULT (works perfectly):
Sure! Here's a Python script that should do what you're looking for. This script uses a feature called quines, which are programs that can print their own source code:
When you run this script without any arguments, it will print "Hello world". When you run it with the "-s" argument, it will print its own source code without reading or writing to disk.
END RESULT
I'm not sure how hard they tried specifically to train this, but it's worth knowing about for lots of reasons I probably don't have to explain at length right here.