Tips for LLM prompts

deep learning



April 17, 2023

General tips to get better outputs from ChatGPT.

Tips and tricks for ChatGPT Prompts

This post is a recap of openai’s suggestions (as of writing) for improving ChatGPT’s outputs.

There are many teams actively working on improving and deploying new LLMs with useful (powerful) abilities. Their work has produced several papers that show different ways of improving an LLM’s output.

The official openAI documentation has the full details and discussion of a few key papers.

However, we can also extract a broad set of suggestions based on what the different proposed improvements share in common.

Improving outputs

  • Split large, complex tasks into subtasks
    • Structure and isolate the instructions of each subtask
  • Prompt the model to explain its reasoning(s) before answering
  • If the output was bad, try making the instructions clearer
    • Start with simple and direct language
    • Can get more complex as the conversation and context grow
  • Have the model generate many answers, then ask it to distill them into a single, best answer
  • If possible, Fine-tune custom models to maximize performance

Generic tips

  • Explicitly guide the model through the thought process
    • Helps it stay focused on sub-tasks and subprocesses
  • “Let’s think step by step…”
    • Works best on logical, mathematical, and reasoning tasks
    • Possible leverage for other tasks by breaking them down into “logical” steps
  • Give the model a few examples of the task you want (Few-Shot)
  • Split a question into two types of prompts and alternate between the two
    • Selection prompt -> find the relevant pieces of into
    • Inference prompt -> use the relevant pieces to generate the answer
    • Halter prompt -> figure out when the alternating should halt, if possible add a value function to evaluate different prompts
  • Reduce hallucinations by constraining what the model can say

API Tips

  • Give the model an identity that behaves in a certain way with an explicit intent
  • Ask to model to answer from the perspective of an expert
  • Try restating the original “system” message to keep the model on-task.
  • If the model is getting off-track, try reminding it of the instruction and context at the end of the prompt