Elamur Research

Efficiently Exploring Large Language Models for Document-Level Machine Translation with In-context Learning

Paper · 2024 · Menglong Cui, Jiangcun Du, Shaolin Zhu et al.

Summary

A sentence can be easy to translate word by word and still leave a translator with an important question. Who is doing the action when the source sentence leaves the subject unstated? Does a name refer to someone already introduced in the document? A sentence translated in isolation may leave those questions unresolved. Yet including a long stretch of the document alongside several examples can fill much of the space available for a translation request. Cui and colleagues investigate how to choose the context and examples that are worth that space in document-level machine translation.

Their method, Context-Aware Prompting, or CAP, starts with the sentence to be translated. It uses attention weights from a large language model to rank other sentences in the same document. The selected sentences are put back in document order and condensed into a summary. CAP uses that summary to search a collection of bilingual sentence pairs. The retrieved pairs become demonstrations in the translation prompt. The summary guides the search, and the pairs show the translator what source sentences and their translations look like. The adaptation takes place through the prompt, a procedure known as in-context learning.

On WMT22 newstest, CAP gives the highest document-level BLEU score among the tested prompt strategies for the larger Qwen chat variants in both German-to-English and Chinese-to-English. For Qwen-14B-Chat, it scores 36.57 and 26.77 in those directions, respectively. The smallest Qwen variant does better with an instruction alone on that news test. On GuoFeng, where the task is to translate omitted Chinese pronouns, CAP leads at every tested size. With Qwen-1.8B-Chat, it reaches 32.58 accuracy averaged across the benchmark's domains, compared with 29.29 without demonstrations. It also leads the tested prompting strategies on both WMT23 literary splits at every tested size.

The authors test what happens when CAP takes a fixed band of neighboring sentences or changes the way it combines token attention. Both variants lower news translation scores in the tested directions. A case study shows the kind of improvement the aggregate scores can conceal. Where other prompts produce a first-person expression or leave the possessor implicit, CAP recovers a third-person possessive that agrees with the reference. The evidence supports selecting demonstrations with the document in view. The extra attention and summarization steps add computation, and the authors identify consistent reference to people and things across a document as an open challenge.

Deep dive: Efficiently Exploring Large Language Models for Document-Level Machine Translation with In-context Learning

Context-Aware Prompting uses selected document sentences to retrieve translation examples, improving results on news, omitted pronouns, and fiction. · about 34 minutes to read

The problem and its context

What a sentence leaves implicit

Document translation poses a question about the unit of evidence. A system can produce a fluent English sentence from a Chinese sentence and still choose the wrong speaker, subject, or possessor. An earlier sentence may have introduced the person whose name the source writer now leaves out. The original readers can supply that connection from the passage. A translator working from the sentence alone may be able to write something grammatical while having little basis for deciding which person the sentence is about.

Zero pronoun translation gives the paper a focused way to study this problem. A zero pronoun is an understood pronoun with no written counterpart at the relevant point in the source. When the target language calls for an explicit expression, the translator needs to infer whom the source means and choose a form that fits the target sentence. The choice can concern the person who performs an action or someone whose work, property, or relationships the text describes. A fluent rendering that changes that person changes the meaning. The broader problem of tracking which expressions refer to the same person or thing is coreference resolution.

The paper also treats literary translation as a setting where sentence boundaries can hide the relevant evidence. A reference can point to an entity introduced much earlier. The right wording for a recurring expression can depend on what was established in another part of the text. A locally plausible lexical choice may disrupt continuity if a document has already established a different rendering for the same person or concept. The authors identify entity consistency, the interpretation of references, and the choice of words as material challenges for literary translation. Those challenges can overlap in a single sentence, making literature a broader test than pronoun restoration alone.

The distinction between cohesion and coherence helps explain the scope of the problem. A possessive, a repeated name, or a reference to a previously introduced topic can tie parts of the target text together. Those ties contribute to cohesion. Coherence concerns whether the translated passage makes sense as a whole, including whether the reader can follow who is involved and how the statements fit together. An individual pronoun can matter to both, but a passage can contain correct pronouns and still be hard to follow for other reasons. That is why the paper uses a targeted pronoun task alongside translation benchmarks that score the output more broadly.

How earlier translation systems used context

The paper groups earlier document translation research by how far it extends the input. One line retains the sentence as the immediate translation unit and gives the system a small amount of surrounding text. This provides more evidence than the sentence alone while keeping the input manageable. The design depends on relevant information being close enough to appear in the chosen neighborhood. When the decisive mention sits farther away, the available neighborhood can contain perfectly readable text and still omit the clue.

Document-to-document work tries to capture more of the passage in a single translation unit. As the authors describe it, early approaches combine multiple sentences into a longer sequence. Subsequent research trains standard systems built on the Transformer and attention architecture using augmented data or pretrained components. Other work changes attention itself to support translation at document scale. These approaches act on the unit of input, the training setup, or the architecture. The unified encoder and G-Transformer are examples the paper cites in its account of that progression. A Simple and Effective Unified Encoder · G-Transformer · Rethinking Document-level Neural Machine Translation

The rise of instruction-following systems opened a different route. A translation request could combine a written instruction with bilingual demonstrations, showing a system the kinds of inputs and outputs the user expects. Earlier work cited by Cui and colleagues found that 32 or more randomly sampled bilingual pairs could help sentence translation in the settings they studied. Other research investigated which examples to pick, including approaches that retrieve examples similar to the sentence being translated. Much of the translation research discussed in the paper concentrated on individual sentences. Prompting Large Language Model for Machine Translation · In-context Examples Selection · Adaptive Machine Translation

The paper identifies Wang and colleagues' investigation of GPT-3.5-TURBO as the closest earlier study of document translation with such a system. It also discusses work by Wu and colleagues that adapts translation behavior through fine-tuning, either by updating a restricted set of parameters or by updating all of them. Parameter updates and prompt construction address different parts of the task. Fine-tuning changes the translator before a request arrives. At inference, a system still has finite space for the document and examples. CAP investigates what a translator already capable of following instructions can do when the examples in that space have been chosen with the document in mind. Document-Level Machine Translation with LLMs

Why the examples and the document compete for space

A bilingual demonstration takes space on both sides. The request supplies a source example and the corresponding translation. A document-sized demonstration increases that cost because it includes a longer source passage and a longer translation. The actual input can also be much longer when it contains the passage to translate. Even where all of this fits, the authors point out that processing longer inputs carries a computational cost. Thus a prompting strategy that works with isolated sentences cannot simply assume the same number or kind of examples will fit a document task.

A separate question is what a useful example should resemble. Direct retrieval can find material close to the current sentence, which is sensible if the sentence itself contains the words and cues governing the translation. A missing pronoun exposes the weakness of that query. The sentence gives the retriever what was written and withholds exactly the person the translator must recover. A source sentence may also be about the same general subject as an example while depending on a different speaker or discourse situation. The usefulness of similarity depends partly on what text is used to measure it.

Nearby sentences supply an alternative source of evidence. In document order, they frequently retain the current thread of discussion and can show how recent material was translated. But position is an indirect cue. A discussion can resume after an interruption, and nearby lines can concern a different participant. If earlier translations are used as demonstrations, a mistaken choice in one sentence can also become part of the input for the next. The paper's prompting comparisons ask whether ranking document sentences first can improve on either proximity or direct similarity to the sentence alone.

CAP's design follows from these constraints. The authors use the document to decide what information matters to a particular sentence, compress that information into a search query, and spend the demonstration budget on bilingual pairs retrieved with that query. The sentence remains the focus of the translation step even though decisions about its examples depend on a wider passage. This is the sense in which the method is document-aware. It gives each sentence a way to draw on the document without making every available sentence an example for every translation decision.

The method, step by step

From the current sentence to a short list of examples

CAP makes two searches over different material. The first is inside the source document. The system asks which sentences in that document receive the most attention from the current sentence. The second is over a datastore, a collection of source sentences with corresponding translations. That search asks which stored sentences best match a summary of the relevant document context. The first search finds evidence belonging to the passage. The second finds bilingual examples that can demonstrate translation choices.

Consider a passage in which a person's name and role occur in one sentence, followed elsewhere by a description of their work with the person left implicit. A contextual search can pick up the sentence identifying the person even if other sentences are closer to the description. A summary of the selected material can describe the person and the research topic together. Examples retrieved with that summary have a chance to reflect the situation in the passage more closely than examples selected from the description alone. The examples can guide the choice of phrasing even though their source sentences belong to the datastore.

The paper calls the first stage the Dynamic Context Window. Here, a window is the set of sentences chosen as context for the current one. It can change its membership as the translation moves through the document. CAP ranks candidates by scores derived from attention, retains the highest-ranking sentences, and arranges the retained material in its original sequence. The summary therefore sees the selected events or statements in document order, even when their order in the ranking was different.

How CAP builds a translation prompt

The steps in order.

How CAP builds a translation promptStep 1: Read final-layer token attention1. Read final-layer token attentionStep 2: Rank document sentences for the current sentence2. Rank document sentences for the current sentenceStep 3: Restore the selected sentences to document order3. Restore the selected sentences to document orderStep 4: Summarize the selected context4. Summarize the selected contextStep 5: Retrieve bilingual examples using the summary5. Retrieve bilingual examples using the summaryStep 6: Add the examples to the translation prompt6. Add the examples to the translation promptStep 7: Generate the translation7. Generate the translation

How attention becomes a sentence score

The scoring procedure begins with attention between tokens. A token is one of the pieces into which the system divides text for processing. The units matter because CAP ultimately needs a sentence score, whereas the starting weights measure relationships between these smaller pieces. A Transformer layer contains several attention heads, each of which supplies its own weights. CAP takes the weights from the final layer and averages the heads for each pair of token positions.

attn[i,j] = (1 ÷ H) × ∑ₕ₌₁ᴴ attnʰ[i,j]

Here attn[i,j] is the averaged attention from token position i to token position j in the document. attnʰ[i,j] is the corresponding weight from head h in the final Transformer block. H is the number of attention heads. The sum, marked ∑, runs over those heads, and division by H gives their arithmetic mean. This step reduces the multiple head-specific weights for a pair of positions to a single value.

At that point the system knows, for a given token in the current sentence, how much attention goes to each eligible token position. The next step treats the candidate sentence as a group. For each token in the current sentence, CAP asks which token in the candidate sentence gets the highest attention and uses that maximum as the candidate's score for the current token. The result can remain high when a name or other useful expression attracts attention and the rest of the candidate sentence attracts little.

TS[i,S] = max {attn[i,k] : k ∈ tokens(S)}

