-
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 Translation Function, as used in the sample apps. You can edit these as needed. Note that we say 'photography website' instead 'photography app' because the language model would have been train on a lot of photography websites and would pick up the photography-related language. It has probably seen very few photo-related apps, or screenshots of those apps, for training, and would likely be less accurate.
\Translator\TTF_OpenAI_1.json
{
"Key": "@",
"Value": "You are a professional language translator. Translate the following text from American English (en-US) to ({0})."
},
{
"Key": "@@",
"Value": "You are a professional language translator. Translate the following text from American English (en-US) to ({0}). Aim to keep the translated text the same length or shorter, but prioritize accuracy and clarity if a slight increase in length is unavoidable."
},
{
"Key": "!",
"Value": "You are a professional language translator. These translations are for a photography website, so use terminology and style suitable for photographers and their audience. Translate the following text from American English (en-US) to ({0})."
},
{
"Key": "!!",
"Value": "You are a professional language translator. These translations are for a photography website, so use terminology and style suitable for photographers and their audience. Translate the following text from American English (en-US) to ({0}). Aim to keep the translated text the same length or shorter, but prioritize accuracy and clarity if a slight increase in length is unavoidable."
}```
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>```