BishopPhillips
BishopPhillips
BPC Home BPC AI Topic Home BPC RiskManager BPC SurveyManager BPC RiskWiki Learn HTML 5 and CSS Enquiry

LARGE LANGUAGE MODELS - Prompt Engineering

LLM Special Tokens
AI Revolution

The ** symbol is used in LLM prompts to indicate a special token that should be replaced with a specific value. These tokens are often used to control the behavior of LLMs and modify the generated text. They are a key component in building templates to shape LLM responses.

For example, the **temperature** parameter can be set using a token in the prompt. The temperature parameter controls the randomness of the generated text. A higher temperature value will result in more random and diverse outputs, while a lower temperature value will result in more predictable and conservative outputs.

Here is an example of a prompt that uses the temperature token:

Generate a paragraph about artificial intelligence with a temperature of **0.5**.

This prompt would generate a paragraph about artificial intelligence with a temperature of 0.5.

Special tokens can be used to template the output to replace sections where the special token appears. For example **adjective1** in a sentence would be replaced by an adjective keeping the rest of the sentence as entered.

Here are some examples of special tokens that can be used in prompts:

  • **adjective1**, **adjective2**, **adjective3**: These tokens can be used to prompt for adjectives. For example, “Roses are **adjective1**” might produce “Roses are red” using the **adjective1** token to prompt for an adjective where the word “red” appears in the output.
  • **noun1**, **noun2**, **noun3**: These tokens can be used to prompt for nouns. For example, “The **noun1** sat on the mat” might produce “The cat sat on the mat” using the noun1 token to prompt for a noun.
  • **verb1**, **verb2**, **verb3**: These tokens can be used to prompt for verbs. For example, “She **verb1** to catch the bus” might produce “She ran to catch the bus” using the verb1 token to prompt for a verb.
  • **plural_noun**: This token can be used to prompt for a plural noun. For example, “Roses are red, violets are blue, sugar is sweet, and so are **plural_noun**” might produce “Roses are red, violets are blue, sugar is sweet, and so are puppies” uses the plural_noun token to prompt for a plural noun.
  • **number**: This token can be used to prompt for a number. For example, “I have been to **number** different countries” might produce “I have been to three different countries” uses the number token to prompt for a number.

These special tokens can be used in prompts to generate creative and engaging content using LLMs. By using tokens in prompts, prompt engineers can fine-tune LLMs to generate high-quality and relevant outputs.

Using Special Tokens – A more Advanced Example - MadLibs

Special tokens are used to create prompt patterns and templates. We shall explore using multiple special tokens in a single LLM prompt to create a prompt pattern and play the MadLibs game.

This is an example of a MadLib:

Roses are adjective1,
Violets are adjective2,
Sugar is adjective3,
And so are plural_noun.

In the game you would just fill in the blanks with your own words and enjoy the silly poem!

In a prompt we use template to direct the LLM, which ends up being almost exactly the same as the example above. For example:

“Using the following Madlib template create a funny poem: Roses are **adjective1**,  Violets are **adjective2**,  Sugar is **adjective3**,  And so are **plural_noun**. “

This prompt might produce:

“Roses are red,
Violets are blue,
Sugar is sweet,
And so are puppies.”


...Place Holders for Prompt Engineering....

MadLibs

Mad Libs is a phrasal template word game created by Leonard Stern and Roger Price in 19531. The game consists of one player prompting others for a list of words to substitute for blanks in a story before reading aloud. The game was invented in the United States, and more than 110 million copies of Mad Libs books have been sold since the series was first published in 1958.

Stern and Price created the game,but could not agree on a name for their invention. No name was chosen until five years later (1958), when Stern and Price were eating Eggs Benedict at a restaurant in New York City. While eating, the two overheard an argument at a neighbouring table between a talent agent and an actor. According to Price and Stern, during the overheard argument, the actor said that he wanted to “ad-lib” an upcoming interview. The agent, who clearly disagreed with the actor’s suggestion, retorted that ad-libbing an interview would be “mad”. Stern and Price used that eavesdropped conversation to create, at length, the name "Mad Libs".

Mad Libs books are still published by Penguin Random House; however, all references to Price Stern Sloan have been removed from the company’s official website.

This article on Articulate that provides examples of Mad Libs-style interactions.