Getting the Proper Reply from ChatGPT – O’Reilly
![](http://thefutureofworkinstitute.xyz/wp-content/uploads/2023/03/speech-bubbles-1441993543oou_crop-4ae2739fa1aa5cd486edf14189d0a92b.jpg)
A few days in the past, I used to be fascinated about what you wanted to know to make use of ChatGPT (or Bing/Sydney, or any related service). It’s straightforward to ask it questions, however everyone knows that these giant language fashions incessantly generate false solutions. Which raises the query: If I ask ChatGPT one thing, how a lot do I have to know to find out whether or not the reply is right?
So I did a fast experiment. As a brief programming undertaking, a variety of years in the past I made a listing of all of the prime numbers lower than 100 million. I used this checklist to create a 16-digit quantity that was the product of two 8-digit primes (99999787 instances 99999821 is 9999960800038127). I then requested ChatGPT whether or not this quantity was prime, and the way it decided whether or not the quantity was prime.
ChatGPT appropriately answered that this quantity was not prime. That is considerably stunning as a result of, for those who’ve learn a lot about ChatGPT, you understand that math isn’t certainly one of its sturdy factors. (There’s in all probability a giant checklist of prime numbers someplace in its coaching set.) Nonetheless, its reasoning was incorrect–and that’s much more attention-grabbing. ChatGPT gave me a bunch of Python code that carried out the Miller-Rabin primality check, and stated that my quantity was divisible by 29. The code as given had a few primary syntactic errors–however that wasn’t the one downside. First, 9999960800038127 isn’t divisible by 29 (I’ll allow you to show this to your self). After fixing the plain errors, the Python code appeared like an accurate implementation of Miller-Rabin–however the quantity that Miller-Rabin outputs isn’t an element, it’s a “witness” that attests to the very fact the quantity you’re testing isn’t prime. The quantity it outputs additionally isn’t 29. So ChatGPT didn’t really run this system; not stunning, many commentators have famous that ChatGPT doesn’t run the code that it writes. It additionally misunderstood what the algorithm does and what its output means, and that’s a extra severe error.
I then requested it to rethink the rationale for its earlier reply, and bought a really well mannered apology for being incorrect, along with a special Python program. This program was right from the beginning. It was a brute-force primality check that attempted every integer (each odd and even!) smaller than the sq. root of the quantity beneath check. Neither elegant nor performant, however right. However once more, as a result of ChatGPT doesn’t really run this system, it gave me a brand new checklist of “prime components”–none of which had been right. Curiously, it included its anticipated (and incorrect) output within the code:
n = 9999960800038127
components = factorize(n)
print(components) # prints [193, 518401, 3215031751]
I’m not claiming that ChatGPT is ineffective–removed from it. It’s good at suggesting methods to resolve an issue, and may lead you to the fitting resolution, whether or not or not it provides you an accurate reply. Miller-Rabin is attention-grabbing; I knew it existed, however wouldn’t have bothered to look it up if I wasn’t prompted. (That’s a pleasant irony: I used to be successfully prompted by ChatGPT.)
Getting again to the unique query: ChatGPT is nice at offering “solutions” to questions, but when you must know that a solution is right, it’s essential to both be able to fixing the issue your self, or doing the analysis you’d want to resolve that downside. That’s in all probability a win, however it’s a must to be cautious. Don’t put ChatGPT in conditions the place correctness is a matter except you’re keen and capable of do the arduous work your self.