Directional Stimulus Prompting — What is it? Why is it?

Abir Das
8 min readJul 24, 2024

--

Imagine you’re chatting with a super-smart robot named Alex, similar to AI models like ChatGPT or Bard. Alex can answer almost any question, tell stories, and even help with your homework. But sometimes, Alex’s answers are a bit off. You ask about the weather, and Alex starts talking about the history of umbrellas. Frustrating, right? Or you ask Alex to recommend a good book, and he starts explaining the process of bookbinding. Even worse, you ask Alex for a recipe, and he starts giving you a lecture on the history of culinary arts. This is where the magic of prompt engineering comes in.

What is Prompt Engineering?

The Art of Asking the Right Questions

Prompt engineering is like giving Alex a nudge in the right direction. It’s the art of crafting questions or prompts that guide AI models to produce the most relevant and accurate responses. Think of it as giving Alex a little hint to stay on topic. Instead of just asking, “What’s the weather?”, you might say, “What’s the weather like today in Bengaluru?” Or, instead of asking, “Recommend a book,” you might say, “Can you recommend a good mystery novel?” Similarly, instead of asking, “Give me a recipe,” you might say, “Can you give me a simple recipe for chocolate chip cookies?” These specific prompts help Alex understand exactly what you’re looking for.

But Why Prompt Engineering Was Needed

The Challenge of Understanding Context

AI models, like Alex, are incredibly powerful but can sometimes miss the mark. They don’t always understand the context or nuances of a question. This can lead to answers that are technically correct but not quite what you were looking for. Prompt engineering helps bridge this gap by providing clear, context-rich prompts that guide the AI to the best possible answer.

Introducing Directional Stimulus Prompting (DSP)

The Next Level of Prompt Engineering

Now, let’s take prompt engineering a step further with Directional Stimulus Prompting (DSP). DSP is like giving Alex not just a hint but a detailed roadmap to follow. It’s a technique that uses a smaller, tunable model to generate specific hints or cues (directional stimuli) that guide the main AI model (like GPT-4) towards the desired output.

How DSP Works

  1. Input Query: You provide the original question or task.
  2. Stimulus Generation: A smaller model (like T5) generates specific hints or cues based on the input.
  3. Combined Input: The original input and the generated stimuli are combined.
  4. LLM Output: The combined input is fed into the main AI model to generate the final output.
  5. Evaluation and Optimization: The AI’s performance is evaluated, and the smaller model is optimized using techniques like supervised fine-tuning (SFT) and reinforcement learning (RL).
Source: Github

Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL)

Supervised Fine-Tuning (SFT) involves training a model on labeled data to help it generate relevant directional stimuli. Think of it as teaching Alex with a set of flashcards. Each card has a question on one side and the best hint on the other. Over time, Alex learns to give better hints based on these examples.

Reinforcement Learning (RL) refines the model by optimizing its output based on rewards from performance metrics. Imagine you give Alex a treat every time he gives a helpful hint. Alex quickly learns to give better hints to earn more treats. This continuous feedback loop ensures Alex’s hints are always improving.

DSP utilizes both SFT and RL to improve the effectiveness of prompts. This integration enhances the model’s ability to provide accurate outputs by generating effective hints and cues that guide the LLM.

Why DSP is a Game-Changer

Clarity, Accuracy, and Efficiency

DSP enhances AI performance by providing fine-grained guidance through directional stimuli. This results in clearer, more accurate, and contextually relevant outputs. It’s like giving Alex a detailed map with all the landmarks highlighted, ensuring he never gets lost.

Applications of DSP

Summarization

Imagine you’re a student struggling to summarize a lengthy research paper on climate change. You ask Alex for help. Without DSP, Alex gives you a summary that misses key points and feels incomplete. But with DSP, Alex generates a summary that highlights the essential findings, methodology, and conclusions. It’s like having a study buddy who knows exactly what to focus on, making your study sessions more productive and less stressful.

Example:

  • Input: “Summarize the following research paper on climate change.”
  • Directional Stimulus: “Highlight the essential findings, methodology, and conclusions.”
  • Output: “The research paper discusses the impact of greenhouse gases on global warming, detailing the methodology used to measure carbon emissions and concluding with recommendations for reducing our carbon footprint.”

Dialogue Response Generation

Now, imagine you’re running a small online business, and you use a chatbot to handle customer inquiries. One day, a customer named Tuhin asks about the return policy. Without DSP, Alex might give a generic response that frustrates Tuhin. But with DSP, Alex generates a response tailored to Tuhin’s specific query, providing clear and helpful information. It’s like having a customer service agent who always knows the right thing to say, enhancing customer satisfaction and loyalty.

Example:

  • Input: “What is your return policy?”
  • Directional Stimulus: “Provide details about the return window, conditions, and process.”
  • Output: “Our return policy allows returns within 30 days of purchase. Items must be in their original condition and packaging. To initiate a return, please contact our support team with your order number.”

Chain-of-Thought Reasoning

Picture yourself as a high school student trying to solve a complex math problem. You ask Alex for help. Without DSP, Alex might give you the final answer without explaining the steps. But with DSP, Alex guides you through each step of the problem, helping you understand the process. It’s like having a math tutor who walks you through each calculation, making learning more interactive and effective.

