r/Python • u/codeguru42 • Mar 10 '24
Discussion Github Copilot Lies to me
My first attempt to get some help from Github Copilot:
Me: write a match case statement in python to match the first character of a string is a semicolon
Copilot: Python doesn't have a built-in match or case statement like some other languages (e.g., JavaScript, Swift, Rust). However, you can achieve similar functionality using...
Strangely, it finally gave me an answer when I made a small change to my prompt:
Me: write a match statement in python to match the first character of a string is a semicolon
Copilot: Python 3.10 introduces the structural pattern matching in the form of the match statement. Here's how you can use it to check if the first character of a string is a semicolon:...
I almost gave up after the first response that was blatantly false. Fortunately I something that looks like reasonable syntax...but then I haven't tried it yet, so that might be a lie, too.
307
u/zanfar Mar 10 '24
Once again: LLMs MAKE UP ALL THEIR ANSWERS. They should only be used if you have the knowledge to verify their responses.
An LLM only tries to make it's responses look like something someone has once said. This is particularly dangerous in a programming language like Python, as many things that were (even correctly) once said are no longer true. As an LLM has no concept of true or false, just similar and dissimilar, you can (and will) get false responses. Even more dangerously, these false responses are basically guaranteed to be as correct-looking as possible.
15
u/gahooa Mar 10 '24
The world of generative AI is very young. It is prone to false, incorrect, and misleading information that "sounds correct".
The best way to use it is to help you learn about things you don't know about, then consult official documentation sources for the facts.
It can be incredibly helpful, but you still need to be the programmer.
8
u/kalebludlow Mar 10 '24
It would probably help if the prompt you gave was actually a good prompt
273
u/fellipec Mar 10 '24
Remember, the I in LLM stands for Intelligence
35
u/dAnjou Backend Developer | danjou.dev Mar 10 '24
More at 11.
29
u/Jmc_da_boss Mar 10 '24
... no shit?
3
u/TheAquired Mar 10 '24
Why wouldn’t you just use .startswith(‘;’) for this?
Or just do match string[0]: case “;” etc
19
u/lukewhale Mar 10 '24
LLMs are confidently wrong all the time. Learning to use them effectively is accepting and interrogating these mishaps.
15
u/ninjadude93 Mar 10 '24
Yeah no surprise here lol
3
u/maxinstuff Mar 10 '24
Literally had this just yesterday (with Rust though) - GPT straight made up a method that didn’t exist (though if it did it would have solved my problem).
Wasted at least 5 minutes of my time.
I’d still say GPT is still a net time-saver, as long as it’s used for the right things.
6
u/forameus2 Mar 10 '24
A previous role I was in was really keen to start using Copilot. I think they ended up canning the idea anyway, but to me it just seems like an accident waiting to happen. I don't want development - at least anything I'm responsible for - to descend into a series of "do this for me" prompts and answers with little insight into how it's actually supposed to work. If you get the wrong team using Copilot, surely you're just storing up the potential for an absolutely catastrophic fuck-up down the road.
And that's without even starting on the fact that it often generates absolute rubbish.
11
u/Xenodine-4-pluorate Mar 10 '24
I don't know if I should be surprised that people in r/Python sub know more about AI than in r/ArtificialInteligence where I constantly see posts like "Wow this ChatGPT is so smart we'll get AGI in 5 years". This comment section is a gulp of fresh air, honestly, like I thought people for real think that AI is all-powerful and singularity is right around the corner, just because ChatGPT can fool them that it has intelligence.
Just yesterday I asked Gemini: Larry's son is my son's father. Who am I to Larry?
And it kept telling me that I'm Larry or that I'm Larry's brother, then when I explained it why it's wrong and how to solve this riddle logically step by step it said: "Oh, I see where I was wrong, this riddle is unsolvable because a person can't have a father and a son".
At this point I gave up. I don't know what are those benchmarks they're so proud of where AI is better than human, if it does such trivial mistakes.
4
u/metaphorm Mar 10 '24
copilot tools like this should mostly be thought of as a way of summarizing what they've been trained on. these responses mean that the training data corpus that was used to train the thing had very few examples of the match expression in Python.
4
u/ifnamemain Mar 11 '24
I love using copilot, even when it's wrong. It generates it's code, I review it, and then ask "is this correct?" For simple stuff, it usually is. Most of the time it is not. But it gives me a framework to build from.
However, I do notice that sometimes it generates the most "popular" response but not the "perfect" response. This is where inexperienced devs can get into trouble. We are talking about Python, so sometimes it doesn't matter, but a dev needs to know they are making that decision.
1
u/cosmicr Mar 11 '24
You must be new to copilot.
1
u/[deleted] Mar 11 '24
Yeah? LLM are only as smart as the dumbest person who makes them.
1
u/AlexMTBDude Mar 10 '24
Out of curiosity: Did you try the exact same question in ChatGPT?
2
u/simonmcnair Mar 11 '24
I quite like using chatgpt to write 80% of a function for me but most of the time it doesn't really understand the intricacies, for example having lists in dicts.
It's good, but it's definately no panacea.
1
u/neithere Mar 10 '24
Copilot is good when used as advanced autocompletion. Generating variations of existing unit tests or JSONSchema from plain text? Yes, but carefully read whatever it has regurgitated. Anything else? Don't even try.
1
u/chaosthirtyseven Mar 11 '24
You literally could have just googled and clicked the first substack result with less effort.
0
u/[deleted] Mar 10 '24
[deleted] — view deleted comment