Guide
Do and do not when you work with LLMs
Problem
A user gets weak or unsafe results from an LLM. The usual cause is not a "bad model". The usual cause is a vague prompt, a bloated context, a cut answer, or a secret in the chat.
Method
Do these steps:
- Write a clear job. Be specific about the outcome, length, format, and style.
- Put instructions first. Put source text after the instructions, with a clear boundary.
- Give 3 to 5 examples when the output format is important.
- For long documents, put the documents first. Put the question last.
- Tell the model what to do. Do not only tell the model what to avoid.
- Use a precise length, such as "3 to 5 sentences". Do not use a vague limit.
- Check why the model stopped. If the answer was cut, increase the output limit or continue the response. Do not use a truncated answer as a complete result.
- Keep passwords, cards, and API keys out of the chat. In Grok Bot, put logins and cards in Vault, 1Password, or a Secure Form.
- For numbers that change, such as prices, ask the bot to look up the current value. Do not trust memory alone.
Do not do these things:
- Do not send a one-line prompt and expect a complete, well-structured result.
- Do not change tool definitions or the start of a cached prompt if you want a cache hit.
- Do not keep stale tool results and the full long chat when the task does not need them.
- Do not treat bot memory as the source of truth.
- Do not paste secrets into a message.
- Do not assume that a large context window removes the need to curate tokens.
- Do not send, publish, purchase, or delete through a bot without an approval rule.
Result
The user gets more reliable answers and fewer unsafe actions. The same rules apply in a chat product and in an API app. The rules do not replace a check of the output. A person must still approve irreversible actions.
Sources
- Anthropic, Prompting best practices: https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices
- OpenAI, Best practices for prompt engineering with the OpenAI API: https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-the-openai-api
- xAI, How Grok Bot works: https://docs.x.ai/grok-bot/how-grok-bot-works