Example:

  • Input: “Solve for x in the equation 2x + 3 = 11.”
  • Directional Stimulus: “Break down the equation step-by-step to solve for x.”
  • Output: “First, subtract 3 from both sides of the equation: 2x + 3–3 = 11–3. This simplifies to 2x = 8. Next, divide both sides by 2: 2x / 2 = 8 / 2. So, x = 4.”

Sentiment Analysis

Think about analyzing customer reviews for a new product launch. You’re a marketing manager, and you need to understand customer feedback. Without DSP, Alex might give you a general sentiment score. But with DSP, Alex focuses on specific aspects of the reviews, highlighting positive and negative sentiments about features like quality, price, and usability. It’s like having a market analyst who digs deep into customer feedback, providing valuable insights for your marketing strategy.

Example:

  • Input: “Analyze the customer reviews for our new product.”
  • Directional Stimulus: “Highlight sentiments about quality, price, and usability.”
  • Output: “Customers appreciate the product’s quality and usability, mentioning its durability and ease of use. However, some customers feel the price is a bit high compared to similar products.”

Language Translation

Suppose you’re a technical writer tasked with translating a complex engineering document. Without DSP, Alex might give you a translation that loses some of the technical nuances. But with DSP, Alex provides a translation that maintains the technical terminology and clarity. It’s like having a professional translator who understands the subject matter, ensuring your document is both accurate and comprehensible.

Example:

  • Input: “Translate this engineering document from English to Bengali.”
  • Directional Stimulus: “Maintain technical terminology and clarity.”
  • Output: “এই নথিটি সেমিকন্ডাক্টর উত্পাদন প্রক্রিয়ার বর্ণনা করে, প্রতিটি ধাপকে সঠিক প্রযুক্তিগত পরিভাষা দিয়ে বিশদভাবে ব্যাখ্যা করে।”

Style Control in Text Generation

Imagine you’re a content creator writing a blog post for a fashion brand. Without DSP, Alex might generate text that doesn’t match the desired tone. But with DSP, Alex produces text that aligns perfectly with the brand’s voice, whether it’s friendly, professional, or persuasive. It’s like having a copywriter who knows exactly how to capture your brand’s essence, making your content more engaging and on-brand.

Example:

  • Input: “Write a blog post about our new summer collection.”
  • Directional Stimulus: “Use a friendly and engaging tone.”
  • Output: “Discover our new summer collection! From breezy dresses to stylish sandals, we’ve got everything you need to stay cool and chic this season. Shop now and embrace the summer vibes!”

Example: Chain-of-Thought Reasoning

Without DSP

Input:
“If a farmer has 10 apples and gives away 4, how many apples does he have left?”

Output:
“The farmer has 6 apples left.”

With DSP

Input:
“If a farmer has 10 apples and gives away 4, how many apples does he have left?”

Directional Stimulus:
“Start by subtracting the number of apples given away from the total. Follow this chain of thought to reach the answer.”

Combined Input:
“If a farmer has 10 apples and gives away 4, how many apples does he have left? Start by subtracting the number of apples given away from the total. Follow this chain of thought to reach the answer.”

Output:
“First, we need to subtract the number of apples given away from the total number of apples. So, 10–4 = 6. The farmer has 6 apples left.”

Example: Mathematical Reasoning

Without DSP

Input:
“Calculate the area of a rectangle with length 5 and width 3.”

Output:
“The area of the rectangle is 15.”

With DSP

Input:
“Calculate the area of a rectangle with length 5 and width 3.”

Directional Stimulus:
“Use the formula for the area of a rectangle: length × width. Follow this chain of thought to reach the answer.”

Combined Input:
“Calculate the area of a rectangle with length 5 and width 3. Use the formula for the area of a rectangle: length × width. Follow this chain of thought to reach the answer.”

Output:
“First, identify the formula for the area of a rectangle, which is length × width. Then, multiply the length (5) by the width (3). So, 5 × 3 = 15. The area of the rectangle is 15.”

Conclusion

Why DSP is Better:

  • Clarity: The output with DSP provides a clear explanation of the reasoning process, making it easier to understand how the answer was derived.
  • Accuracy: By guiding the model through the reasoning steps, DSP reduces the likelihood of errors and improves the accuracy of the output.
  • Educational Value: The step-by-step explanation is beneficial for educational purposes, helping users learn and understand the problem-solving process.

Directional Stimulus Prompting (DSP) is a game-changer in the world of AI, enhancing the performance of large language models by providing fine-grained guidance through directional stimuli. By leveraging both supervised fine-tuning and reinforcement learning, DSP optimizes a small, tunable policy model to generate effective stimuli that guide LLMs towards desired outputs. Its applications in summarization, dialogue response generation, chain-of-thought reasoning, sentiment analysis, language translation, and style control demonstrate its versatility and effectiveness in improving AI-generated outputs. As AI continues to evolve, DSP represents a significant advancement in prompt engineering, offering a more efficient and precise way to harness the power of large language models.

References

  1. Guiding Large Language Models via Directional Stimulus Prompting (arXiv)
  2. The Power of Directional Stimulus in Prompt Engineering
  3. This State-Of-The-Art Directional-Stimulus Prompt Engineering Technique for Generative AI Earns Bigtime Payoffs via Hints (Forbes)
  4. [NeurIPS 2023] Codebase for the paper: “Guiding Large Language Models with Directional Stimulus Prompting”
  5. Mastering Prompt Engineering: A Beginner’s Guide to AI Interaction

Share

Rewrite

--

--