Home

Awesome

<div align="center"> <img src="imgs/github.png" alt="Logo" width="200"> </div> <h2 align="center">🗺️ MAPS: Multi-Aspect Prompting and Selection</h2>

Implementaion of our paper:

Exploring Human-Like Translation Strategy with Large Language Models

🔥 Update

MAPS

Motivation

<p align="center"> <img src="imgs/intro.png" alt="intro" width="350" /> </p> The difference between machine and human translation in an English-Chinese example. Typical neural machine translation is a source-target mapping process, while human translators can take complex steps to ensure the quality and accuracy of the translation.

<br><br>

Framework

<p align="center"> <img src="imgs/method.png" alt="method" width="800" /> </p>

MAPS aims to enable LLMs to mimic the human translation process by multi-aspect prompting and selection.

<br>

Dependencies

<br>

Reproduce the main results

Run

Preparation

Run MAPS

Run other methods

Note: The translation results have already been generated and saved in the output directory. Therefore, the scripts won't repeat the inference. If you want to regenerate the results, simply delete the contents within the output directory.

<br>

Evaluation

sh run-evaluation.sh > evaluation.log

<br>

Interactive

If you just want to have a try, you can try the interactive script like this without need of GPU or CUDA (only text-davinci-003 now):

# Preparation
wget https://unbabel-experimental-models.s3.amazonaws.com/comet/wmt21/wmt21-comet-qe-da.tar.gz
tar -xf wmt21-comet-qe-da.tar.gz -C eval_ckpt/   
conda create -n maps -c pytorch python==3.8.13 pytorch==2.0.0  
conda activate maps
pip3 install -r requirements.txt
# Interactive
(maps) zwhe@zhiweideMacBook-Pro MAPS-mt % python3 interactive.py --lang-pair en-zh

Enter source English sentence: Joint Aid for Dogs is a high specification joint and muscle supplement with glucosamine for dogs, designed to aid freedom of movement.

Output:

<p align="center"> <img src="imgs/case-output.png" alt="method" width="1000" /> </p>

Remember to set your openai API_KEY in model/openai/translate.py. You can also take a look at the demo website.

Citation

@article{he2023exploring,
    author = {He, Zhiwei and Liang, Tian and Jiao, Wenxiang and Zhang, Zhuosheng and Yang, Yujiu and Wang, Rui and Tu, Zhaopeng and Shi, Shuming and Wang, Xing},
    title = "{Exploring Human-Like Translation Strategy with Large Language
                    Models}",
    journal = {Transactions of the Association for Computational Linguistics},
    volume = {12},
    pages = {229-246},
    year = {2024},
    month = {03},
    issn = {2307-387X},
    doi = {10.1162/tacl_a_00642},
    url = {https://doi.org/10.1162/tacl\_a\_00642},
    eprint = {https://direct.mit.edu/tacl/article-pdf/doi/10.1162/tacl\_a\_00642/2346100/tacl\_a\_00642.pdf},
}