Manuscript Offprint

arXiv:2610.24593

Training with Ciphers to Enhance In-Context Terminology Learning For Translation from Rare Languages

Deevyanshu Malu, Deeptanshu Malu, Sunita Sarawagi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Training with Ciphers to Enhance In-Context Terminology Learning For Translation from Rare Languages Deevyanshu Malu1* Deeptanshu Malu1* Sunita Sarawagi1 *Equal Contribution 1 IIT Bombay {deevyanshumalu, deeptanshumalu}@cse.iitb.ac.in Abstract Fine-tuning LLMs with in-context examples (IC-Train) lets translation models adapt to new parallel data at deployment, but it is unclear whether they actually learn the translations of rare terms from those examples. We formal￾ize this capability as in-context term learning (ICTL). We show that standard IC-Train de￾velops this capability only weakly, and pro￾pose RareCipherFT, which strengthens it with￾out any lexical resources. RareCipherFT pairs each training target with in-context examples that share a rare term with it. It then replaces that term with a character-shuffled cipher in both the context and the reference, so the term can only be recovered by copying from context. The ciphered fraction of training data is an￾nealed to preserve translation quality. Across seven translation directions between English and Tamil, Assamese, Mizo, Nepali and Hausa, and four models from 1B to 7B parameters, RareCipherFT raises term recall over standard IC-Train by 5–15 absolute points without low￾ering COMET. Probes using synonyms, nonce words and controls for shared surface context show that these gains come from linking source terms to their in-context translations rather than from shortcuts. 1 Introduction The in-context learning (ICL) capability of LLM￾based machine translation systems has been found to be effective for continuous learning and adap￾tation, particularly for low resource languages where labeled data may not be available in one go (Moslem et al., 2023a; Li et al., 2025; Ramos et al., 2025; Zebaze et al., 2025). A complemen￾tary line of work has shown that this adaptation ability is further strengthened when the model is fine-tuned with in-context examples, a strategy we refer to as IC-Train (Min et al., 2022; Alves et al., 2023; Zheng et al., 2024; Bornschein et al., 2025). While IC-Train improves overall translation qual￾In-context example x 1 : ேதசிய அறிவியல் தினத்ைதெயாட்டி, விஞ்ஞானிகளுக்கு … y 1 : … has greeted the scientists on National Science Day. In-context example (distractor) x 2 : … ெவற்றி கரமாக ஏவிய … y 2 : … the team for the successful launch. Test x∗ : இந்த சாதைனைய பாராட்டி பிரதமர்விஞ்ஞானிகளுக்கு ெதாைலேபசி மூலமாக வாழ்த்து ெதரிவித்துள்ளார். Gold y∗ : The Prime Minister applauded the scientists, calling their achievement an inspiring one. RareCipherFT: The Prime Minister congratulated the scientists on the achievement through a phone call. ✓ ICFT: The Prime Minister congratulated the team for the successful launch. ✗ Figure 1: Motivating example of in-context term learn￾ing (ICTL), Tamil→English. The test source x ∗ and x 1 share the term விஞ்ஞானிகளுக்கு (“to the scientists”), so the model must find its translation scientists in y 1 and use it. The distractor x 2 shares the headline but is about a launch, which x ∗ never mentions. ICFT copies y 2 ver￾batim, while RareCipherFT copies scientists. Translit￾erations in Figure 8. ity via adaptation with new examples, a more fine￾grained question has received less attention: does the model actually learn new or rare terms from the in-context examples? Consider a test sentence x ∗ paired with an in￾context example (x i , y i ). If a rare source term u appears in both x ∗ and x i , and its translation v ap￾pears in y i , then the model has the opportunity to infer that u translates to v and place v at the cor￾rect position in its output translation of x ∗ (See Figure 1 for an example.) We call this capabil￾ity in-context term learning (ICTL). ICTL requires the model to perform a chain of implicit reasoning: to produce the rare term v, the model needs to lo￾cate its aligned word in the source x ∗ , align v in y i to corresponding u in x i , in-context lookup v using the shared source word u, and copy its trans￾lation to the appropriate output position. We show that standard IC-Train, which we call In-Context Fine-Tuning (ICFT), which simply maximizes likelihood of a target with similar examples in-context, does not sufficiently develop this chain.

Our goal in this paper is to strengthen such an implicit reasoning chain so that the model reliably extracts terms from in-context examples at inference time. We propose RareCipherFT, that promotes ICTL during IC-Train via two key ideas: First, we selectively include in-context examples that share rare terms with the target. In IC-Train, the model can predict a target token through either (i) parametric recall or (ii) contextual copying. Parametric recall suffices for high-frequency terms but fails on rare, domain-specific vocabulary absent from the fine-tuning corpus. By pairing examples with context that include shared rare terms, we are more likely to develop the ICTL capability. Second, we reinforce the effect further via a cipher-based data augmentation that replaces selected rare target-language tokens with synthetic ciphers obtained by a character-level shuffling of the original term. However, since ciphers distort original data distribution, we introduce a simple annealing to linearly decrease the fraction of ciphered training instances.

