This is the second part of our two-part mini-series on programming with LLMs. It is for everyone, not just developers. Thanks to LLM's help, it is now easier than ever to be a “programmer,” with a few caveats.
In our first edition, we explored these caveats and shared our opinions. If you haven’t, we recommend you go back and read it as an introduction to this piece. Today, we share our 15 best tips for programming with LLMs.
1. Give more context to the LLM
When asking an LLM a question, don’t explain how to solve it. We often make the mistake of telling the LLM, “You should take that variable and do something with it.” Instead, providing more context and letting the LLM do the hard work is more effective. Just ask, “Solve this”, “Find the bug”, or “Is there something odd?”. It’s adding unnecessary biases. Don’t be too specific; you don't need an LLM if you know exactly what to do.
2. Error Handling
LLMs don’t include error handling by default, but you can always ask for it. Just remember to instruct the model!
3. LLMs Are the New Rubber Duck
Often, we start typing a question to the LLM and don’t even finish it. By clearly expressing the problem, we find the solution on our own. The advantage now is that this new rubber duck can respond back.
4. Copy-paste the Error
Don’t bother adding structure or extra information when encountering an error. Copy and paste the code or command with the error stack. Most of the time, the LLM can solve it.
5. Work with the LLM (Not Against It)
Sometimes, you have an idea for a solution, but the LLM suggests a different one. We’ve had instances where we tried our solution first, only to realize later that the LLM’s suggestion was better. What we attempted wasn’t feasible, and the LLM’s approach made more sense.
6. Stop Overthinking
The goal is to offload mental processing from the developer to the LLM. At some point, you don’t need to understand the bug. Let the LLM do its thing, and when it doesn’t work, start thinking about how to improve the prompt. If it doesn’t work, go back to basics and understand the code.
Solving problems is part of software engineers' jobs. In this case, we are trying to say, “Be smart and choose your battles” (aka the things LLMs can’t solve yet).
7. Ask One Thing at a Time
LLMs use an attention mechanism to analyze relationships between words. These massive models can handle many tasks due to their large training data. There’s likely an example similar to your problem in the dataset. However, if you tackle too many things simultaneously, the LLM might go “off track”, mixing up different examples, and have more trouble answering.
The next 8 tips are for our supporters and premium subscribers. If you enjoyed the previous tips, become a supportive member here with a nice discount:
Keep reading with a 7-day free trial
Subscribe to High Learning Rate to keep reading this post and get 7 days of free access to the full post archives.