Hacker News new | ask | show | jobs
by bcrosby95 1199 days ago
ChatGPT does not understand your code, does not have the same mental model as you do of your code, and from my experiments does not have the ability to connect related but spatially disconnected concepts across even small codebases which will cause it to introduce bugs.

Asking it about these things sounds like it would result in questionable, at best, responses.

2 comments

Saying a machine cannot understand the way humans understand is like saying airplanes cannot fly the way birds fly.
Which is correct and a big reason for why early flight machines had no chance at all of working

Of course, that doesn't tell you whether the machine understanding will be useful or not

I see, that's what I was worried about. It would be really helpful if it could answer high-level questions about a big confusing codebase, but maybe it's not just a matter of showing it the code and having it work.
ChatGPT has a published context window of 4096 tokens. Although, I saw someone on Twitter saying the real figure, based on experiments, was closer to 8192 tokens. [0] Still, that’s an obvious roadblock to “understanding” large code bases - large code bases are too big to fit in its “short-term memory”, and at runtime its “long-term memory” is effectively read-only. Some possible approaches:

(A) wait for future models that are planned to have much longer contexts

(B) fine tune a model on this specific code base, so the code base is part of the training data not the prompt

(C) Break the problem up into multiple invocations of the model. Feed each source file in separately and ask it to give a brief plain text summary of each. Then concatenate those summaries and ask it questions about it. Still probably not going to perform that well, but likely better than just giving it a large code base directly

Another issue is that, even the best of us make mistakes sometimes, but then we try the answer and see it doesn’t work (compilation error, we remembered the name of the class wrong because there is no class by that name in the source code, etc). OOTB, ChatGPT has no access to compilers/etc so it can’t validate its answers. If one gave it access to an external system for doing that, it would likely perform better.

[0] https://mobile.twitter.com/goodside/status/15988746742046187...