This is actually quite impressive. Try reading the comments in the code. The comments often make perfect sense in the local context even if it’s GPT-2 gibberish. The real examples have worse comments at times. The only flaw is that it shows fake code most of the time so you can game it that way.
Some of the "real" ones have absolutely atrocious comments. Two variables labelled with literally just the name of the variable like so: bool hasdied // has died and then a `// done` for seemingly no reason after initializing variables... where did this code come from?!
Try to guess if code is real or GPT2-generated
61–70 of 108 posts
Re: Try to guess if code is real or GPT2-generated
#62I understand that GPT-2/3 is just a very smart parrot that has no semantic knowledge of what it is outputting. Like I guess let's take a very dumb markov chain that was "trained" on the following input:
a.c ``` int array[6]; array[5] = 1; ```
b.c
``` int array[4]; array[3] = 2; ```
I guess a markov chain could theoretically produce the following code:
out.c
``` int array[4]; array[5] = 1; ```
which is undefined behaviour. But it is produced from two programs where no undefined behaviour is present. A better question would be, how can we guarantee that certain program invariants (like lack of undefined behaviour) can be preserved in the produced code? Or if there are no guarantees, can we calculate a probability? (Sorry, not an expert on machine learning, just excited about a potentially new way to fuzz programs. Technically, one could just instrument C programs with sanitizers and produce backwards static slices from the C sanitizer instrumentation to the beginning of the program and you get a sample of a program without undefined behaviour... so there is already the potential for some training set to be expanded beyond what Csmith can provide.)
EDIT: I don't know how to format here...
Re: Try to guess if code is real or GPT2-generated
#63Earlier quoted context omitted.
Same thought here - apparently humans read from uninitialized arrays immediately after declaring them! That said, it is still a pretty fun website :)
I actually ran into a case where I wanted to do this, but was forced not to. What was the scenario? I had a couple of small, fixed-size char buffers and I wanted to swap their valid portions, but the obvious choice of swap_ranges(a, b, a + max(na, nb)) would run into this issue. (n.b. this wouldn't be correct for non-POD types anyway, but we're talking about chars.) On top of it being annoying to not be able to do th…
Re: Try to guess if code is real or GPT2-generated
#64Re: Try to guess if code is real or GPT2-generated
#65The two factors that seemed like dead giveaways were comments that didn't relate to the code, and sequences of repetition with minor or no variations.
If only. Humans leave dead comments all the time and I was wrong when I guessed “gpt” wrote this based on that. Being confusing isn’t reliable either unless it’s a syntax error
I really wish the site let me view my previous guesses.
Re: Try to guess if code is real or GPT2-generated
#66Earlier quoted context omitted.
I actually ran into a case where I wanted to do this, but was forced not to. What was the scenario? I had a couple of small, fixed-size char buffers and I wanted to swap their valid portions, but the obvious choice of swap_ranges(a, b, a + max(na, nb)) would run into this issue. (n.b. this wouldn't be correct for non-POD types anyway, but we're talking about chars.) On top of it being annoying to not be able to do th…
Why would you ever want to swap an uninitialized value into a buffer? You're wasting CPU cycles writing out data that you are guaranteed to never want to use. Why not just do a copy from the source buffer to the uninitialized one (as that is likely the half of the swap that is desired)?
Re: Try to guess if code is real or GPT2-generated
#67I got a function that assigned the same expression to three variables. Then it declared a void function with documentation stating "returns true on success, false otherwise". Apparently that code was written by a human, which makes me either doubt the correctness of that website, or the quality of the code it was fed with
Same thought here - apparently humans read from uninitialized arrays immediately after declaring them! That said, it is still a pretty fun website :)
Re: Try to guess if code is real or GPT2-generated
#68The giveaway seems to be the comments. Some comments a computer could obviously generate and some are obviously written by humans. The code seemed to be irrelevant in making a determination in my playing around with it.
Re: Try to guess if code is real or GPT2-generated
#69Re: Try to guess if code is real or GPT2-generated
#70Would be nice if the back button worked so you could see what you guessed wrong. This is a good example of where POST is used unnecessarily and URLs should be idempotent.