Coder Social home page Coder Social logo

nlp2ct / copyingpenalty Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sunbowliu/copyingpenalty

1.0 0.0 0.0 1.19 MB

On the Copying Behaviors of Pre-Training for Neural Machine Translation (Findings of ACL 2021)

Python 96.71% C++ 0.91% Cuda 2.08% Shell 0.06% Lua 0.24%

copyingpenalty's Introduction

On the Copying Behaviors of Pre-Training for Neural Machine Translation (Findings of ACL 2021)

Citation

Please cite as:

@inproceedings{liu2021copying,
  title={On the Copying Behaviors of Pre-Training for Neural Machine Translation},
  author={Liu, Xuebo and Wang, Longyue and Wong, Derek F and Ding, Liang and Chao, Lidia S and Shi, Shuming and Tu, Zhaopeng},
  booktitle={Findings of the Association for Computational Linguistics: ACL 2021},
  year={2021}
}

Requirements and Installation

This implementation is based on fairseq(v0.9.0)

  • PyTorch version >= 1.2.0
  • Python version >= 3.6
git clone https://github.com/SunbowLiu/CopyingPenalty
cd CopyingPenalty
pip install --editable .

Addtional Parameters

The copying penalty can be applied to both vanilla sequence-to-sequence learning models (--task translation) and (m)BART-initialized models (--task translation_from_pretrained_bart).
Please refer to fairseq and mBART for the training of models.

Features

  1. As simple and powerful as the length penalty.
  2. Particularly effective in the task of similar input and output domains.
  3. Trivial computational cost.
parameter description
--copypen Copying penalty: <1.0 favors copying source tokens, >1.0 favors translating (converting) source tokens; Default: 1.0
--target-dictionary-path Path to target side dictionary for automatically obtaining the punctuation list.

Mainly modified code: fairseq/sequence_generator.py

Tune a copying penalty on the validation set

mkdir $PATH_TO_OUTPUT/validation
for cp in 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
do
RESULT=$PATH_TO_OUTPUT/validation/$cp.txt
python generate.py \
    $PATH_TO_DATA \
    --gen-subset valid \
    --path $PATH_TO_OUTPUT/checkpoint_best.pt \
    --copypen $cp --target-dictionary-path $PATH_TO_TGT_DICTIONARY \
    > $RESULT
done

Apply the tuned copying penalty to the test set

python generate.py \
    $PATH_TO_DATA \
    --gen-subset test \
    --path $PATH_TO_OUTPUT/checkpoint_best.pt \
    --copypen $cp --target-dictionary-path $PATH_TO_TGT_DICTIONARY

copyingpenalty's People

Contributors

sunbowliu avatar

Stargazers

Runzhe Zhan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.