TS[i,S] is the score from token i in the current sentence to the candidate sentence S. tokens(S) is the collection of token positions in S. The index k ranges over those positions, as indicated by ∈, meaning membership. attn[i,k] is the head-averaged weight calculated in the previous step. The operation max takes the largest such weight. The braces identify the values entering that operation, with the condition after the colon specifying which positions count.

The procedure repeats that comparison for the tokens of the current sentence. It then averages their scores for the candidate. A candidate may receive support from several current tokens through different parts of the candidate sentence. The final score combines those individual responses. The maximum within each candidate and the mean across the current sentence answer different questions. The first asks whether the candidate has a strongly attended token for the token under consideration. The second asks how large those peaks are across the current sentence.

SS[I,S] = avg {TS[i,S] : i ∈ tokens(I)}

SS[I,S] is the sentence-level score from the current sentence I to candidate sentence S. tokens(I) gives the positions that belong to I, and i takes each of those positions. TS[i,S] is the token-to-sentence score for that position and candidate. The avg operation takes the arithmetic mean of those values. The role of the two sentence arguments is directional. The procedure starts from tokens in I and looks for strong attention into S. Reversing the roles would ask a different question.

The order of the operations also matters. Suppose different attention heads favor different words inside the candidate. CAP first combines the scores for each individual pair of positions. It then looks for the strongest token in the candidate using those combined scores. This differs from choosing a favorite token inside each head and pooling the choices. Similarly, averaging the token-to-sentence scores at the end means that the entire current sentence participates. A very strong response from one current token can contribute to the score along with weaker responses from the others.

Once the scores are available, CAP takes the top N sentences, where N is the number to retain as document context. The rank determines which sentences survive. Their positions in the source determine the order in which the summary stage receives them. A related person may be introduced before an event becomes intelligible, so passing the sentences on in their original order preserves that sequence among the retained material. The description discusses surrounding document sentences when defining the ranking and emphasizes preceding context when introducing summarization. It gives no general numerical setting for N or a complete account of how availability of later sentences is handled.

What the summary is for

The retained sentences can still contain several propositions, names, and changes of topic. CAP asks a language system to compress that material into a short summary of the important topics and information. This summary acts as a query. Its job is to represent the context in a form that can be compared with the examples available in the datastore. A summary can bring together related information scattered across the selected sentences, even when no individual sentence states the connection in that form.

Compression changes what the retrieval stage sees. If the context identifies a researcher, establishes a topic, and then describes work without naming its subject, the summary can put the researcher and topic into the same representation. That lets the retrieval stage take account of both. It also means the choice of examples depends on what the summary preserves. A detail lost at this point cannot affect the search through the summary embedding, even if it appeared in the original document. The paper relies on a concise representation to make the retrieval query informative and manageable.

The output of this stage is distinct from the bilingual demonstrations. A summary describes the selected material. A demonstration contains a source sentence and its translation. In the pipeline the authors specify, the summary determines which demonstrations to retrieve, and the retrieved pairs go into the translation template. It would be a different experiment to insert the summary itself as the example, or to give the translator all the selected raw sentences as a replacement for the pairs. The design assigns each kind of text a particular role.

Finding bilingual pairs that match the summary

The datastore supplies candidate examples with ready-made target sentences. CAP uses sentence-transformers to turn the summary and each candidate source sentence into embeddings, numerical representations that can be compared. A candidate earns a higher score when its vector points in a direction more similar to the summary vector. The intended comparison is one of semantic similarity, so it can reflect related meanings even when surface wording differs. The paper cites the sentence-embedding work of Reimers and Gurevych for this stage. Making Monolingual Sentence Embeddings Multilingual

score(S, X) = cos(𝐒, 𝐗)

In this formula, S is the summary of the selected context and X is a candidate example sentence from the datastore. The bold characters 𝐒 and 𝐗 are their respective embeddings. score(S, X) is the retrieval score for that summary and candidate. The function cos is cosine similarity, which compares the directions of the two vectors. A higher score gives the sentence a higher position in the retrieval ranking. The symbol S therefore has a new meaning in the retrieval formula. In the attention formulas it denotes an individual candidate document sentence.

CAP retrieves the top K examples, where K determines how many bilingual pairs the translator will see. The quantity is separate from N, which controls how many document sentences feed the summary. When a datastore source sentence is selected, its accompanying target sentence comes with it. The comparison is made to the source example's representation, while the output delivered to the translation prompt has both sides. In the prompt-selection experiments, the authors set K to 3 as a compromise between performance and cost.

There is a useful distinction between the search CAP performs and the embedding-based baseline called Similar. Both can rank example sentences with sentence embeddings. Similar bases its query on the sentence to translate. CAP makes its query from a summary of selected document context. A comparison between them therefore tests whether the more elaborate route produces better demonstrations under the reported conditions. It leaves open how much improvement comes from finding the right document sentences and how much comes from the way those sentences are compressed into a query.

What is prepared beforehand and what happens at translation time

CAP uses existing bilingual data and instruction-tuned translation systems. The authors use chat variants from the Qwen and Baichuan families, chosen because they can follow instructions and support Chinese and English. CAP is applied by constructing the prompt for a particular input. Its description does not include an additional parameter-training stage for the translation system. It is an instance of few-shot learning at inference, in which a small set of examples accompanies the instruction for the task. Qwen Technical Report · Baichuan 2

