Warning: Please note that the information included in this article only refers to LLM Profiles for GPT (OpenAI). If an LLM is used as a translation provider as part of an MT Profile, please refer to the documentation for your provider instead.
When an LLM is used as your translation provider, Smartling supports the use of conditional syntax and placeholders in the translation prompt:
- Placeholders can be used to modify your default translation instructions.
- Jinja2 conditions can be included in your prompt to dynamically adapt it to specific circumstances based on predefined rules.
LLM prompts with conditional syntax
Conditional syntax can help streamline the prompt creation. Conditions enable you to use a general prompt and dynamically adapt it to specific circumstances based on predefined rules.
For example, the use of conditions allows you to apply locale-specific rules without having to create a separate prompt for each target locale.
Conditions allow you to apply the correct formality rules for each locale (e.g. If the target locale is fr-FR, use the pronoun "vous" for the formal register; if the target locale is de-DE, use the pronoun "du" for an informal tone, etc.).
By using conditional syntax, you can use the same prompt across languages, but render different rules per locale.
How to use conditions in your prompt
Conditions need to be included in the editable System Role field of Smartling's prompting interface, together with your translation prompt.
Supported syntax and tags
Smartling supports Jinja2 syntax with the following tags: if/elif/else/endif.
Example:
Prompt template (as entered in the System Role field)
Translate text
{% if target_language == 'es-ES' %}
and use this prompt for es-ES
{% elif target_language == 'fr-FR' %}
and use this prompt for fr-FR
{% else %}
and use this prompt
{% endif %}Rendered prompt if {{target_language}} is "es-ES"
Translate text
and use this prompt for es-ESSupported placeholders
Smartling supports the use of placeholders in your translation prompt. This is optional and the use of placeholders in your LLM Profile is not required.
The placeholders listed below can be included in your translation prompt.
Locale and source text placeholders
The following placeholders can be added as part of your prompt to modify the default translation behavior.
For example, these placeholders can be used to create locale-specific translation rules.
{{source_language}}: refers to the source locale as specified in your Smartling project (e.g. en-US).{{target_language}}: refers to all target locale(s) as specified in your Smartling project (e.g. es-ES).{{source_texts}}: represents the source text to translate.
Placeholders for Assets References
The following placeholders allow you to modify the standard behavior of Smartling's prompt tooling feature.
For example, if Prompt Tooling with RAG is enabled, using your glossary terms as assets references, Smartling will send all available glossary terms to the LLM as part of the rendered prompt. By using the placeholder {{glossary_terms}}, you can adjust this default behavior. For example, your prompt could include the following instruction, in order to avoid using glossary terms with incorrect capitalization as assets references: "Do not insert {{glossary_terms}} if they are in different casing in the {{target_language}}."
{{translation_examples}}: represents example translations from your Translation Memory (TM), with a maximum of five examples and a similarity score above 0.1. This placeholder populates with a value only if the corresponding checkbox is selected under "Assets References" in your LLM Profile.{{glossary_terms}}: represents glossary terms from the linguistic package associated with your Smartling project. The glossary terms are sent to the LLM as examples of your preferred terminology. This placeholder populates with a value only if the corresponding checkbox is selected under "Assets References" in your LLM Profile.
Tip: For more information about Smartling's prompting interface, please visit Managing LLM Profiles and Prompts. For more information about Assets References, please visit our documentation on Prompt Tooling with RAG.