Hacker News new | ask | show | jobs
by swid 1500 days ago
It's funny to me that this kind of usage of GPT is just programming with a lot of extra steps.
2 comments

If you just ask GPT-3 text-davinci-002 to complete

    Create a Python program to reverse a string:
It produces

    def reverse(s): 
        return s[::-1]
And that isn't even the code-specific model.
What happens if you ask it to evaluate the function it generated, with some input?
Good question.

I just asked text-davinci-002 to complete this prompt:

    Here is some python code:

    def reverse(s): 
        return s[::-1]

    What would this function return for the input "hello"?
And it actually responds:

    The function would return "olleh".

Sadly, when I asked it to try "encyclopedia", it said:

    "aidnocypilecne"
Which is a brave attempt, but not quite right.

To see if it was just making assumptions based on the function name, I tried to trick it with

    def reverse(s): 
        return s + 2

    What would this function return for the input "hello"?
But GPT-3 is too clever for that:

    It would return "hello2".
Also, it even recognizes what the function will actually do, when it's named misleadingly:

    def getLength(s): 
         return s[::-1]

    What would this function return for the input "hello"?
Still produces:

    It would return "olleh".
One last result:

With this prompt:

    Here is some python code:

    def getLength(s): 
         return a.length

    What is the bug in this code?
GPT-3 says:

    The function is called getLength but it returns the length of the string a, not the string s.

That's it, pack it up, we're done here.
Absolutely fascinating stuff, thanks for trying it out! I just wish we had some way of really understanding what's going on under the hood...
I was just thinking the opposite - that by choosing such a tiny problem one might be able to actually develop some intuition about what's going on inside that very black box
I meant it mostly as a joke, but there is a certain amount of irony to it. This goes way beyond prompt engineering - he wrote an algorithm to run on GPT in a way you would not expect a non-programmer to write. I think the idea is cool and the process to write it was revealing.
Right. What non-programmer is going to think to turn a word into character list with positional metadata sprinkled in.
It’s actually weirdly similar to the kind of tricks people use for mental feats like memorizing the order of a complete deck of cards or repeating back a long list of words in reverse order.

When you think about every mental task GPT3 is being asked to do as being something it is being asked to perform immediately and without having prepared and as fast as possible this makes a lot more sense.

Like, a reasonable human response to “quick! What’s encyclopedia backwards?!” Would be more like

“Er.. right. A. I. D. E. O? Oh wait is it one of those OE ligature things? P. A. No, O. P. Hang on did I already say P?”

I used a similar technique for a completely unrelated task. My "original" idea.