For the news experiments, the authors draw on OPUS-100 and news-commentary-v15 as stores of bilingual examples. Following earlier example-selection work, they normalize punctuation with Moses and apply a length filter to sentence pairs. The filter excludes pairs whose reported source-to-target length ratio exceeds 1.5. That is a rule for cleaning the bilingual candidates, separate from the limits on how many context sentences and demonstrations are selected. For the experiments on literary translation, the training portion of the WMT23 literary dataset supplies the example store.

At translation time, CAP assembles the retrieved pairs using a prompt template adopted from earlier work by He and colleagues. The target system receives the prompt and generates the translation. The examples provide source-to-target patterns while the translation instruction identifies what to do with the input. The paper describes how the template is used and identifies the work it comes from. It does not spell out all of the prompt wording for the summarization and translation stages. Exploring Human-Like Translation Strategy

The procedure therefore has distinct costs at distinct stages. A short demonstration list limits what gets passed to the translator as examples. Selecting that list still requires reading attention weights, choosing context sentences, generating a summary, and ranking datastore entries. The authors' efficiency argument concerns using scarce demonstration space for better examples. Overall computation depends on the work required to make those choices, as well as on the length of the final prompt.

Experiments and results

The benchmarks and what their scores measure

The authors use different tests to ask different questions. WMT22 newstest supplies general news translation evaluation. The system comparison covers German into English, Chinese into English, English into German, and English into Chinese. The comparison among prompt-selection strategies concentrates on the directions into English. The news test documents serve as translation inputs and are evaluated against references. OPUS-100 and news-commentary-v15 supply material for retrieving demonstrations. Separating the evaluation role from the retrieval role is important when reading the results, since a score concerns the translations generated for the news test.

GuoFeng targets Chinese zero pronouns. Its material comes from movie subtitles, question-and-answer forums, government news, web fiction, and personal profiles. The diversity matters for the interpretation of the aggregate. Dialogue can leave a conversational participant unstated, whereas a profile may omit a person whose identity has already been established in the prose. The results in the paper average accuracy across the benchmark's domains. They indicate how each prompting strategy performs on that aggregate, without identifying which individual domain accounts for a given change.

WMT23 Literary Translation tests a broader form of context sensitivity. Its training data supply candidate bilingual examples. The in-domain split, test01, shares a domain with the datastore. The out-of-domain split, test02, differs from it in domain. This makes the relation between the query and the available examples part of the evaluation. A method can help on test02 even if the absolute score remains below test01, because those observations answer separate questions. The within-split comparison shows how a retrieval strategy fares against the other strategies on the same material.

The principal news metric is document-level BLEU, written d-BLEU. It measures overlap with reference translations using sequences of words or tokens, with results reported at document level. This gives a broad indication of translation quality in the authors' benchmark. It can be sensitive to many kinds of decisions at once, from repeated lexical choices to the wording of a particular sentence. A change in the score does not by itself identify which translation decisions produced it.

The authors also report chrF2, an instance of the character-based chrF metric, and use SacreBLEU for the document-level BLEU and chrF2 evaluation. The character-based comparison gives a complementary view of how candidate translations overlap their references. The targeted GuoFeng measure is accuracy for zero pronoun translation. The paper additionally uses BlonDe, a document-translation metric, in a supplementary news comparison. All experiments ran on 4 NVIDIA A100 GPUs. That hardware description establishes the experimental setting without supplying a runtime comparison among the strategies. BlonDe

CAP against other ways of choosing a prompt

The prompting comparison keeps the named Qwen chat variant the same within each set of scores while changing the source of the demonstrations. Zero-shot gives the translator an instruction without examples. Random draws bilingual pairs from the datastore without ranking them for the current input. BM25 selects examples by a lexical retrieval score, giving weight to how their words match the query. These baselines establish how the system fares with no demonstrations, with untargeted demonstrations, and with an established form of word-based retrieval.

Similar uses sentence embeddings to retrieve examples on the basis of the current sentence. Precedent takes an entirely different source of examples. It uses earlier sentences in the same document, paired with the translations generated for them in previous steps. This makes Precedent a useful comparison for context-sensitive translation. Earlier lines can name people, maintain the topic, or show how the system has already translated a recurring expression. The examples also inherit the quality of the earlier outputs.

The Qwen-7B-Chat news results show why it matters to include the instruction-only baseline. In German-to-English, randomly selected examples and the two direct retrieval strategies score below Zero-shot. Precedent improves on Zero-shot, and CAP gives the strongest result. This particular row tests several different sources of assistance for an identical translation direction and Qwen variant. Adding examples can help, but the result depends on the information the examples carry and the system's ability to use it.

Prompt strategies for Qwen-7B-Chat on German-to-English WMT22 newstest, document-level BLEU

CAP leads, with examples from previous translations the strongest alternative.

Prompt strategies for Qwen-7B-Chat on German-to-English WMT22 newstest, document-level BLEUZero-shot: 34.21Zero-shot34.21Random: 32.91Random32.91BM25: 32.90BM2532.90Similar: 33.43Similar33.43Precedent: 34.49Precedent34.49CAP (this paper): 34.86CAP (this paper)34.86
The numbers
System or settingd-BLEU
Zero-shot34.21
Random32.91
BM2532.90
Similar33.43
Precedent34.49
CAP (this paper)34.86

