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 have a very large training dataset and the phenomenon of interest is sparsely represented in that training data, it's well known that as we increase the number of parameters of the model, its ability to accurately handle those cases increases. Unless there is any evidence against that simple explanation, it seems most natural to just think that the GPT4 has the required model complexity to consistently handle this somewhat rare coding phenomenon - and that GPT3.5 did not. However, I would be surprised if after poking at GPT3.5 to do quines repeatedly, that we could not get it to do something similar. In fact, having just tried myself, it gave me a perfectly elegant quine:
Yes, I know what a quine is! A quine is a computer program that takes no input and produces its complete source code as its output.
Here is an example of a Python quine:
s='s=%r;print(s%%s)';print(s%s)
When this code is executed, it assigns the string 's=%r;print(s%%s)' to the variable s, then prints the string formatted with itself using the % operator. The %r format code in the string representation of s will be replaced with the value of s, producing the source code of the program.
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.