<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Novita Guok</title>
    <description>The latest articles on DEV Community by Novita Guok (@novitaguok).</description>
    <link>https://dev.to/novitaguok</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F402480%2F821c5d12-6f5b-421f-8013-a156e9f71422.jpeg</url>
      <title>DEV Community: Novita Guok</title>
      <link>https://dev.to/novitaguok</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/novitaguok"/>
    <language>en</language>
    <item>
      <title>From Input to Impact: Driving Results with Prompt Engineering (Part 1: Foundational &amp; Static Patterns)</title>
      <dc:creator>Novita Guok</dc:creator>
      <pubDate>Mon, 27 Jul 2026 08:29:15 +0000</pubDate>
      <link>https://dev.to/novitaguok/from-input-to-impact-driving-results-with-prompt-engineering-part-1-foundational-static-861</link>
      <guid>https://dev.to/novitaguok/from-input-to-impact-driving-results-with-prompt-engineering-part-1-foundational-static-861</guid>
      <description>&lt;p&gt;&lt;strong&gt;Prompt engineering&lt;/strong&gt; is the art and science of crafting inputs (prompts) to get clear, accurate, and useful responses from artificial intelligence models.&lt;/p&gt;

&lt;p&gt;Instead of treating an AI like a standard search engine, prompt engineering treats it like a skilled assistant: the quality of the output directly depends on how you frame the instructions, context, and format.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Generative AI Work?
&lt;/h3&gt;

&lt;p&gt;A brief answer: &lt;strong&gt;probability&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Generative AI is based on mathematical statistical theory. First, a model is trained on a massive dataset. During this process, the model learns the patterns of how data appears and how it correlates with other data within specific contexts.&lt;/p&gt;

&lt;p&gt;Through this learning process, the model builds a distributed probability system. When given a prompt, it generates new content by continuously predicting the next most probable output.&lt;/p&gt;

&lt;p&gt;Let's see the example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi4zrurplylvexw3jia5v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi4zrurplylvexw3jia5v.png" alt="Gemini Prompt Example" width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A generative AI model processes the whole prompt to understand the correlation between every word. This allows the model to provide a context-relevant response.&lt;/p&gt;

&lt;p&gt;What is interesting is that the responses provided are flexible and varied, even with the same model and prompt. This is due to the random seed that is used for randomization when choosing the output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft5i6pamyvk9x643x1f7v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft5i6pamyvk9x643x1f7v.png" alt="Generative AI" width="799" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To learn more about how Generative AI works, you can check out this reference: &lt;a href="https://www.youtube.com/watch?si=IgjRhGGCfdXETPzr&amp;amp;v=wjZofJX0v4M&amp;amp;feature=youtu.be" rel="noopener noreferrer"&gt;Transformers (how LLMs work) explained visually&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh5iuec94yefmjtjl2mwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh5iuec94yefmjtjl2mwb.png" alt="Transformer" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Training Dataset Cut-Off Date&lt;br&gt;&lt;br&gt;
Generative AI models are trained on massive datasets. However, these datasets are static and do not contain real-time updates. For example, OpenAI's GPT-4 has a knowledge cut-off date of October 2023, meaning the model lacks information about events or developments beyond that date.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bias&lt;br&gt;&lt;br&gt;
A model's output depends directly on the quality and balance of its training data, which is rarely free from bias. For instance, if you ask an AI to compare several products, but the training data contains significantly more positive information about Product A than its competitors, the model's response will likely lean in favor of Product A.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hallucinations&lt;br&gt;&lt;br&gt;
It is crucial for Generative AI users to understand that models generate responses by predicting the most probable next word, not by retrieving verified facts. This probabilistic nature can lead to "hallucinations"—instances where the model confidently generates incorrect or completely fabricated information.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Best Practises
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Role&lt;br&gt;&lt;br&gt;
Define a specific persona or expert role for the AI to adopt. This helps the model tailor its tone, style, and complexity to match the target audience's level of understanding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Objective&lt;br&gt;&lt;br&gt;
Provide clear, direct instructions or goals. Setting explicit expectations reduces ambiguity and prevents the model from generating overly broad or generic answers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Context&lt;br&gt;&lt;br&gt;
Supply essential background data or relevant details for the AI to work with. Without sufficient context, the model will make assumptions to "fill in the gaps," which often leads to inaccurate or irrelevant results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Constraint / Limitation&lt;br&gt;&lt;br&gt;
Establish strict boundaries, such as response length, formatting rules, or topics to avoid. Setting clear limits keeps the model focused only on delivering what you need.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Prompt Engineering Patterns
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Pattern: The Persona
&lt;/h2&gt;

&lt;p&gt;Defining Personas Using personas helps the AI model understand context and constraints, ensuring the generated output is more relevant, specific, and tailored to a particular viewpoint. A simple framework for this is the &lt;strong&gt;R-I-C formula&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Role:&lt;/strong&gt; the job or identity (e.g., "Act as a senior software engineer").&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Identity:&lt;/strong&gt; key demographic and background details (e.g., "You have 7 years of experience writing in Kotlin and love teaching beginners").&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Communication style:&lt;/strong&gt; the tone, formatting, and behavior (e.g., "Keep explanations simple, encouraging, and end with a brief question").&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Formulas&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The Expert/Professional Pattern&lt;br&gt;&lt;br&gt;
"Act as a [Profession] specializing in [Specialty]. You have [Number] years of experience. Please answer my questions using [Tone/Style, e.g., clear, concise, professional English]."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Fictional/Creative Pattern&lt;br&gt;&lt;br&gt;
"You are [Character Name/Description] from [Context/Setting]. Your personality is [Traits]. When you speak, use the vocabulary and voice of [Character/Archetype]."&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pattern: The Audience/Reverse Persona
&lt;/h2&gt;

&lt;p&gt;By specifying the target audience, the AI model adjusts its tone, terminology, and detail level to match the user's specific background and depth of knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"Explain [Topic] to me as if I am [Audience Profile, e.g., a five-year-old child / an anxious first-time buyer]. Use simple terms and avoid complex jargon."&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern: Few-Shot
&lt;/h2&gt;

&lt;p&gt;In simple terms, this pattern provides several input-output examples (shots). It is exceptionally helpful for tasks requiring a specific output format, such as information extraction or structured content creation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 1 Input:&lt;/strong&gt; "My internet keeps dropping every five minutes."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 1 Output:&lt;/strong&gt; Category: Technical Issue&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 2 Input:&lt;/strong&gt; "Where is the refund status for my last order?"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 2 Output:&lt;/strong&gt; Category: Billing Inquiry&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your Turn Input:&lt;/strong&gt; "I cannot log into my mobile app account."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your Turn Output:&lt;/strong&gt; &lt;code&gt;[Model fills in: Category: Technical Issue]&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or you can show the model the exact structural layout you expect back. E.g.,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 1 Input:&lt;/strong&gt; "Send an email to John Smith at &lt;a href="mailto:john@example.com"&gt;john@example.com&lt;/a&gt; about the meeting."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 1 Output:&lt;/strong&gt; &lt;code&gt;{"name": "John Smith", "email": "&lt;/code&gt;&lt;a href="mailto:john@example.com"&gt;&lt;code&gt;john@example.com&lt;/code&gt;&lt;/a&gt;&lt;code&gt;", "topic": "meeting"}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 2 Input:&lt;/strong&gt; "Message support for Sarah Jenkins regarding her subscription at &lt;a href="mailto:sarah@test.org"&gt;sarah@test.org&lt;/a&gt;."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example 2 Output:&lt;/strong&gt; &lt;code&gt;{"name": "Sarah Jenkins", "email": "&lt;/code&gt;&lt;a href="mailto:sarah@test.org"&gt;&lt;code&gt;sarah@test.org&lt;/code&gt;&lt;/a&gt;&lt;code&gt;", "topic": "subscription"}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your Turn Input:&lt;/strong&gt; "Reach out to Alex Brown (&lt;a href="mailto:alex.b@sample.net"&gt;alex.b@sample.net&lt;/a&gt;) to schedule an interview."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your Turn Output:&lt;/strong&gt; [Model fills in: &lt;code&gt;{"name": "Alex Brown", "email": "&lt;/code&gt;&lt;a href="mailto:alex.b@sample.net"&gt;&lt;code&gt;alex.b@sample.net&lt;/code&gt;&lt;/a&gt;&lt;code&gt;", "topic": "interview"}&lt;/code&gt;]&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern: Chain-of-Thought
&lt;/h2&gt;

&lt;p&gt;Research shows that Generative AI models are significantly more accurate when guided through a step-by-step reasoning process rather than asked to jump straight to a final answer. We can implement this in two ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instructing the AI directly&lt;/strong&gt; to show its step-by-step reasoning (e.g., &lt;em&gt;"Think step-by-step before providing the final answer"&lt;/em&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Providing worked-out examples&lt;/strong&gt; that demonstrate the complete reasoning process.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While both patterns guide the AI using examples, Few-Shot and Chain-of-Thought patterns differ in depth and purpose. Few-Shot Prompting simply provides input-output pairs to show the expected final format, helping the AI map a specific input to a desired output structure. On the other hand, Chain-of-Thought Prompting goes a step further by demonstrating the step-by-step reasoning behind an answer, guiding the model on &lt;strong&gt;how&lt;/strong&gt; to solve the problem logically before reaching a conclusion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Q: A local bakery had 40 croissants at 8:00 AM. They sold 25 during the morning rush and baked a fresh batch of 30 at noon. How many croissants are available now?&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;A: The bakery started with 40 croissants. They sold 25, leaving 40 - 25 = 15. Then they baked 30 more, making 15 + 30 = 45. The answer is 45.&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Target Question:&lt;/strong&gt; &lt;code&gt;A store receives a shipment of 150 phones. They sell 45 on Monday and 30 on Tuesday. On Wednesday, 10 damaged units are returned to stock. How many sellable phones remain?&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI Output:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The store started with an initial inventory of 150 phones.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On Monday, 45 phones were sold: 150 - 45 = 105.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On Tuesday, 30 phones were sold: 105 - 30 = 75.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On Wednesday, 10 returned units were added back to stock: 75 + 10 = 85.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The answer is 85 sellable phones.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern: ReAct
&lt;/h2&gt;

&lt;p&gt;As Generative AI users, we can empower models to utilize external tools when generating responses. &lt;strong&gt;ReAct&lt;/strong&gt;—short for &lt;strong&gt;Reasoning and Acting&lt;/strong&gt;—is an advanced evolution of the Chain-of-Thought pattern. Beyond guiding the model to process tasks step-by-step, ReAct enables the model to take actions—such as querying external APIs or databases—to retrieve real-time information it doesn't natively possess.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flleh42rx96c4199wk139.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flleh42rx96c4199wk139.png" alt="ReAct" width="800" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The ReAct framework operates through three core components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Thought:&lt;/strong&gt; The model formulates a step-by-step plan based on the user's prompt and the context currently available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Action:&lt;/strong&gt; The model executes a specific task to gather additional information, such as making an external API call or performing a search.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Observation:&lt;/strong&gt; The model analyzes the data retrieved from the action and uses it to synthesize the final response.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Question: What is the current market capitalization difference between Apple and Microsoft in USD?

Thought 1: I need to fetch the real-time market cap of Apple (AAPL).
Action 1: Search[Apple AAPL current market capitalization USD]
Observation 1: Apple's market capitalization is approximately $3.45 trillion USD.

Thought 2: I need to fetch the real-time market cap of Microsoft (MSFT).
Action 2: Search[Microsoft MSFT current market capitalization USD]
Observation 2: Microsoft's market capitalization is approximately $3.12 trillion USD.

Thought 3: I need to subtract Microsoft's market cap from Apple's market cap to find the difference.
Action 3: Calculator[3.45 - 3.12]
Observation 3: 0.33

Thought 4: I now have the final calculation in trillions.
Final Answer: The current market capitalization difference between Apple and Microsoft is approximately ($330 billion USD).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;The Golden Rule:&lt;/strong&gt; The clearer your instructions, context, and examples, the less room the AI has to make assumptions or hallucinate.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>ai</category>
      <category>software</category>
      <category>programming</category>
    </item>
    <item>
      <title>From Input to Impact: Driving Results with Prompt Engineering (Bonus: Output Consistency Pattern)</title>
      <dc:creator>Novita Guok</dc:creator>
      <pubDate>Mon, 27 Jul 2026 08:28:52 +0000</pubDate>
      <link>https://dev.to/novitaguok/from-input-to-impact-driving-results-with-prompt-engineering-bonus-output-consistency-pattern-154b</link>
      <guid>https://dev.to/novitaguok/from-input-to-impact-driving-results-with-prompt-engineering-bonus-output-consistency-pattern-154b</guid>
      <description>&lt;p&gt;The &lt;strong&gt;Result Consistency Pattern&lt;/strong&gt; (often referred to as the Template or Format Enforcement Pattern) is a prompt engineering design technique used to ensure an AI model returns responses in a uniform, predictable structure every single time, regardless of varying user inputs.&lt;/p&gt;

&lt;p&gt;Because Large Language Models (LLMs) are probabilistic and generative by nature, running the same prompt multiple times can produce vastly different layouts, tones, or structures. The &lt;strong&gt;Result Consistency Pattern&lt;/strong&gt; fixes this by removing structural ambiguity.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why Is It Needed?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In production environments, AI outputs are frequently parsed by code, saved to databases, or fed into downstream software tools. If the output format varies (e.g., returning markdown one time and standard text the next), downstream parsers break.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern: Tail Generation
&lt;/h2&gt;

&lt;p&gt;A technique where key instructions, formatting rules, or operational constraints are appended at the &lt;strong&gt;very end&lt;/strong&gt; of the prompt—after all the background context, examples, or user data.&lt;/p&gt;

&lt;p&gt;Because Large Language Models (LLMs) rely on attention mechanisms, they tend to exhibit &lt;strong&gt;recency bias&lt;/strong&gt; (paying stronger attention to tokens at the end of the context window). Placing critical instructions at the "tail" helps prevent the model from drifting, ignoring rules, or adding unwanted conversational padding.&lt;/p&gt;

&lt;p&gt;The structure of a standard long Tail Generation Prompt is structured in three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Context / data input:&lt;/strong&gt; user inputs, database context, long documents&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Task requirements &amp;amp; examples:&lt;/strong&gt; what needs to be done with the data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TAIL INSTRUCTIONS (recency anchor):&lt;/strong&gt; &lt;em&gt;"REMEMBER: Return ONLY the JSON schema. Start with {"&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Preventing Conversational Filler (JSON Extraction)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Without Tail Prompt
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System: Extract names and emails into JSON.

User Data: [Insert 2,000 words of email threads...]

AI Output: "Sure! Here is the JSON extracted from your emails: ```

json..." (Breaks code parsers)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;  With Tail Prompt&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
plaintext
User Data: [Insert 2,000 words of email threads...]

---
CRITICAL TAIL INSTRUCTION: 
Extract the names and emails from the text above into a valid JSON array.
Do NOT include introductory phrases, explanations, or Markdown code blocks.
Your response MUST begin directly with the character '['.


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Enforcing Tone and Constraints on Large Datasets&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
xml
&amp;lt;context&amp;gt;
  [Insert complex financial report here]
&amp;lt;/context&amp;gt;

&amp;lt;task&amp;gt;
  Summarize the key revenue risks outlined in the financial report above.
&amp;lt;/task&amp;gt;

&amp;lt;tail_instructions&amp;gt;
  CRITICAL CONSTRAINTS:
  - Keep the summary to exactly 3 bullet points.
  - Do not use corporate jargon; explain as if speaking to a high school student.
  - End your response with the phrase: "End of Risk Report."
&amp;lt;/tail_instructions&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Last, the here are best practices for &lt;strong&gt;Tail Prompting:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Visual Separators:&lt;/strong&gt; Use horizontal lines (&lt;code&gt;---&lt;/code&gt;) or XML tags (&lt;code&gt;&amp;lt;tail_instructions&amp;gt;&lt;/code&gt;) to clearly decouple the tail instructions from the input data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Imperative Language:&lt;/strong&gt; Use clear, forceful commands (&lt;em&gt;"Do NOT...", "You MUST begin with..."&lt;/em&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prefix the Output:&lt;/strong&gt; If the API or platform supports it, pre-filling the model's response start token (e.g., forcing the model's output to start with &lt;code&gt;{&lt;/code&gt;) works hand-in-hand with tail generation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern: Template
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnza79rg6t5zqlutq4w5c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnza79rg6t5zqlutq4w5c.png" alt=" " width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In software development, we often require AI model responses to follow a strictly predictable structure—such as valid JSON, CSV, or XML—so downstream application code can parse the output without breaking. The &lt;strong&gt;Template Pattern&lt;/strong&gt; (or &lt;em&gt;Output Consistency Pattern&lt;/em&gt;) guarantees structural uniformity across variable inputs. To implement this pattern, we can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use labeled delimiters:&lt;/strong&gt; Enclose your required output schema, rules, and input data using clear delimiters such as XML tags (&lt;code&gt;&amp;lt;schema&amp;gt;...&amp;lt;/schema&amp;gt;&lt;/code&gt;), square brackets (&lt;code&gt;[...]&lt;/code&gt;), or backticks (``). Delimiters cleanly separate instructions from context, making parsing boundaries explicit to the model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Apply Tail Generation Prompting:&lt;/strong&gt; Append your formatting rules and start-token constraints at the &lt;strong&gt;very end&lt;/strong&gt; of the prompt (the "tail"). Placing key formatting constraints last leverages recency bias, ensuring the model does not add conversational preambles or postscripts.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Prompt Formula&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
xml
&amp;lt;context&amp;gt;
  Analyze the following customer review: "[Insert Review Text]"
&amp;lt;/context&amp;gt;

&amp;lt;output_template&amp;gt;
  Return the analysis strictly using the XML structure below:

  &amp;lt;review_analysis&amp;gt;
    &amp;lt;sentiment&amp;gt;[Positive | Neutral | Negative]&amp;lt;/sentiment&amp;gt;
    &amp;lt;category&amp;gt;[Technical | Billing | General]&amp;lt;/category&amp;gt;
    &amp;lt;summary&amp;gt;[1-sentence summary]&amp;lt;/summary&amp;gt;
  &amp;lt;/review_analysis&amp;gt;
&amp;lt;/output_template&amp;gt;

&amp;lt;final_rules&amp;gt;
  CRITICAL: Return ONLY the raw XML code above. Do not include markdown block wrappers, introductory greetings, or postscript remarks. Your response MUST begin directly with "&amp;lt;review_analysis&amp;gt;".
&amp;lt;/final_rules&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>From Input to Impact: Driving Results with Prompt Engineering (Part 2: Adaptive Prompting)</title>
      <dc:creator>Novita Guok</dc:creator>
      <pubDate>Mon, 27 Jul 2026 08:07:52 +0000</pubDate>
      <link>https://dev.to/novitaguok/from-input-to-impact-driving-results-with-prompt-engineering-part-2-adaptive-prompting-4346</link>
      <guid>https://dev.to/novitaguok/from-input-to-impact-driving-results-with-prompt-engineering-part-2-adaptive-prompting-4346</guid>
      <description>&lt;p&gt;Also known as Dynamic Prompting is a technique where an AI system adapts its instructions in real time based on user input, task complexity, or feedback.&lt;/p&gt;

&lt;p&gt;Instead of relying on a single, fixed text template (a "static prompt"), an adaptive prompting framework acts as a flexible pipeline that builds or alters the prompt on the fly before sending it to the Large Language Model (LLM).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Static Prompting&lt;/th&gt;
&lt;th&gt;Adaptive Prompting&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Instruction Structure&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fixed template regardless of input.&lt;/td&gt;
&lt;td&gt;Dynamically composed at runtime.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Complexity Handling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Same prompt used for simple and hard tasks.&lt;/td&gt;
&lt;td&gt;Escalates detail or reasoning steps for hard tasks.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Context Awareness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited to hardcoded rules or fixed examples.&lt;/td&gt;
&lt;td&gt;Adjusts persona, tone, or constraints based on user data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tool Usage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fixed tool calls or manual intervention.&lt;/td&gt;
&lt;td&gt;Dynamically injects tool definitions only when needed.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  How Adaptive Prompting Works
&lt;/h3&gt;

&lt;p&gt;An adaptive prompting pipeline typically follows four core steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Input Analysis &amp;amp; Classification:&lt;/strong&gt; When a user submits a query, an orchestrator (or a lighter classifier model) analyzes the user's intent, sentiment, background, and the task's complexity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic Context Assembly:&lt;/strong&gt; Based on the analysis, the system retrieves only the necessary context (e.g., user preferences, relevant database records, specific few-shot examples) and selects an appropriate persona or operational role.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instruction Injection:&lt;/strong&gt; The system constructs the final prompt by stitching together modular rules.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*   *Example:* If the user is identified as a beginner, the system dynamically appends the rule: `"Use simple analogies and avoid jargon."`

*   *Example:* If the user query requires real-time math or web data, the system injects tool-use instructions (such as ReAct steps).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Feedback Loop &amp;amp; Refinement (Self-Correction):&lt;/strong&gt; If the LLM's output fails a validation check (e.g., bad JSON formatting or hallucinated facts), the system automatically creates a follow-up prompt containing the error message to ask the model to correct itself.&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Prompt Engineering Patterns
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Pattern: Question Refinement
&lt;/h2&gt;

&lt;p&gt;When posing a question, we often have an incomplete or vague idea of what we actually want to achieve. Because our prompts are constrained by our limited initial knowledge, the AI model may deliver unexpected or unhelpful results due to missing context.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Question Refinement Pattern&lt;/strong&gt; solves this by turning the AI into a collaborative editor before it attempts to generate a final answer.&lt;/p&gt;

&lt;p&gt;How to implement this pattern?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ask the AI to generate improved variations:&lt;/strong&gt; Instruct the model to analyze your original prompt and propose several clearer, more specific, or better-structured alternative questions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Require confirmation before answering:&lt;/strong&gt; Direct the model to pause and ask you to select or refine its suggested options &lt;em&gt;before&lt;/em&gt; it provides the final answer.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Prompt Formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Whenever I ask a question about&lt;/em&gt; &lt;strong&gt;&lt;em&gt;[Topic]&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;, suggest&lt;/em&gt; &lt;strong&gt;&lt;em&gt;3 better, more specific versions&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;of my question that would yield a more thorough and accurate answer. Then, ask me which version I would like you to answer."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern: Alternative Approaches
&lt;/h2&gt;

&lt;p&gt;The core idea of this pattern is to prompt the AI model to generate multiple pathways or methods to solve a single problem. Rather than settling on the first solution, this approach encourages reflection on your true objectives and allows you to evaluate which method is best suited for your constraints.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate multiple solutions:&lt;/strong&gt; Instruct the AI to list alternative approaches or methods that achieve the same core objective as your initial request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compare trade-offs:&lt;/strong&gt; Ask the AI to compare the pros and cons (or advantages and disadvantages) of your original approach against the alternatives it proposes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Prompt Formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"I want to achieve&lt;/em&gt; &lt;strong&gt;&lt;em&gt;[Goal/Task]&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;. Here is my initial idea:&lt;/em&gt; &lt;strong&gt;&lt;em&gt;'[Insert your approach]'&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;. Before implementing it, please list&lt;/em&gt; &lt;strong&gt;&lt;em&gt;3 alternative ways&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;to accomplish the same goal, and compare the pros and cons of each method against my original idea."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern: Cognitive Verifier
&lt;/h2&gt;

&lt;p&gt;Works by having the AI model break down a primary question into smaller, sub-questions ("atomic queries") to collect necessary context and verify details before delivering a final answer. How to implement this pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instruct the model to ask sub-questions:&lt;/strong&gt; Require the AI to generate and answer additional sub-questions to gather comprehensive background data before addressing your main query.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Require complete data synthesis:&lt;/strong&gt; Direct the model to explicitly incorporate the answers from all sub-questions when synthesizing its final response.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Prompt Formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"When I ask you&lt;/em&gt; &lt;strong&gt;&lt;em&gt;'[Insert your main question]'&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;, follow these steps before answering:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Break my query down into 3–4 foundational sub-questions required to answer it accurately.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Answer each sub-question individually.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Combine the insights from all sub-questions to provide a well-verified final response."&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pattern: Flipped Interaction
&lt;/h2&gt;

&lt;p&gt;Imagine you are developing an Android e-Library application and need to write unit tests for the &lt;strong&gt;"Add Book"&lt;/strong&gt; feature. You are unsure how to structure the test code and haven't identified all the necessary edge cases. Because your own requirements are unclear, crafting a precise initial prompt is difficult—and asking a vague question will likely yield an incomplete answer.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Flipped Interaction Pattern&lt;/strong&gt; solves this problem by turning the traditional AI dynamic upside down: &lt;strong&gt;instead of you asking the AI questions, the AI asks you questions&lt;/strong&gt; to draw out the necessary details and constraints. Step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Define the ultimate goal:&lt;/strong&gt; State your target objective clearly (e.g., &lt;em&gt;"Help me write a complete test suite for the 'Add Book' screen in my Android app"&lt;/em&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flip the roles:&lt;/strong&gt; Instruct the AI to ask you targeted questions rather than immediately generating a solution (e.g., &lt;em&gt;"Ask me questions one by one to collect the information you need"&lt;/em&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set the stopping constraint:&lt;/strong&gt; Tell the AI when to stop asking questions and deliver the final output (e.g., &lt;em&gt;"Continue asking questions until you have enough details to generate the complete test code"&lt;/em&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Prompt Formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"I want you to&lt;/em&gt; &lt;strong&gt;&lt;em&gt;[Define Goal/Task, e.g., create unit tests for the 'Add Book' feature in Kotlin]&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;. To do this accurately,&lt;/em&gt; &lt;strong&gt;&lt;em&gt;ask me questions&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;about my project requirements, data structures, and edge cases.&lt;/em&gt; &lt;strong&gt;&lt;em&gt;Ask only one question at a time.&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;Keep asking questions until you have all the information required to write the complete code, then provide the solution."&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