The result for Qwen-7B-Chat in Chinese-to-English illustrates how the balance can vary with direction. CAP scores 24.34 d-BLEU on WMT22 newstest, against 24.02 for Zero-shot and 23.65 for Precedent. Here the instruction alone ranks above the strategy using earlier translations. Similar scores 23.85, also above Precedent and below Zero-shot. The comparison identifies CAP as the best-scoring strategy for that configuration while showing that the other contextual strategy does not have the same ordering across directions.

With Qwen-14B-Chat, CAP scores 36.57 in German-to-English and 26.77 in Chinese-to-English on the same news test. Zero-shot reaches 35.99 and 26.37, respectively. Precedent lands at 35.75 in German-to-English and 26.49 in Chinese-to-English. For Qwen-72B-Chat, CAP reaches 38.14 into English from German and 29.32 into English from Chinese. Precedent is its closest competitor in both directions at 38.01 and 29.15. The strongest comparison changes across settings, so a report against a single alternative would give an incomplete picture of the benchmark.

The smallest Qwen variant is the exception to the pattern on WMT22 news. Qwen-1.8B-Chat scores 19.84 d-BLEU with Zero-shot and 18.56 with CAP for German-to-English. In Chinese-to-English, Zero-shot yields 17.28 and CAP yields 15.51. CAP still gives the best result among the tested strategies that provide examples for this variant in both directions. The choice to include Zero-shot reveals that even the strongest demonstration strategy need not beat the instruction by itself.

The authors suggest that small systems can struggle to extract the useful information in context. For Precedent, they also suggest a feedback mechanism. When an earlier translation is poor, using it as a demonstration can reinforce a bad decision in subsequent sentences. That explanation fits how Precedent is constructed. The news scores establish the relative performance of the methods, while the proposed reasons for the smallest variant's behavior remain interpretations of the pattern.

Comparison with dedicated translation systems

The paper compares the prompted chat variants with dedicated encoder-decoder translation systems. In that architecture, an encoder processes the source and a decoder generates the target sequence. MarianMT uses a separate pretrained system for each direction in these experiments. M2M100-1.2B and NLLB-3.3B are multilingual baselines. This comparison asks whether translations produced with CAP can compete with dedicated systems, beyond the question of which prompt works best for a fixed Qwen variant. No Language Left Behind

On German-to-English WMT22 newstest, NLLB-3.3B scores 36.35 d-BLEU and 67.74 chrF2. MarianMT scores 36.25 d-BLEU and 68.28 chrF2. Qwen-14B-Chat with CAP reaches 36.57 d-BLEU and 70.00 chrF2, while Qwen-72B-Chat with CAP reaches 38.14 d-BLEU and 70.44 chrF2. Qwen-7B-Chat with CAP is below the dedicated systems named here on d-BLEU at 34.86, while its chrF2 score of 68.84 exceeds their corresponding scores. That is a concrete case where the choice of evaluation metric changes the judgment about the smaller prompted system.

In Chinese-to-English on WMT22, NLLB-3.3B records 25.48 d-BLEU and 60.03 chrF2. Baichuan-7B-Chat with CAP records 25.06 d-BLEU and 60.70 chrF2. Baichuan-13B-Chat with CAP reaches 26.02 d-BLEU and 64.91 chrF2. Qwen-72B-Chat with CAP reaches 29.32 d-BLEU and 65.43 chrF2. These results establish that the comparison with dedicated systems depends on the chat variant and metric, even within a single translation direction. They also show that CAP is used with Baichuan as well as with Qwen in the cross-system experiments. The detailed within-system prompt comparison is reported for Qwen.

The authors report a clear advantage for the prompted systems in English-to-Chinese, a direction they identify as a strength of the Qwen and Baichuan families. English-to-German is the clearest counterexample to a general advantage across directions. On WMT22 newstest in that direction, NLLB-3.3B scores 34.08 d-BLEU and 69.23 chrF2. Qwen-72B-Chat with CAP scores 31.48 d-BLEU and 68.11 chrF2. The authors suggest the training emphasis on Chinese and English as an explanation for the difficulty generating German. The comparison measures translation performance and does not directly measure the effect of training-language composition.

This distinction is important because the comparison changes the underlying systems as well as the prompt. When CAP and Zero-shot are compared on the same Qwen variant, the strategy for preparing input changes while the system remains fixed. When CAP with Qwen is compared with NLLB or MarianMT, the systems and their prior training differ. The first comparison supplies evidence about prompt construction. The second tells a reader how competitive the resulting translation pipeline is on a particular benchmark.

What happens when the source leaves out a pronoun

The GuoFeng test puts the emphasis on whether the translation recovers the intended person when Chinese omits an expression that English calls for. CAP gives the highest average accuracy among the prompt strategies at all the tested Qwen sizes. With the smallest variant, it scores 32.58, compared with 29.91 for Precedent and 29.29 for Zero-shot. This is the same variant that loses to Zero-shot on both news directions. A prompt can make the targeted pronoun decision more accurate even when it fails to improve a broad translation score on a different benchmark.

For the other Qwen sizes, the margin over the strongest competitor varies. Qwen-7B-Chat reaches 42.13 average accuracy with CAP, while Precedent reaches 42.02. On Qwen-14B-Chat, CAP produces 41.87 against 40.45 for Precedent. With Qwen-72B-Chat, the corresponding values are 41.65 and 39.07. CAP ranks first at each size, and the highest CAP accuracy among the reported GuoFeng runs belongs to Qwen-7B-Chat. This differs from the ordering of the Qwen variants by CAP's document-level BLEU on the news directions in the prompting experiment.