We evaluate RareCipherFT on seven language pairs spanning diverse rare languages (Assamese, Tamil, Mizo, Nepali, Hausa). We fine-tune four base models (Llama-3.2-1B, Qwen-2.5-1.5B, Qwen-2.5-3B, OLMo-3-7B). Our experiments show that RareCipherFT improves Term Recall over ICFT on all models without deteriorating overall translation quality. We present an analysis to provide evidence that our training does promote sound ICTL capabilities, while avoiding various learning short-cuts.

In this work our goal was to analyze and promote terminology learning from raw in-context examples. There is extensive prior work on promoting terminology translation in NMT, but they all require external lexical resources in the form of either a synonym dictionary, or a bilingual term dictionary. We compare with recent existing work that invoke an external alignment library to extract translation dictionary. We show that RareCipherFT better preserves fluency when incorporating term dictionaries than an existing state-of-the-art method (DragFT).

Contributions. (1) We formalize in-context term learning (ICTL) as a distinct capability, that allows a model to harness parallel in-context sentences to learn term translations. (2) We propose RareCipherFT that strengthens ICTL without requiring external lexical resources, through a combination of how examples are paired with context, and via selective ciphering. (3) We demonstrate consistent improvements in terminology extraction across seven language pairs and three model families. (4) We analyze the models with various probes that show evidence that RareCipherFT's training promotes sound ICTL, without degenerating to learning shortcuts. (5) We show that RareCipherFT achieves higher COMET for comparable term-recall than methods like DragFT (Zheng et al., 2024), that rely on an explicit bilingual term dictionary.

2 Related Work

ICL for MT. ICL has proven effective for continuous adaptation in MT (Moslem et al., 2023a), with similarity-based example selection, especially for low-resource languages (Zebaze et al., 2025). Tang et al. (2024) show that syntax- and coverage-aware retrieval of ICL examples improves adaptation, Li et al. (2025) show that ICL with parallel examples outperforms dictionary-based prompting for low-resource translation, and Ramos et al. (2025) find that learning from examples is more effective than instruction tuning. These observations motivate our focus on training models to extract terms from parallel sentences instead of glossaries.

IC-Train for MT. Min et al. (2022) first proposed fine-tuning with in-context examples to improve ICL, an idea since applied across diverse domains(Bornschein et al., 2025) including logical reasoning (Bertolazzi et al., 2026), neuroscience (Yu et al., 2025), and log parsing (Yu et al., 2026). For MT specifically, Alves et al. (2023) showed that IC-Train preserves ICL ability often lost during standard zero-shot fine-tuning. Malu et al. (2026) show that IC-Train with random contexts weakens ICL, while similar contexts encourage label copying; their Contrastive-Context data recipe, adds contrast to make the model robust across the full similarity spectrum. Other work fine-tunes per domain with varying data sizes (Vieira et al., 2024), preference pairs (Vieira et al., 2025), multi-stage schedules for shifting domains (Guan et al., 2025), or meta-learning with domain-specific data (Sharaf et al., 2020); our goal instead is a single model that adapts to new do-mains via ICL at inference time.

Terminology-aware MT. Prior work enforces terminology through constrained decoding (Chatterjee et al., 2022; Chen et al., 2021) or glossary-augmented LLM prompting (Zhang et al., 2023; Bogoychev and Chen, 2023; Moslem et al., 2023b; Ghazvininejad et al., 2023). Zheng et al. (2024)'s DragFT integrates bilingual glossary entries into source sentences to improve domain terminology. Unlike these methods, we assume no lexical resources at inference or training time: neither bilingual glossaries of term translations nor monolingual thesauri of target-language synonyms. Both are scarce for low-resource languages. Most prior work on terminology learning are on relatively high resource languages. Instead, we train the model to infer terminology mappings from parallel in-context demonstrations. The prompting tricks used in the TL literature are orthogonal to our focus in this paper of enhancing in-context term learning. Mutal et al. (2025) find that one to three in-context examples matching the test input's domain and register give the largest gains in medical MT, but they score only whole sentences and don't check whether terms are carried over from demonstrations.

Ciphers and synthetic tokens. Fang et al. (2025) use substitution ciphers as a diagnostic to disentangle task retrieval from task learning in ICL, showing that LLMs can decode latent bijective mappings from in-context demonstrations. Agarwal and Sarawagi (2025) show with synthetic sequence to sequence tasks that, LLMs struggle to uncover input-output alignments during ICL, and propose instead IC-Train to teach the missing alignment knowledge. Bafna et al. (2026) use ciphers to create synthetic low resource languages where they replace all tokens for a new task. Our work draws on a related intuition but uses cipher tokens not as a diagnostic probe but as a training signal that forces the model to develop robust contextual-copying circuits for cross-lingual terminology extraction. To our knowledge, this is the first application of cipher-based data augmentation to explicitly strengthen in-context term learning in MT.

References (28)