Using XML Tags for Prompt Engineering

Prompt engineering is a key element when it comes to getting meaningful and precise outputs from machine learning models like Palmyra -X or Instruct Palmyra. To refine the outputs of these models, you can make use of various approaches such as prefixing, infixing, or affixing additional instructions within the prompt. One innovative approach for prompt engineering is using XML tags within the prompt to define specific behaviors or output formats.



As of my last training data in August 2023, Writer's LLM doesn't inherently recognize XML or HTML-like tags to control behavior. However, you can still use them in a custom manner as part of your prompts to make post-processing easier or to provide a standardized format for the prompts you send to the model.

Why Use XML Tags?

  1. Standardization: By using XML tags, you ensure that each part of your prompt follows a uniform structure, making it easier to parse.

  2. Flexibility: XML tags can be custom defined, allowing you to introduce new functionality without altering the core prompt.

  3. Easier Post-Processing: With tagged outputs, you can easily parse the returned text to extract the information you need.

Basic Structure

The basic structure when using XML tags within a prompt could look something like this:

  <instruction>Translate the following sentence into French:</instruction>
  <input>How are you?</input>

How to Use XML Tags for Prompt Engineering

Step 1: Design Your XML Schema

Decide what XML tags will represent. For example:

  • <instruction> can hold the specific task you want the model to perform.
  • <input> can hold the content you want to be acted upon.

Step 2: Create Your Prompt

Craft the prompt using the XML tags:

  <instruction>Summarize the following paragraph:</instruction>
  <input>Climate change is having a severe impact on the polar regions...</input>

Step 3: Send to the Model

Pass the entire XML-formatted prompt to the LLM through the API or whichever interface you're using.

Step 4: Post-process the Output

The model's output will include your XML tags. You can then parse the output to extract the portion you are interested in.

Additional Tips

  1. Custom Tags: Feel free to create custom tags that can hold additional information or specific formatting options.

  2. Nesting: XML allows for nested tags, providing you with an added layer of complexity if needed.

  3. Validation: Before sending, validate your XML to ensure that it conforms to XML standards.

Using XML tags in prompt engineering is an innovative and flexible way to instruct machine learning models like Plamyra-X. It offers a standardized yet customizable approach to extract the information you need. While the models do not inherently understand XML tags as control elements, this method sets the stage for easier parsing and post-processing, providing a convenient way to organize and refine your prompts.