Prompt strategies for Qwen-14B-Chat on GuoFeng, average zero pronoun translation accuracy

CAP leads, and using recent document translations performs better than direct similarity retrieval.

Prompt strategies for Qwen-14B-Chat on GuoFeng, average zero pronoun translation accuracyZero-shot: 38.30Zero-shot38.30Random: 37.55Random37.55BM25: 37.94BM2537.94Similar: 37.93Similar37.93Precedent: 40.45Precedent40.45CAP (this paper): 41.87CAP (this paper)41.87
The numbers
System or settingaccuracy
Zero-shot38.30
Random37.55
BM2537.94
Similar37.93
Precedent40.45
CAP (this paper)41.87

Precedent places above Similar for GuoFeng at every tested size. For example, with Qwen-72B-Chat, Precedent reaches 39.07 on the benchmark's average accuracy measure, and Similar reaches 37.39. The earlier sentences and their translations contain document-specific information that a datastore query based only on the current sentence may miss. The consistent ranking supports the paper's decision to use document context when selecting examples, although Precedent and Similar also differ in where their bilingual pairs come from and how those pairs were produced.

Literature in and out of the retrieval domain

The literary experiments compare CAP with Zero-shot, Random, and Similar. CAP has the highest document-level BLEU for every tested Qwen variant on both splits. On the in-domain test01 split, it gives Qwen-1.8B-Chat a score of 14.81, compared with 13.77 for Zero-shot. On out-of-domain test02, the same variant scores 9.95 with CAP and 8.93 with Zero-shot. Demonstrations chosen through CAP can therefore help this small system in a setting where the news results favored the instruction alone.

With Qwen-7B-Chat, CAP scores 19.65 on test01 and 14.73 on test02. The strongest alternative on test01 is Similar at 19.48, while on test02 it is Random at 14.21. With Qwen-14B-Chat, CAP gives 21.56 on test01 and 15.87 on test02. Zero-shot is the strongest alternative on both splits for that variant, scoring 21.43 and 15.52. As in the news comparison, the strongest competing prompt differs with the system and the evaluation setting.

For Qwen-72B-Chat, CAP scores 23.10 on test01, where Zero-shot gives 22.96. On test02, CAP scores 17.85 and the closest alternative is Similar at 17.55. Similar gives 21.67 on test01, where it trails Random at 21.94. That reversal makes the paper's general observation about direct similarity more precise. It can underperform random selection on literature, and it can also produce the strongest competing result on a particular split. CAP's lead holds across both splits in the tested configurations.

Prompt strategies for Qwen-72B-Chat on WMT23 Literary Translation test02, document-level BLEU

CAP scores highest on the out-of-domain split, followed by direct similarity retrieval.

Prompt strategies for Qwen-72B-Chat on WMT23 Literary Translation test02, document-level BLEUZero-shot: 16.61Zero-shot16.61Random: 16.68Random16.68Similar: 17.55Similar17.55CAP (this paper): 17.85CAP (this paper)17.85
The numbers
System or settingd-BLEU
Zero-shot16.61
Random16.68
Similar17.55
CAP (this paper)17.85

The authors relate these gains to the literary need for context, including consistent handling of entities across a text. The reported literary numbers measure overall reference overlap. They establish the order of the prompting strategies by document-level BLEU, while leaving the contributions of entity consistency, pronoun interpretation, and word choice combined. The out-of-domain result specifically shows that CAP can help when the test material differs in domain from the datastore. The lower absolute scores on test02 give a separate indication of how the system fares on that split.

Checking the news result with a document metric

The appendix reports BlonDe scores for Qwen-7B-Chat and Qwen-14B-Chat on WMT22 newstest. CAP leads the tested prompt strategies for both variants in German-to-English and Chinese-to-English. With Qwen-7B-Chat, CAP scores 47.00 for German-to-English and 35.20 for Chinese-to-English. Zero-shot scores 46.88 and 35.15, respectively. The lead is present on a metric intended for document translation as well as on d-BLEU, though the closest scores in these comparisons are close.

For Qwen-14B-Chat, CAP scores 50.23 BlonDe for German-to-English against 50.01 for Zero-shot. In Chinese-to-English, CAP scores 38.90 and Similar scores 38.82. The best competing strategy thus changes with direction on this metric as well. The appendix establishes that CAP's ranking in the tested news conditions survives a change of metric for these variants. It reports overall BlonDe scores, leaving open which individual aspects of document translation account for the differences.

What the ablations show

Choosing context by relevance or by location

An ablation changes part of a method to see whether its contribution remains visible in the outcome. The paper's comparison on WMT22 newstest examines the selection of document sentences and the way token attention is pooled. Both changes leave a translation pipeline that can still select context, retrieve examples, and generate output. The comparisons ask whether specific choices inside that pipeline contribute to the reported d-BLEU.

The first variant replaces the Dynamic Context Window with a fixed one. It uses the two preceding and two subsequent sentences as context for the current sentence. This is a meaningful alternative because it still supplies document information and makes it straightforward to preserve local sequence. It also embodies a different assumption about relevance. A fixed window treats proximity as the rule for inclusion. CAP allows the membership of the context to depend on what the current sentence attends to.

On German-to-English WMT22 newstest, the fixed-window variant records 35.84 d-BLEU and full CAP records 36.57. On Chinese-to-English, the fixed window gives 26.03 and full CAP gives 26.77. In both directions, the tested attention-ranked window leads to higher translation scores than the tested neighborhood. Because the window determines the text that gets summarized, this comparison captures the downstream effect of changing the selected context. It does not identify which candidate sentences mattered in each document, or how frequently useful context lay beyond the fixed band.

The fixed window is also different from the primary Precedent baseline. The window variant changes the source sentences that go into the selection and retrieval process. Precedent forms its demonstrations by pairing previous source sentences with the translations the system has already generated for them. The fixed-window ablation thus compares ways of supplying context to CAP. A comparison with Precedent spans both the source of the examples and the role of prior generated translations.

Taking the strongest token match or averaging the candidate

The second ablation changes the token-to-sentence operation. It replaces the maximum over a candidate's tokens with an average over them. The last aggregation, across tokens in the current sentence, remains a separate step. With the maximum, a strongly attended expression in the candidate can carry its score for a given current token. With the average, the value depends also on the rest of the candidate, so a high weight on an informative expression can be diluted by low weights elsewhere.

The average variant gives 36.05 d-BLEU in German-to-English WMT22 newstest and 26.38 in Chinese-to-English. The corresponding values for full CAP are 36.57 and 26.77. This gives empirical support to the maximum as part of the tested ranking procedure. A plausible reason is that some useful context consists of a small number of tokens within a sentence, such as a name or a role. The ablation measures final translation scores, so it leaves that account of the underlying attention patterns open to further testing.

The two variants probe complementary design decisions. One replaces attention-based ranking with a fixed rule for selecting a neighborhood. The other preserves attention-based ranking but changes the calculation that makes it possible. Together they show that both the source of the sentence-selection signal and the pooling operation matter in the reported news setup. They do not separately test whether summarization outperforms using the selected sentences directly as a query, or whether the same gains would hold with a different summarizer.

What attention and individual outputs reveal

The paper visualizes final-layer attention for Qwen-14B-Chat in a zero pronoun translation example. The plotting convention assigns darker shading to tokens with higher attention. While generating the English pronoun he, the translation system gives noticeable attention to material associated with the relevant subject, including the Chinese pronoun 他 in retrieved examples. This makes the system's use of the prompt visible at the token level. The pattern is compatible with a demonstration supplying a cue at the point where the translation must express a person the source sentence omitted.

A supplementary visualization shows attention to a subject's name and a title identifying that person as a professor. This adds detail about the kind of contextual material that can be prominent while the English pronoun is generated. The visualization concerns the generation of a particular output, whereas the sentence-ranking rule uses aggregated token attention to choose context earlier in the pipeline. Both stages use attention information in the analysis, but the figure is an observation about a translation example. It does not measure the effect of replacing or removing the highlighted tokens.

The main case study gives the pronoun decision a concrete meaning. The Chinese source describes research areas without stating whose work they are. In the reference, the English sentence supplies a third-person possessive. For Qwen-14B-Chat, Zero-shot makes the description about a group including the speaker, and Random makes it about the speaker alone. Similar presents the research areas without resolving the possessor explicitly. CAP produces a third-person possessive consistent with the reference. All the outputs can convey something about the topic of the research, so the example turns on whom the text is about.

The supplementary case concerns a question about driving with a manual or automatic transmission. The Chinese omits the person being addressed, and the reference uses the second person in English. CAP also produces a second-person form. The other prompts introduce first-person perspectives in at least part of the translation or shift the interpretation of the situation. Even in CAP's output, the surrounding wording differs from the reference, including its description of the vehicle controls. The case is informative about recovering the addressee, while the rendering of the rest of the sentence remains a separate translation question.

These cases explain why the paper reports zero pronoun accuracy separately from general translation metrics. A translation can identify the correct person and have other lexical or semantic problems. It can also overlap much of the reference while assigning an action or possession to the wrong person. The cases show both how the prompts can change the grammatical expression in English and how a narrowly correct choice fits into a translation with other decisions still to evaluate.

Limitations

Limits identified by the authors

The authors identify coreference consistency as a continuing challenge. GuoFeng accuracy tests a particular kind of omitted expression, and the reported BLEU and BlonDe scores summarize broader aspects of translation. A document may require consistent reference across many sentences, across repeated mentions of different people, and through shifts in perspective. A method can improve the choice of an omitted pronoun in one sentence while leaving other links in that chain unresolved. The paper treats more complete handling of those links as future work.

The language coverage is another stated limit. The benchmark comparison covers a set of directions involving English, German, and Chinese, and the focused zero pronoun task concerns translation from Chinese. These directions make it possible to observe differences such as the stronger result into Chinese and the difficulty into German relative to a dedicated system. They do not establish how the approach behaves for a wider range of language pairs, source-side omissions, or systems of reference. The authors call for testing in more directions.

Computational demand is the third explicit limitation. The pipeline computes dynamic context and generates a summary before it prepares the translation prompt. The authors describe the resulting load as slightly higher than that of the baseline and identify a more efficient procedure as a goal for later work. The method addresses how to fit useful demonstrations into a limited window. Its advantage in using that space coexists with the extra inference work required to select the demonstrations.

