It is an industry-wide problem. These LLMs all do it, the biggest ones are bad about it and the smaller ones are slightly worse.
when the creators of these LLMs and the “experts” are saying “well, we can’t really say why it does what it does, we don’t really understand it” that’s the big red warning sign that we shouldn’t be depending on them for anything.
Oh, everyone knows why they do it, just nobody wants to say it.
Any time it comes up with a new variable name or really new anything that isn't 1:1 an existing snippet taken from an open source project, that's the same mechanism as the one by which it "hallucinates".
The difference is not inside the AI, it's outside of it - users desire rewording and renaming for plagiarism purposes, but do not desire it in package names.
This also goes for the code itself. Users desire re-ordering of calls to hide plagiarism, but do not desire such reordering when it changes behavior or makes it harder to read. (And yes, users technically would prefer true new code to plagiarism, but that's not on the offer).
And the rules governing which changes are desired for plagiarism and which changes are undesirable, are too complex for AI to replicate.