Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro-preview-05-06· GoogleHugging Face LMArena Human Preference 140K

What can I add to a prompt to avoid an LLM hallucinating or making things up?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with chatgpt-4o-latest-20250326’s answer.
  1. User

    What can I add to a prompt to avoid an LLM hallucinating or making things up?

  2. Gemini Assistant

    While you can't completely eliminate the risk of LLM hallucinations (it's an inherent challenge with current generative AI), you can significantly reduce it by crafting your prompts more effectively. Here's what you can add or how you can structure your prompts:

    1. Provide Specific Context (Grounding):

      • The single most effective method. If you want the LLM to answer based on specific information, give it that information directly in the prompt.
      • Example: Instead of "What are the benefits of XYZ Corp's new software?", try: "Based on the following press release: [Paste press release text here]... What are the key benefits of XYZ Corp's new software mentioned in this document?"
      • This is the core idea behind Retrieval Augmented Generation (RAG).
    2. Instruct it to Indicate Uncertainty:

      • Explicitly tell the LLM what to do if it doesn't know the answer or if the information isn't in the provided context.
      • Example: "Answer the following question based only on the provided text. If the answer is not in the text, state 'The information is not available in the provided text.'"
    3. Request Citations or Sources (with caution):

      • Ask the LLM to cite its sources if you've provided multiple documents or if you're allowing it to use its general knowledge (though the latter is riskier).
      • Example: "Summarize the main arguments for and against Topic X, citing specific sections from the provided articles."
      • Caution: LLMs can sometimes hallucinate citations or misattribute information, so always verify.
    4. Be Extremely Specific and Unambiguous:

      • Vague prompts leave more room for interpretation and, therefore, invention.
      • Example: Instead of "Tell me about dogs," try "List five common health issues in Golden Retrievers according to veterinary sources."
    5. Constrain the Scope of the Answer:

      • Tell the LLM what not to do or what to focus on exclusively.
      • Example: "Describe the process of photosynthesis, focusing only on the light-dependent reactions. Do not discuss the Calvin cycle."
    6. Use Role-Playing (with factual constraints):

      • Assign a role that implies factuality.
      • Example: "You are a meticulous fact-checker. Review the following statement for accuracy and provide corrections if needed: [statement]"
      • Example: "You are an expert historian. Based on widely accepted historical accounts, describe the causes of World War I. Do not speculate or offer personal opinions."
    7. Ask for Step-by-Step Reasoning (Chain-of-Thought):

      • For complex queries, asking the LLM to "think step-by-step" can sometimes lead to more grounded and logical outputs, making it easier to spot errors.
      • Example: "Solve this math problem and show your work step-by-step: [problem]"
    8. Lower the "Temperature" (if you have API access):

      • Many LLM APIs have a "temperature" parameter. A lower temperature (e.g., 0.2-0.5) makes the output more deterministic, focused, and less "creative" (and thus less prone to wild invention). A higher temperature encourages more randomness and creativity.
    9. Iterative Prompting and Refinement:

      • Start with a basic prompt, review the output, and then refine your prompt to address any inaccuracies or unwanted fabrications. Ask follow-up questions to clarify.
    10. Negative Prompts:

      • Explicitly tell it what not to do.
      • Example: "Summarize the provided article. Do not add any information not present in the text. Do not make up statistics or examples."

    Combining Strategies:

    Often, the best approach is to combine several of these:

    "You are a financial analyst assistant. Based only on the provided quarterly report excerpts: [Paste excerpts here]... List the key financial highlights mentioned. For each highlight, cite the page number or section from the excerpts where it can be found. If specific information is not present in the excerpts, explicitly state 'Information not found in provided excerpts.' Do not speculate or provide information outside of these excerpts."

    Crucial Reminder: No matter how well you craft your prompt, always critically evaluate and verify any factual claims made by an LLM, especially for important tasks. Human oversight remains essential.

  3. User

    Is it possible to adjust the temperature when using ChatGTP?

  4. Gemini Assistant

    Okay, let's clarify this as "ChatGPT" can mean a couple of things:

    1. ChatGPT Web Interface (chat.openai.com):

      • No, you cannot directly adjust the "temperature" setting yourself as an end-user through the standard ChatGPT web interface. OpenAI likely has a default temperature setting (or perhaps even dynamically adjusts it) for general chat interactions to balance creativity and coherence.
    2. OpenAI API (for developers using models like GPT-3.5-turbo, GPT-4, etc.):

      • Yes, absolutely. When you are using the OpenAI API to programmatically interact with the underlying models (the same ones that power ChatGPT), the temperature is one of the key parameters you can set.
      • What it does:
        • Lower temperature (e.g., 0.0 - 0.3): Makes the output more deterministic, focused, and less random. Good for factual Q&A, summarization, or tasks where you want predictable, less "creative" output.
        • Higher temperature (e.g., 0.7 - 1.0 or higher): Makes the output more random, creative, and potentially surprising. Good for brainstorming, story writing, or when you want diverse ideas. Very high temperatures can lead to incoherence or more hallucinations.
      • Example (conceptual API call):
        # This is pseudocode to illustrate the concept
        response = openai.ChatCompletion.create(
          model="gpt-4",
          messages=[{"role": "user", "content": "Write a poem about a robot."}],
          temperature=0.8 # You can adjust this value
        )
        
    3. ChatGPT Plus/Team/Enterprise with Custom GPTs:

      • When you create a Custom GPT, you don't get a direct "temperature" slider in the configuration. However, the instructions you provide to your Custom GPT can strongly influence its behavior in a way that mimics temperature control (e.g., "Be highly creative and imaginative" vs. "Stick strictly to the provided facts and be very concise").
      • The end-user of a Custom GPT (even one you've made) doesn't get to adjust a temperature setting for that specific Custom GPT during their interaction.

    In summary:

    • Using the ChatGPT website for chatting? No direct temperature control.
    • Developing applications using the OpenAI API? Yes, temperature is a crucial parameter you can control.

    If you're not a developer but want to influence the "creativity" of ChatGPT on the web interface, you can try to do so through your prompts:

    • For less "creative" / more factual output: "Be very precise and stick to known facts." "Answer concisely." "Based only on established information..."
    • For more "creative" output: "Be imaginative." "Write in a playful style." "Brainstorm some wild ideas."

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.