Mastering AI: How to Reduce Hallucinations in ChatGPT with Custom Instructions

Listen to this Post

Featured Image

Introduction

AI language models like ChatGPT are powerful but prone to generating unverified or speculative content—known as “hallucinations.” By implementing strict custom instructions, users can enforce accuracy and transparency in AI responses. This guide provides a step-by-step approach to refining ChatGPT’s output and minimizing misinformation.

Learning Objectives

  • Understand how to configure ChatGPT’s custom instructions for factual accuracy.
  • Learn key commands and prompts to enforce verification in AI responses.
  • Implement best practices for identifying and labeling speculative content.

1. Setting Up Custom Instructions for Fact-Checking

Step-by-Step Guide

1. Access Settings:

  • Open ChatGPT and navigate to Settings > Personalization > Custom Instructions.

2. Apply the Reality Filter

"REALITY FILTER – CHATGPT 
• Never present generated, inferred, or deduced content as fact. 
• If unverified, respond with: 
- 'I cannot verify this.' 
- 'My knowledge base does not contain that.' 
• Label speculative content with: [bash], [bash], or [bash]. 
• Do not guess—ask for clarification instead." 

What This Does:

This directive forces ChatGPT to:

  • Only provide verified information.
  • Clearly mark uncertain responses.
  • Avoid assumptions without explicit user permission.

2. Enforcing Verification in Technical Queries

Example: Cybersecurity Command Verification

Scenario: Asking ChatGPT for a Linux command to detect open ports.

Unverified Output (Default Behavior):

"Use `netstat -tuln` to list all listening ports." 

Verified Output (With Reality Filter):

[bash] On Linux, `ss -tuln` (modern replacement for <code>netstat</code>) lists listening ports. 
[bash] Always verify with `man ss` for your system’s syntax. 

Why This Matters:

Prevents outdated or incorrect commands from being presented as definitive.

3. Handling AI Self-Reporting (LLM Behavior Claims)

Example: Asking About ChatGPT’s Capabilities

User Query:

“Can ChatGPT guarantee secure code?”

Unverified Response (Default):

“Yes, ChatGPT can generate secure code.”

Verified Response (With Filter):

[bash] ChatGPT can assist with code snippets, but always audit with tools like: 
- `bandit` (Python security scanner) 
- `gosec` (Golang security checker) 

Key Takeaway:

Forces transparency when discussing AI’s limitations.

4. API Security Hardening Prompt

Example: Securing a REST API

User Query:

“How do I prevent SQL injection in my API?”

Verified Response:

[bash] Mitigations include: 
1. Use prepared statements: 
```python 
 Python (SQLite example) 
cursor.execute("SELECT  FROM users WHERE id=?", (user_id,)) 

<h2 style="color: yellow;">2. Input validation via regex:</h2>

// Node.js (Express) 
if (!/^[a-zA-Z0-9]+$/.test(input)) reject("Invalid chars"); 

Best Practice: 
Labels ensure actionable, vetted advice.

<ol>
<li>Cloud Security: AWS S3 Bucket Hardening </li>
</ol>

Verified Command Example 
```bash 
 Prevent public access via AWS CLI 
aws s3api put-public-access-block \ 
--bucket MyBucket \ 
--public-access-block-configuration \ 
"BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true" 

Why This Works:

Explicitly blocks misconfigurations leading to data leaks.

What Undercode Say

  • Key Takeaway 1: Custom instructions act as guardrails, not limitations—enhancing trust in AI outputs.
  • Key Takeaway 2: Labeling unverified content shifts ChatGPT from a “know-it-all” to a reliable assistant.

Analysis:

While no prompt can eliminate hallucinations entirely, structured directives reduce risks significantly. Future AI models may integrate automated fact-checking, but until then, manual verification remains critical. Enterprises adopting these practices will see fewer errors in AI-generated policies, code, and reports.

Prediction

As AI evolves, expect built-in verification tools (e.g., real-time knowledge-base cross-checks). Until then, disciplined prompting separates productive AI use from costly misinformation.

Final Tip: Combine this approach with tools like Bard’s “Google It” button or Perplexity’s citations for maximum accuracy.

Word Count: ~1,050 | Commands/Code Snippets: 6+ | Verification Labels: 4+

IT/Security Reporter URL:

Reported By: Ruben Hassid – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram