4 ms·
Tell it not to write so many comments then. You have a great deal of flexibility in dictating the coding style and can even include that style in your system pr
by Maxatar 1y ago
Tell it not to write so many comments then. You have a great deal of flexibility in dictating the coding style and can even include that style in your system prompt or upload a coding style document and have Gemini use it.
- Trasmatta 1y agoEvery time I ask an LLM to not write comments, it still litters it with comments. Is Gemini better about that?
- dheera 1y agoI usually ask ChatGPT to "comment the shit out of this" for everything it writes. I find it vastly helps future LLM conversations pick up all of the context and why various pieces of code are there. If it is ingesting data, there should also be a sample of the data in a comment.
- sitkack 1y agoLLMs are extremely poor at following negative instructions, tell them what to do, not what not to do.
- diggan 1y agoOk, so saying "Implement feature X" leads to a ton of comments. How do you rewrite that comment to not include "don't write comments" while making the output not containing comments? "Write only source code, no plain text with special characters in the beginning of the line" or what are you suggesting here in practical terms?
- FireBeyond 1y ago"Implement feature X, and as you do, insert only minimal and absolutely necessary comments that explain why something is being done, not what is being done."
- sitkack 1y agoYou would say "omit the how". That word has negation built in.
- sroussey 1y ago“Constrain all comments to a single block at the top of the file. Be concise.” Or something similar that does not rely on negation.
- sitkack 1y agoI also include something about "Target the comments towards a staff engineer that favors concise comments that focus on the why, and only for code that might cause confusion." I also try and get it to channel that energy into the doc strings, so it isn't buried in the source.
- diggan 1y agoBut I want no comments whatsoever, not one huge block of comments at the top of the file. How'd I get that without negation? Besides, other models seems to handle negation correctly, not sure why it's so difficult for the Gemini family of models to understand.
- staticman2 1y agoThis is sort of LLM specific. For some tasks you might try including the word comment but give the order at the beginning and end of the prompt. This is very model dependent. Like: Refractor this. Do not write any comments. <code to refractor> As a reminder your task is to refractor the above code and do not write any comments.
- diggan 1y ago> Do not write any comments. [...] do not write any comments. Literally both of those are negations.
- staticman2 1y agoYes my suggestion is that negations can work just fine, depending on the model and task, and instead of avoiding negations you can try other promoting strategies like emphasizing what you want at the beginning and at the end of the prompt. If you think negations never work tell Gemini 2.5 to "write 10 sentences that do not include the word the" and see what happens.
- Hackbraten 1y ago"Whenever you are tempted to write a line or block comment, it is imperative that you just write the actual code instead"
- grw_ 1y agoNo, you can tell it not to write these comments in every prompt and it'll still do it
- nearbuy 1y agoSample size of one, but I just tried it and it worked for me on 2.5 pro. I just ended my prompt with "Do not include any comments whatsoever."