Limits visible in the evaluation

The general translation gains and the claims about discourse operate at different levels. The literary experiment reports document-level BLEU, which cannot by itself isolate how often a person or place is named consistently. The news appendix reports an aggregate document metric. The pronoun benchmark directly measures a narrower phenomenon, but its aggregate across domains does not show whether an improvement is spread evenly across those domains. The attention figures and case studies provide examples of successful choices without estimating how common those mechanisms are across the test data.

The size comparisons also merit separate readings for each task. The larger Qwen variants tend to have higher document-level BLEU on the reported news comparisons, while the GuoFeng results with CAP peak at a smaller variant. The smallest Qwen variant benefits on the literary splits and pronoun benchmark, yet loses to Zero-shot on the news directions. The findings demonstrate that context-aware examples can help at several sizes. They leave the usefulness of demonstrations dependent on the task and on the ability of the translator and its supporting stages to use the available evidence.

The paper's reported scores also leave uncertainty about the repeatability of close comparisons. A lead such as 42.13 against 42.02 on GuoFeng average accuracy describes the ranking of the runs in the table. The paper gives no intervals around those values and provides no account of variation over repeated draws for the random-example strategy in that comparison. Seeing CAP lead across several configurations is evidence of a recurring pattern. Interpreting a close individual comparison requires information about variability that the score alone cannot supply.

The component comparisons are narrower than the full method. A fixed window and average pooling are informative alternatives, but both ablations concern the early context-selection stage and are reported for the news test. They leave the contribution of the summary stage relative to direct retrieval from the same selected sentences unresolved. Likewise, a fixed number of demonstration pairs does not establish that the competing prompts contain the same amount of text. Example count constrains the design, while prompt length also depends on the length of each example.

The practical efficiency claim is limited in a similar way. The paper states the experimental hardware and notes the cost of the extra stages. It does not quantify the tradeoff with an end-to-end comparison of translation time or measured prompt lengths. It also does not test how the costs change as documents grow. Attention scoring requires access to the relevant internal weights, which is a practical condition of implementing the method as described. If those weights cannot be obtained, the recipe would need another means of ranking sentences, and the paper's ablation results cannot be transferred directly to that replacement.

Finally, the datastore sets the range of demonstrations the search can return. The out-of-domain literary test shows gains with the store used in that experiment, even across a domain difference. It does not show how CAP behaves when the store lacks useful parallels for the language pair, genre, or kind of reference that the translator needs to resolve. Summarization adds a related dependence. It can preserve a useful topic or relationship, but it can also omit the very detail that would distinguish the right example from a broadly similar one. The experiments evaluate the resulting pipeline on the given stores and benchmarks, leaving those sources of retrieval failure unmeasured.

What came after

The later citing work points to several stages at which document context can influence translation. CAP concentrates on the preparation of a prompt. It selects sentences from the current document, uses a summary to retrieve bilingual examples, and lets the translator generate from the resulting input. The later titles indicate work on decisions during decoding, on an explicit representation of discourse, and on an adaptive translation agent. The citation links establish that these works cite Cui and colleagues. Their titles identify the broad technical connections, with the details of how they use or evaluate CAP left unspecified.

The work on quality-aware decoding addresses discourse translation through the stage that produces a target sequence. A useful way to locate the relationship is to ask when the intervention takes effect. CAP changes the evidence available before generation by choosing demonstrations. Quality-aware decoding locates the intervention in decoding, when the translation is being produced. Both concern the relationship between the document and the eventual output, with different roles for prompt construction and generation. The title identifies the decoding focus without establishing which quality signals it uses or whether it reuses CAP's retrieval procedure. Unlocking Latent Discourse Translation

The discourse-graph study identifies a graph as the guide for document translation. Its connection to CAP is the question of how to represent links between parts of a document so that they can guide an individual translation decision. CAP converts token attention into a ranking for the current sentence, then carries information from the selected sentences forward in a summary. A discourse graph places relationships at the center of the representation. The title supports that distinction in approach. It leaves open how the graph is formed, what relationships it encodes, and how its use is compared with context ranking or retrieval. Discourse Graph Guided Document Translation

AdaDPI names dynamic parametric internalization as the adaptation mechanism for a document translation agent. The stated mechanism places the connection with CAP at the level of how a translator adapts to a document. In CAP, the relevant document information affects which examples appear in the input, without a parameter update in the described procedure. AdaDPI's title points to a parametric route to adaptation. That gives the two works a common question about how document evidence conditions translation, while leaving the agent's implementation and its direct use of CAP unspecified. AdaDPI

Cite

Cite as Menglong Cui, Jiangcun Du, Shaolin Zhu and Deyi Xiong. 2024. Efficiently Exploring Large Language Models for Document-Level Machine Translation with In-context Learning. Findings of the Association for Computational Linguistics: ACL 2024.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2024.findings-acl.646

@inproceedings{cui2024efficiently,
  title = {{Efficiently Exploring Large Language Models for Document-Level Machine Translation with In-context Learning}},
  author = {Menglong Cui, Jiangcun Du, Shaolin Zhu and Deyi Xiong},
  booktitle = {Findings of the Association for Computational Linguistics: ACL 2024},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.646},
  url = {https://doi.org/10.18653/v1/2024.findings-acl.646}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/cui-2024-efficiently-exploring-large-language-models/