Home

Awesome

ReflectionLLMMT

<div align="center"> <img src="images/logo.png" width=250></img> <p class="image-caption">TasTe: Teaching Large Language Models to Translate through Self-Reflection</p> </div>

📣 News

🔗 Quick Links

🤖 About TasTe<a name="about"></a>

The TasTe framework, which is short for Teaching Large Language Models to Translate through Self-Reflection, is designed as a two-stage inference process to enhance the translation quality of MT-LLMs. It consists of the following two stages:

To ensure the sufficient capability for the entire self-reflective translation process, the LLMs are fine-tuned on a multi-task training set. The dataset consists of three parts:

<div align="center"> <img src="images/framework.png"></img> <p class="image-caption">The Framework of TasTe</p> </div>

📜 File Structure<a name="structure"></a>

DirectoryContents
checkpoints/Fine-tuned model checkpoints
data/Experimental Data
infer/Testing scripts
results/Testing outputs
train/Fine-tuning scripts

🛠️ Requirements<a name="requirements"></a>

TasTe is developed with HuggingFaces's transformers and Deepspeed-chat.

🚀 Quick Start<a name="start"></a>

Installation

git clone https://github.com/YutongWang1216/ReflectionLLMMT.git
cd ReflectionLLMMT
pip install -r requirments.txt

Fine-tuning for TasTe models

(1) FixEmb: Tuning with Embedding Layers Fixed

(2) Full: Tuning with Full Parameters

Make sure to fill in the following parameters before running:

work_dir=/path/to/ReflectionLLMMT      # path to the ReflectionLLMMT root directory
model_name=name_of_your_model          # name your model, e.g. bloom_fixemb
settings=tc                            # training settings, choices=[tc, qe, mt]
premodel=/path/to/original/checkpoint  # path to the pretrained model checkpoint directory
GPU_NUM=8                              # number of available GPUs
GPU=0,1,2,3,4,5,6,7                    # GPU ids

There are three choices of training settings, corresponsing to three different training sets:

  1. tc - Fine-tune with data in data/train_tc.json to get a TasTe model in Text Classification style.
  2. qe - Fine-tune with data in data/train_qe.json to get a TasTe model in Quality Estimation style.
  3. mt - Fine-tune with data in data/train_mt.json to get a MT-baseline model.

Evaluating TasTe models

Make sure to fill in the following parameters before running:

work_dir=/path/to/ReflectionLLMMT  # path to the ReflectionLLMMT root directory
lang=zh-en                         # language pair to be tested in, choices=['zh-en', 'en-zh', 'de-en', 'en-de']
test_model=name_of_model           # name of the fine-tuned model you gave
settings=tc                        # model settings, choices=[tc, qe, mt]
GPU_NUM=8                          # number of available GPUs

There are also three choices of testing settings, corresponsing to three different training settings:

  1. tc - Test a TasTe model in Text Classification style.
  2. qe - Test a TasTe model in Quality Estimation style.
  3. mt - Test a MT-baseline model.

📝 Citation<a name="citation"></a>

If you find this repo useful, please cite our paper as:

@inproceedings{wang-etal-2024-taste,
    title = "{T}as{T}e: Teaching Large Language Models to Translate through Self-Reflection",
    author = "Wang, Yutong  and
      Zeng, Jiali  and
      Liu, Xuebo  and
      Meng, Fandong  and
      Zhou, Jie  and
      Zhang, Min",
    editor = "Ku, Lun-Wei  and
      Martins, Andre  and
      Srikumar, Vivek",
    booktitle = "Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
    month = aug,
    year = "2024",
    address = "Bangkok, Thailand",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2024.acl-long.333",
    pages = "6144--6158",
    abstract = "Large language models (LLMs) have exhibited remarkable performance in various natural language processing tasks. Techniques like instruction tuning have effectively enhanced the proficiency of LLMs in the downstream task of machine translation. However, the existing approaches fail to yield satisfactory translation outputs that match the quality of supervised neural machine translation (NMT) systems. One plausible explanation for this discrepancy is that the straightforward prompts employed in these methodologies are unable to fully exploit the acquired instruction-following capabilities. To this end, we propose the $\textbf{TasTe}$ framework, which stands for translating through self-reflection. The self-reflection process includes two stages of inference. In the first stage, LLMs are instructed to generate preliminary translations and conduct self-assessments on these translations simultaneously. In the second stage, LLMs are tasked to refine these preliminary translations according to the evaluation results. The evaluation results in four language directions on the WMT22 benchmark reveal the effectiveness of our approach compared to existing methods. Our work presents a promising approach to unleash the potential of LLMs and enhance their capabilities in MT. The codes and datasets are open-sourced at https://github.com/YutongWang1216/ReflectionLLMMT.",
}