Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

LaraDocumentTranslator

Translate Haystack Documents using Lara, an adaptive translation API that combines LLM fluency with low hallucination and latency.

Key Features​

  • Translates Document text content using the Lara translation API.
  • Auto-detects source language when no source language is specified.
  • Supports translation memories and glossaries for consistent domain-specific terminology.
  • Offers three translation styles: faithful (accuracy), fluid (readability), and creative (expressive).
  • Accepts per-document translation settings via list parameters for batches with mixed language or style requirements.
  • Preserves original Document metadata and adds original_document_id to translated Documents.

Configuration​

  1. Sign up at laratranslate.com and get an access key pair.
  2. Set the LARA_ACCESS_KEY_ID and LARA_ACCESS_KEY_SECRET environment variables. For instructions, see Create Secrets.
  3. Configure LaraDocumentTranslator in your pipeline YAML with the source and target language codes.

Connections​

LaraDocumentTranslator takes a list of Document objects as documents input and outputs a list of translated Document objects as documents.

Connect a document converter's or retriever's documents output to the documents input. Connect the documents output to downstream processing components such as a document writer or embedder.

Source Code​

To check this component's source code, open document_translator.py in the Haystack Core Integrations repository.

Usage Examples​

Basic Configuration​

lara_translator:
type: haystack_integrations.components.translators.lara.document_translator.LaraDocumentTranslator
init_parameters:
access_key_id:
type: env_var
env_vars:
- LARA_ACCESS_KEY_ID
strict: false
access_key_secret:
type: env_var
env_vars:
- LARA_ACCESS_KEY_SECRET
strict: false
source_lang: en-US
target_lang: de-DE
style: faithful

Using the Component in a Pipeline​

# haystack-pipeline
components:
pdf_converter:
type: haystack.components.converters.pypdf.PyPDFToDocument
init_parameters: {}
lara_translator:
type: haystack_integrations.components.translators.lara.document_translator.LaraDocumentTranslator
init_parameters:
access_key_id:
type: env_var
env_vars:
- LARA_ACCESS_KEY_ID
strict: false
access_key_secret:
type: env_var
env_vars:
- LARA_ACCESS_KEY_SECRET
strict: false
source_lang: en-US
target_lang: de-DE
writer:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
- ${OPENSEARCH_HOST}
index: translated-docs
embedding_dim: 768
create_index: true

connections:
- sender: pdf_converter.documents
receiver: lara_translator.documents
- sender: lara_translator.documents
receiver: writer.documents

inputs:
files:
- pdf_converter.sources

max_runs_per_component: 100

metadata: {}

Parameters​

Init Parameters​

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
access_key_idSecretSecret.from_env_var("LARA_ACCESS_KEY_ID")Lara API access key ID.
access_key_secretSecretSecret.from_env_var("LARA_ACCESS_KEY_SECRET")Lara API access key secret.
source_langstr | NoneNoneSource language locale code (for example, en-US). If None, Lara auto-detects the language. See the supported languages list.
target_langstr | NoneNoneTarget language locale code (for example, de-DE). See the supported languages list.
contextstr | NoneNoneOptional context text sent to Lara to improve translation quality. This text is not translated.
instructionsstr | NoneNoneOptional natural-language instructions to guide translation style or terminology (for example, "Be formal").
stylestrfaithfulTranslation style. One of faithful (accuracy and precision), fluid (natural readability), or creative (artistic expression).
adapt_tolist[str] | NoneNoneOptional list of translation memory IDs for domain adaptation at inference time.
glossarieslist[str] | NoneNoneOptional list of glossary IDs for consistent terminology enforcement across translations.
reasoningboolFalseIf True, uses the Lara Think model for multi-step linguistic analysis. Increases latency and cost.