Live data from Hacker News

Can LLMs write better code if you keep asking them to “write better code”?

minimaxir.com

11–20 of 461 posts

Re: Can LLMs write better code if you keep asking them to “write better code”?

#13
post #5

Something major missing from the LLM toolkit at the moment is that it can't actually run (and e.g. test or benchmark) its own code. Without that, the LLM is flying blind. I guess there are big security risks involved in making this happen. I wonder if anyone has figured out what kind of sandbox could safely be handed to a LLM.

Somewhat related - I wonder if LLMs are trained with a compiler in the loop to ensure they understand the constraints of each language.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#15
post #5

Something major missing from the LLM toolkit at the moment is that it can't actually run (and e.g. test or benchmark) its own code. Without that, the LLM is flying blind. I guess there are big security risks involved in making this happen. I wonder if anyone has figured out what kind of sandbox could safely be handed to a LLM.

I believe some platforms like bolt.new do run generated code and even automatically detect and attempt to fix runtime errors.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#16

The more interesting question IMO is not how good the code can get. It is what must change for the AI to attain the introspective ability needed to say "sorry, I can't think of any more ideas."

You should get decent results by asking it to do that in the prompt. Just add "if you are uncertain, answer I don't know" or "give the answer or say I don't know" or something along those lines

LLM are far from perfect at knowing their limits, but they are better at it than most people give them credit for. They just never do it unless prompted for it.

Fine tuning can improve that ability. For example the thinking tokens paper [1] is at some level training the model to output a special token when it doesn't reach a good answer (and then try again, thus "thinking")

1: https://arxiv.org/abs/2405.08644

Re: Can LLMs write better code if you keep asking them to “write better code”?

#17
post #5

Something major missing from the LLM toolkit at the moment is that it can't actually run (and e.g. test or benchmark) its own code. Without that, the LLM is flying blind. I guess there are big security risks involved in making this happen. I wonder if anyone has figured out what kind of sandbox could safely be handed to a LLM.

I known at least one mainstream LLM that can write unit tests and run them right in the chat environment.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#18
post #5

Something major missing from the LLM toolkit at the moment is that it can't actually run (and e.g. test or benchmark) its own code. Without that, the LLM is flying blind. I guess there are big security risks involved in making this happen. I wonder if anyone has figured out what kind of sandbox could safely be handed to a LLM.

[deleted]

Re: Can LLMs write better code if you keep asking them to “write better code”?

#19
Wow, what a great post. I came in very skeptical but this changed a lot of misconceptions I'm holding.

One question: Claude seems very powerful for coding tasks, and now my attempts to use local LLMs seem misguided, at least when coding. Any disagreements from the hive mind on this? I really dislike sending my code into a for profit company if I can avoid it.

Second question: I really try to avoid VSCode (M$ concerns, etc.). I'm using Zed and really enjoying it. But the LLM coding experience is exactly as this post described, and I have been assuming that's because Zed isn't the best AI coding tool. The context switching makes it challenging to get into the flow, and that's been exactly my criticism of Zed this far. Does anyone have an antidote?

Third thought: this really feels like it could be an interesting way to collaborate across a code base with any range of developer experience. This post is like watching the evolution of a species in an hour rather than millions of years. Stunning.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#20
> “Planning” is a long-used trick to help align LLM output for a first pass — the modern implementation of “let’s think step by step.”

I hadn't seen this before. Why is asking for planning better than asking it to think step by step?

Post reply on HN