Machine Translation with Large Language Models: Prompting, Few-shot Learning, and Fine-tuning with QL o RA (2023)

Abstract: While large language models have made remarkable advancements in natural language generation, their potential in machine translation, especially when fine-tuned, remains under-explored. In our study, we conduct comprehensive experiments, evaluating 15 publicly available language models on machine translation tasks. We compare the performance across three methodologies: zero-shot prompting, few-shot learning, and fine-tuning. Central to our approach is the use of QLoRA, an efficient fine-tuning method. On French-English, QLoRA fine-tuning outperforms both few-shot learning and models trained from scratch. This superiority is highlighted in both sentence-level and document-level translations, with a significant BLEU score improvement of 28.93 over the prompting method. Impressively, with QLoRA, the enhanced performance is achieved by fine-tuning a mere 0.77% of the model’s parameters.

## introduction the rapid advancement of large language models (llms) is reshaping the field of natural language processing (nlp), marking a potential paradigm shift in future development @xcite . instead of crafting dedicated task-specific systems, a growing interest has been focusing on quickly adapting llms to specific tasks simply through prompting @xcite . so far, studies have shown that prompting llms can match or even rival the performance of specialized systems on numerous nlp tasks @xcite . among all the nlp tasks, the application of llms to machine translation (mt) is understudied. the optimal way to harness llms for mt remains an open question. while encoder-decoderbased llms @xcite @xcite are inherently designed for the sequence-to-sequence demands of mt, the approach for leveraging decoder-only models is less straightforward. although there are initial attempts in this direction @xcite @xcite , these studies mainly concentrate on prompting and few-shot learning, not exploiting the availability of bitext. additionally, most work focus on exceptionally large llms like gpt3 @xcite with its staggering 175 billion parameters, which are beyond the reach of non-commercial research groups for local training. this poses a significant hurdle for institutions with constrained computational resources, rendering the findings less applicable and relevant to many researchers. in this paper, we aim to investigate the performance of llms on mt tasks, with a particular focus on decoder-based llms, a category less charted for mt applications. our research focuses on a range of publicly available mediumsized llms. this includes models pretrained on english-centric datasets, such as gpt-neo @xcite , opt @xcite , llama2 @xcite , as well as those on multilingual datasets such as xglm @xcite and bloomz @xcite . we evaluate various versions of these models, with their parameter sizes spanning from 1.3 billion to 13 billion, totaling 15 models. in our experiments, we explore zero-shot prompting, few-shot learning, and fine-tuning, where our emphasis on fine-tuning fills the gap in previous studies. for the fine-tuning process, we employ the qlora method @xcite , which enhances efficiency and minimizes memory usage by quantizing the model to 4-bit precision and limiting the number of trainable parameters. to the best of our knowledge, this is the first instance of qlora being applied to fine-tuning llms for mt tasks. we also evaluate the performance of llms in document-level translation. standard sequence-tosequence mt models focus on translating one sentence at a time, overlooking discourse phenom-ena and the broader context. existing methods for document-level translation often pivot toward architectural modifications @xcite @xcite , leading to specialized models that need unique designs. our objective is to evaluate the capability of llms in preserving long-term contextual coherence and to explore their potential in facilitating the development of a robust document-level translation system. we demonstrate the effectiveness of fine-tuning on a french-english dataset -this language pair is selected due to its accessibility for llms, positioning it as an ideal starting point for research in this domain. our experimental results, complemented by thorough analysis, reveal that: to attain an equivalent bleu score, it necessitates 21 times less training time and reduces the trainable parameters by 1370-fold compared to conventional fine-tuning. ## qlora qlora @xcite is an efficient finetuning approach that reduces the memory usage of training without compromising the 16-bit task performance. the approach involves quantizing a pretrained model to 4-bit precision. subsequently, a compact set of learnable low-rank adapter (lora, hu et al. ( 2021 )) weights are added, which can be tuned through backpropagation. lora motivated by the empirical findings of @xcite and @xcite , which suggest that llms possess a notably low intrinsic dimension for their parameters, lora hypothesizes a similar low intrinsic rank for weights during model adaptation. thus, lora introduces a reparameterization aimed at reducing dimensions. specifically, it employs a low-rank decomposition to represent the pretrained weights, resulting in newly-added adapter weight matrices, with the rank r anticipated to be considerably smaller than the original weight matrices' dimension. during finetuning, the pretrained weights are frozen, with only the newly incorporated adapter updated via backpropagation. a key observation is that as the rank r is reduced, there is a corresponding decrease in the number of adaptable parameters. ## sentence-level translation in this section, we assess the sentence-level translation performance of pretrained llms using prompting versus fine-tuned llms (section 5.1). we investigate the effects of incorporating or not incorporating qlora during the fine-tuning process (section 5.2). additionally, we analyze the impact of varying qlora hyperparameters (section 5.3), including the rank of the low-rank approximation (section 5.3.1), and the trainable parameters (section 5.3.2). we also conduct experiments with different sizes of fine-tuning data and compare the results of fine-tuned llms with the baseline nmt model (section 5.4). lastly, we explore few-shot learning with varying numbers of shots and diverse prompts (section 5.5). baseline is the nmt system described in section 4.2. rank r for qlora is set to 64. foot_2 ## document-level translation in this section, we delve into the proficiency of llms in document-level translation. our primary observations, contrasting the prompted and finetuned llms, are detailed in section 6.1. additionally, we explore the influence of document length, measured by the number of sentences per document, in section 6.2. ## qualitative analysis figure 4 shows translations of two french sentences using various llms. in the first example, when prompted, bloomz-7.1b replicates the source sentence verbatim, neglecting to translate. while this does not occur for every test set sample, as shown in the second example, similar behavior is noted in other prompted llms. on the other hand, french english l'onu donne un bilan même plus élevé avec 979 morts et 1 902 blessés. the un has reported even higher numbers with 979 dead and 1,902 injured. bloomz-7.1b p l'onu donne un bilan même plus élevé avec 979 morts et 1 902 blessés. bloomz-7.1b ft the un gives a higher figure with 979 dead and 1 902 wounded.<eos>.<eos>.<eos>. ## conclusions in this study, we investigate the capabilities of llms in performing machine translation tasks. through comprehensive experiments, we assess the effectiveness of prompting, few-shot learning, and fine-tuning using qlora for french-english translation. our key findings are: in the future, we are interested in exploring two primary avenues. (1) while our current study demonstrates the promise of llms trained on english-centric data for french-to-english translations, it raises intriguing questions: would these results hold true for other language pairs, especially for low-resource languages? and would there be a noticeable difference in performance between english-centric and multilingual llms in such scenarios? (2) our experiments are confined to decoder-based llms. moving forward, we are also interested in comparing these models against their encoder-decoder counterparts, such as mt5 @xcite , mbart @xcite , nllb @xcite .