Adapt to Translation Memories
Domain Adaptation Using Past Translation Examples
Lara can adapt almost in real-time to your style and terminology by providing quality-vetted sentence translation examples. This examples are stored in repositories called Translation Memories. You can have as many translation memories you want each defining a domain style and terminology.
During the translation phase you can ask Lara to adapt to one or multiple translation memories. Lara performs adaptation at inference time changing the translation to match the style and terminology of the selected translation memory. No model training is required and model quality improves continually as new examples are provided. For this reason Lara adaptation can also be used to solve instantaneously critical production errors.
Adaptation can also be used to fix recurring translation errors in production just by adding some examples of correct translations into the translation memory.
Domain Adaptation is available for Team and Enterprise Subscriptions.
The SDK allows to:
- Create a Translation Memory
- List User Created Translation Memories.
- Add translated sentences to the translation memory
- Bulk import into a Translation Memory using a TMX file.
- Translate adapting to one or more Translation Memories
- Delete a Translation memory
Translate with memories
Below a quick example of listing and translating using translation memories.
# List available translation memories for the account
print(lara.memories.list())
# Adapting the translation to specific memories.
res = lara.translate("Hello, how are you?", source="en", target="it", adapt_to=[
'mem_1...', 'mem_2...' # Replace with actual memory IDs to use for adaptation
])
print(res.translation)
# To translate without any adaptation, pass an empty list to `adapt_to`
res = lara.translate("Hello, world!", source="en", target="it", adapt_to=[])
print(res.translation) # Translation without adaptation
// List available translation memories for the account
console.log(await lara.memories.list())
let res = await lara.translate('Hello, how are you?', 'en-US', 'it-IT',
{
// Replace with actual memory IDs to use for adaptation
adaptTo: ["mem_1...", "mem_2..."]
})
console.log(res.translation)
// To translate without any adaptation, pass an empty list to `adapt_to`
res = await lara.translate('Hello, how are you?', 'en-US', 'it-IT', {adaptTo: []})
console.log(res.translation) // Translation without adaptation
// List available translation memories for the account.
System.out.println(lara.memories.list());
// Adapting the translation to specific memories.
TranslateOptions options = new TranslateOptions();
// Replace with actual memory IDs to use for adaptation.
options.setAdaptTo("mem_1...", "mem_2...");
TextResult res = lara.translate("Hello, how are you?", "en-US", "it-IT", options);
System.out.println(res.getTranslation());
// To translate without any adaptation, pass an empty list to `adapt_to`.
options.setAdaptTo(); // Translation without adaptation.
res = lara.translate("Hello, how are you?", "en-US", "it-IT", options);
System.out.println(res.getTranslation());
// List available translation memories for the account.
print_r($lara->memories->getAll())."\n";
// Replace with actual memory IDs to use for adaptation.
$options = new TranslateOptions(['adapt_to' => array('mem_1...', 'mem_2...')]);
$res = $lara->translate('Hello, how are you?', 'en-US', 'it-IT',
$options // Replace with actual memory IDs to use for adaptation.
);
echo $res->getTranslation();
// To translate without any adaptation, pass an empty list to `adapt_to`.
$res = $lara->translate('Hello, how are you?', 'en-US', 'it-IT',
array('adapt_to' => array()
));
echo $res->getTranslation(); // Translation without adaptation.
Lara team offers domain adaptation services that include the creation and maintenance of translation memories for enterprise subscribers. Adaptation services can be requested writing at support@laratranslate.com.
Tips for managing language codes
It is highly recommended to always specify the complete language locale code, (eg.
pt-PT
or and not justpt
) when adding content to translation memories. This ensures that, as new languages and variants are released, your translation memories will contain precise data that Lara can use for translations and regional adaptation.
Please refer to the Translation Memory Management section of the SDK documentation for information on how to upload a translation memory to Lara.
Updated 23 days ago