Sub topic 8
Translate-Train, Translate-Test, and Few-Shot Target Data
Assume that you understand transformer classifiers, fine-tuning, and metrics such as accuracy and F1. This chapter focuses on choosing how training data reaches a target language. The model may be multilingual, but the data strategy still affects transfer quality.
Three ways to use target-language data
Suppose you have labeled English examples and want an intent classifier for German.
- Translate-train translates the labeled English training set into German, then fine-tunes the multilingual model on the translated examples.
- Translate-test keeps training in English, translates each German input into English at prediction time, and applies the English-trained model.
- Few-shot target data adds a small labeled German set to the training process.
The methods differ in where translation happens and what errors it can introduce.
| Strategy | Training data | Inference data | Main advantage | Main risk |
|---|---|---|---|---|
| Translate-train | Translated target-language examples | Native target language | Fast inference | Translation noise in training |
| Translate-test | Source-language examples | Translated to source language | No target training set needed | Translation latency and errors |
| Few-shot | Mostly source data plus some target data | Native target language | Adapts to local wording | Needs labeled target examples |
flowchart TD
A[English labeled data] --> B{Transfer strategy}
B --> C[Translate-train]
C --> D[Train on translated German data]
D --> E[Predict on native German]
B --> F[Translate-test]
F --> G[Train on English data]
G --> H[Translate German input to English]
H --> I[Predict]
B --> J[Few-shot target data]
J --> K[Combine English and labeled German]
K --> L[Predict on native German]Translate-train
Translate-train preserves the normal inference path. At training time, translate each labeled example into the target language and keep its original label.
from transformers import pipeline
translator = pipeline(
"translation",
model="Helsinki-NLP/opus-mt-en-de",
)
examples = [
{"text": "I want to cancel my order.", "label": "cancel_order"},
{"text": "Where is my package?", "label": "track_order"},
]
translated = [
{
"text": translator(item["text"], max_length=64)[0]["translation_text"],
"label": item["label"],
}
for item in examples
]
for item in translated:
print(item)In a real project, translate a large training split, validate the translations, and fine-tune on the resulting German text. Keep the original English data too when the model must support both languages.
Translation can change meaning, omit context, or choose unnatural wording. For that reason, mix translated examples with human-written target-language examples when possible. Do not evaluate on translated test data if the production input will be native German. That would hide errors caused by target-language phrasing.
Translate-test
Translate-test requires no target-language training set. During inference, translate each German input into English and send the result to the English-trained classifier.
This approach is useful when:
- The source-language classifier is already accurate.
- A reliable translation system is available.
- Inference latency and translation cost are acceptable.
- You cannot modify or retrain the classifier.
It has two separate failure points: the translation can lose the intent, and the classifier can misunderstand the translated wording. Cache translations when inputs repeat, and measure the complete pipeline rather than the classifier alone.
Few-shot target-language data
Few-shot adaptation uses a small labeled set from the target language. You can fine-tune only on that set, combine it with translated source examples, or use it for a final adaptation stage.
Target examples are valuable because they contain local vocabulary, spelling conventions, politeness patterns, and domain-specific terms that machine translation may miss. Stratify the sample across labels. Ten examples from one class do not compensate for zero examples from another class.
A practical sequence is:
- Fine-tune on the full source-language set.
- Add translated training examples if target coverage is weak.
- Adapt briefly on balanced, human-labeled target examples.
- Evaluate on a separate native target-language test set.
The best choice depends on resources. Prefer translate-train for low-cost native-language inference at scale. Prefer translate-test for a quick baseline or a fixed source-language model. Prefer few-shot data when a small amount of target labeling is affordable and wording differs substantially across languages.
Exercise
You have an English classifier, 200 human-labeled German examples, and strict low-latency requirements. Which strategy is the strongest starting point, and why?
Show answer
Use source training plus few-shot adaptation on the German examples, then predict directly on German. This avoids translation during inference and uses the available target-language wording.