-
Notifications
You must be signed in to change notification settings - Fork 0
13. Hint Tokens @, @@, !, !!
Let's say we are translating for a photography-related app. When we send a string like 'Aperture' to a Translation Function, do we mean aperture as in a camera lens, or aperture as in an opening of some kind, like a window? We need to give the function a hint to get the best translation results.
With human translators, we might have included context in the .resw comments. But in this Translator app, we'll use the following hint tokens:
-
@- A normal, generic translation.
Example:'@Aperture'may be translated as an opening of some kind. -
!- A translation with extra context.
Example:'!Aperture'is more likely to be translated in a photography context.
- Longer prompts cost more.
- If a generic
@prompt works, use that instead to save costs.
Often, we have limited screen space to display a string, such as the header above a combobox control. It looks good in en-US, but translating it may make the string too long, affecting the layout and making it look bad.
To handle this, use the following hint tokens:
-
@@- A normal, generic translation, but where we want the translation to be of similar or shorter length. -
!!- A translation with extra context, but where we want the translation to be of similar or shorter length.
Here are the hints for the OpenAI API profile, as used in the sample apps. You can edit these as needed.
\Translator\Profiles\OpenAI_gpt4_v1.prf
{
"Key": "@",
"Value": "You are a professional translator who translates from {0} to {1}. Always respond in JSON format and place your translated text the the 'translated' property and your confidence 1-100 integer in the 'confidence' property. Do the translation in the context of the text displayed on a photography software user interface."
},
{
"Key": "@@",
"Value": "You are a professional translator who translates from {0} to {1}. Always respond in JSON format and place your translated text the the 'translated' property and your confidence 1-100 integer in the 'confidence' property. Do the translation in the context of the text displayed on a photography software user interface. Aim to keep the display width of the translated text the same or less than the original."
},
{
"Key": "!",
"Value": "You are a professional translator who translates from {0} to {1}. Always respond in JSON format and place your translated text the the 'translated' property and your confidence 1-100 integer in the 'confidence' property. Do the translation in the context of the text displayed on a photography software user interface."
},
{
"Key": "!!",
"Value": "You are a professional translator who translates from {0} to {1}. Always respond in JSON format and place your translated text the the 'translated' property and your confidence 1-100 integer in the 'confidence' property. Do the translation in the context of the text displayed on a photography software user interface. Aim to keep the display width of the translated text the same or less than the original."
}
Here's some .xaml elements from the sample app. You can see the hint token usage.
<StackPanel
Grid.Row="0"
Orientation="Horizontal"
HorizontalAlignment="Stretch"
Margin="20 20 20 20"
Spacing="15">
<Button
x:Uid="Close_btn"
Content="@Close">
</Button>
<CheckBox
x:Uid="Lock_cb"
Content="@@Lock" />
<RadioButtons
Header="@Zoom"
x:Uid="Zoom_rbs">
<RadioButton
x:Uid="Zoom100_rb"
Content="@100%" />
<RadioButton
x:Uid="Zoom200_rb"
Content="@200%" />
</RadioButtons>
<ToggleButton
x:Uid="Browser_tgbtn"
Content="!Image Browser" />
<ToggleSwitch
x:Uid="Connect_ts"
Header="@Connection"
OffContent="@Disconnected"
OnContent="@Connected"
IsOn="True" />
</StackPanel>```