Tags:
create new tag
view all tags

Emails for SIGCSE list about CS and poor use of ChatGPT

Frank Vah

Hi friends. Given ChatGPT 's rise in popularity, I had a couple students test it out for dozens of CS1 programs, and thought I should write the results up in a whitepaper to get the info out more quickly, in case that's helpful to the community. In short:

  • ChatGPT does remarkably well just from the English specifications of programming assignments. For one class, it completed about 45 hours work in just about 1 hour of mostly-mindless copy-pasting, with an average score of 96% from an autograder.
  • However, its code style can be a giveaway. Its code style often departs from the class and book style, using untaught constructs like while(true) loops with breaks (and we couldn't easily train it to use our class's style). Also, for one student using it on multiple programs, code style may vary across those programs in ways that normal students don't do, such as using different indent amounts or line spacings in different programs.
  • And, although it will generate different solutions for different students, it starts to repeat solutions (with minor variations like variable names). So if multiple students (e.g., 5+) use it in a class, they run a risk of showing up in a similarity checker.

What I'll be doing is letting students know this info (enough to let them know they can get caught, but not so much detail that they might find workarounds), because my goal is not to catch/punish cheating, but to reduce the temptation -- nobody speeds right past a cop.

On a related note, I am also looking into ways of using ChatGPT to help students. It can generate examples with explanations (though sometimes with bad style or wrong explanations) which students might use to see more examples (humans learn well through lots of examples), can help debug student code, and more. Looking forward to this next era in CS education!

Thoughts/ideas on either of the above two topics -- detecting cheating via ChatGPT, and using ChatGPT for good -- are very welcome! Frank

Bill Kerney, Clovis Community College

On my first online exam, about 15 students out of 106 in my data structures class used ChatGPT to write their code for them. The earmarks are obvious. As you said, Frank, the coding style used in ChatGPT doesn't match what I teach in class, and there's a lot of other obvious flags as well:

  1. ChatGPT likes using certain kinds of pointless code, such as a private: access specifier at the top of a class in C++ (C++ classes are private by default, so it's unnecessary, but ChatGPT likes doing it).
  2. ChatGPT puts a return 0; at the bottom of main, which is also unnecessary in C++. Most people don't know that the C++ standard allows omitting the return 0; from main() so the code that ChatGPT is trained on always has it. I never use it in my class, and students usually copy my style, so it's another obvious flag.
  3. ChatGPT likes using std::, whereas we use "using namespace std;" (this is obviously a point people will disagree on what is "proper style", but it's another flag). One student who cheated again after being caught cheating the first time tried hiding the cheating the second time rewriting the code and removing the "std::"s.
  4. The variable naming styles change slightly from rerun to rerun in ChatGPT (for example using .size() or .length() will vary from run to run, and it will rotate through snake_case, camelCase, etc.), but by doing it a few times you can get an idea for the range of solutions ChatGPT has, and then scan for that in their answers.
  5. ChatGPT would also write functions I didn't ask it to write (such as a main() with testing code in it), and students would just copy and paste these in as well. The test variable names and test parameters were usually the same.
  6. Sometimes students would hit paste twice, which was hilarious.
  7. The solutions were mostly correct, but when wrong were always wrong the same way.
  8. Where they were correct, it would come up with answers actually too good (like using tricks involving ASCII codes) where students usually would use simpler solutions.
For my second exam, I actually was rather clever with the writing of the homework prompt, and made it impossible for ChatGPT to answer correctly. I had students write a class to hold a "school mascot" with the name of the mascot, the name of the school, etc. in it, with an example of King Triton from UC San Diego (my alma mater). I told them that the default constructor should be, quote, "The mascot for our school" which was very deliberately not specified. As such ChatGPT assumed that our school was UC San Diego, and filled in the default constructor wrong with King Triton instead of the Crush (yes, our school mascot is a verb, don't ask me how that happened).

As Frank said, the submissions were similar enough that it would set off a similarity detector. The solutions were all mostly right, but all made the same mistake (it was asked to preserve an invariant, and it only checked the invariant on the constructor, not the setter/mutator) in the exact same place, which again made it easy to detect.

For shorter bits of code, it will be probably impossible to detect, but at the same time, if you're just using it to look up the name of random_shuffle() or something it is no different than using cppreference or other online references, which I allow.

My advice (and it's still something we're working on here) is:

  1. Run ChatGPT yourself on your assignments so you know what to look for
  2. Tell students you are actively looking for ChatGPT submissions to discourage them from trying
  3. Put things in your assignment that ChatGPT wouldn't know how to code but a student coding by hand would have no trouble with.
I'm not interested in being punitive towards students, my sole concern is that they learn the material.
Topic revision: r1 - 2023-08-01 - CathyBareiss
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback