Prompt engineering is the art of effectively instructing language models to generate desired outputs. With the right techniques, we can harness the full potential of these models. Delimiters are a powerful tool in prompt engineering, which provides structure and guidance. Let’s explore how delimiters can transform our interactions with language models.
Delimiters act as signposts in the conversation between users and language models. They help demarcate different components and guide the model’s behavior. Delimiters can be as simple as tags or phrases that indicate specific instructions or roles. They can also be used to format the response’s output. By strategically employing delimiters, we gain greater control over model responses.
When using delimiters in prompt engineering, there is flexibility in the choice of delimiters. Here are some common types of delimiters that can be employed:
We can use textual tags in our prompts to specify the input type. The tags can either be an instruction or a role, etc. Here is an example of using textual tags in prompts:
Follow the steps to extract the output from the given text.Text:On a sunny day, Alex and Bob went for a walk in the humid forest behind their big mansion. When theyreached the lake, they sat down and had a delicious meal.Steps:1. Identify the nouns in the input.2. Identify the adjectives in the input.3. Identify the verbs in the input.
In this example, “Text” and “Steps” are the keywords that act as textual delimiters and specify the different types of input in the prompt.
Here’s the sample output for this prompt:
Sample Output |
Let’s go through the steps to extract the requested information from the given text: Text: On a sunny day, Alex and Bob went for a walk in the humid forest behind their big mansion. When they reached the lake, they sat down and had a delicious meal. Step 1: Identify the nouns in the input. Day, Alex, Bob, Walk, Forest, Mansion, Lake, Meal Step 2: Identify the adjectives in the input. Sunny, Humid, Big, Delicious Step 3: Identify the verbs in the input. Went, Walk, Reached, Sat, Had So, the extracted information is:
|
Oftentimes, it is hard for the model to differentiate between instructions in an input text. We can use special characters like triple backticks (```), angled brackets (<>), curly braces ({}), etc., to help the model process different inputs. Here are some examples:
Triple backticks:
Summarize the text delimited by triple backticks into one sentence.``` Two social media influencers, Amy and Ben, have built substantial followings in their respectiveniches. They have similar audiences and values, and they believe that collaborating on a project orcontent series could benefit both of them in terms of expanding their reach and engaging their followers.However, they are struggling to come up with a cohesive and compelling concept for their collaboration.They need help in finding a solution to create a collaborative project that resonates with theiraudiences and achieves their goals.```
Triple backticks are used to separate different input types to make them easier to identify.
Here’s the sample output for this prompt:
Sample Output |
Two social media influencers, Amy and Ben, seek to leverage their similar audiences and values through collaboration on a project or content series, aiming to expand their reach and engagement; yet, they face challenges in conceptualizing an effective and cohesive idea, requiring assistance to develop a resonating and goal-achieving collaborative project. |
Angled brackets:
Identify the nouns, adjectives, and verbs in the following text:"On a sunny day, Alex and Bob went for a walk in the humid forest behind their big mansion. When theyreached the lake, they sat down and had a delicious meal."Nouns: <list nouns here>Adjectives: <list adjectives here>Verbs: <list verbs here>
Angled brackets are mostly used for formatting outputs. They inform the model of the places where output should be inserted.
Here’s the sample output for this prompt:
Sample Output |
Nouns: day, Alex, Bob, walk, forest, mansion, lake, meal Adjectives: sunny, humid, big, delicious Verbs: went, walk, reached, sat, had |
Persona tokens can be used as delimiters to influence the model's response style or perspective. These tokens help shape the model's behavior based on predefined characteristics or personas. For example:
Persona: Helpful AssistantA helpful assistant always uses a polite and respectful tone when talking to their clients. They asktheir clients about all relevant details and try to provide solutions or alternative methods.Persona: Unsatisfied CustomerAn unsatisfied customer is a little angry. They are disappointed because their expectations aren't met.Write a small dialogue between [Helpful Assitant] and [Unsatisfied Customer] about a system maintenance issue.
Here’s the sample output for this prompt:
Sample Output |
[Helpful Assistant]: Good afternoon! Thank you for reaching out. I'm here to help. Could you kindly share the specifics of the system maintenance issue you're encountering? [Unsatisfied Customer]: Yeah, whatever. I've been having major problems since your maintenance. This is ridiculous. [Helpful Assistant]: I'm genuinely sorry to hear about the troubles you're facing. I understand your frustration and I'm here to assist. Can you provide me with some details about the specific problems you've been experiencing after the maintenance? [Unsatisfied Customer]: Finally someone who cares. The system was working fine before, but now it's slow and glitchy. I can't get anything done, and it's affecting my work. This wasn't supposed to happen! [Helpful Assistant]: I truly apologize for the inconvenience this has caused you. It's definitely not the experience we intended. Thank you for explaining the issues. While we work on resolving the glitches, have you tried restarting your device or clearing your browser cache? These steps might offer a temporary solution while we address the root cause. [Unsatisfied Customer]: Yeah, I've tried all that nonsense. It's just frustrating that I have to waste even more time on this. Your maintenance was supposed to make things better, not worse. [Helpful Assistant]: I completely understand your frustration. Our aim was indeed to improve your experience, and I'm sorry we've fallen short of that. Your feedback is crucial in helping us rectify this. We're actively investigating the situation and will work to get your system back to its optimal state. In the meantime, I recommend using our mobile app as an alternative. It might offer a smoother experience while we iron out these issues. [Unsatisfied Customer]: I appreciate your understanding, but I shouldn't have to resort to workarounds. I hope you fix this soon. [Helpful Assistant]: You're absolutely right, and I apologize for any inconvenience this has caused you. We're committed to resolving this as quickly as possible. Thank you for your patience, and please don't hesitate to reach out if you need further assistance or updates on the situation. We value your business and will do everything we can to regain your trust. |
Delimiters significantly enhance prompt engineering in multiple ways:
Improved model understanding: Delimiters help models grasp the context and interpret instructions more accurately.
Enhanced control and direction: Clear instructions provided through delimiters guide the model's responses toward the desired outcome.
Structured conversations: Delimiters enable interactive exchanges, allowing users to have dynamic conversations with the model.