Prompt variables
Variables are a powerful feature that allows you to define some text variables that will be replaced with a text of your choice when the prompt is sent for completion.
A sample use case: It's known that following a prompt with the sentence
"Explain your thinking step-by-step" will result in the Language Model
replying with a more accurate and thorough response. Therefore, you could
consider saving this text as a variable called steps
, and attach it to a
prompt whenever you need it.
How to use Variables
Let's go through a quick example of how to add Variables to your prompts.
1. Open the Variables page
Find the Variables page by clicking the button in the top-left part of the interface, in the sidebar.
2. Create the Variable
Click on "Create Variable" to make the modal appear, then first add the name of the variable. The name should be something easy for you to remember, in order to reuse it easily when working on a prompt.
For fun, let's create a variable called pirate
that inserts the text "Reply as a pirate", then save the variable.
3. Inserting and testing the variable
Let's now check if the variable is correctly working. Let's create a new prompt and add the following text:
Tell me a short story.
Next, let's add our variable. To do so, we need to start typing {{
followed by a space, or the initial letter of our variable name. You will see a suggestion box showing your variables. To select one, simply click on it, or press Enter
(you can use the keyboard arrows to select the correct one).
Once added, you will see that the variable will be highlighted with a special orange marker, to indicate that it has been correctly added and to help you quickly identify it. We can now submit our prompt and check the result:
As you can see, the model replied using the tone we specified. Now we can potentially reuse this variable any time we want and add it to any prompt.
When to use Variables
Quartzite offers you different ways to add predefined content to your prompts and work more efficiently. We recommend using Variables (for example instead of Templates) when you see yourself repeating the same text often. For example:
- Prompt engineering instructions, like the text "Explain your thinking step-by-step" we mentioned earlier, or creating model personalities to reuse - for example, instructing the model to answer as a Senior Software Developer and adding more information about their profile.
- Quickly add context to prompts. For example, are you working long-term on a project, and often need to ask the model some questions about it? Then create a short description of it and save it as a variable. You will be able to quickly add it to any prompt and make the model's response more precise.
Experimental
Add CSV data to your prompts. You can save any piece of text as a variable, therefore also CSV data. (Be however mindful of the CSV length and potential token cost.)
And more... Try experimenting with this feature to see what's most useful for your specific applications!