Giter VIP home page Giter VIP logo

shininglab / text-editing-as-imitation-game Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 7.77 MB

This repository is for the paper Text Editing as Imitation Game in Findings of the Association for Computational Linguistics: EMNLP 2022, pages 1583–1594, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.

Home Page: https://aclanthology.org/2022.findings-emnlp.114/

Python 100.00%
findings paper emnlp2022 imitation-learning text-editing

text-editing-as-imitation-game's Introduction

Text-Editing-AS-Imitation-Game

This repository is for the paper Text Editing as Imitation Game. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 1583–1594, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.

[arXiv] [Poster] [Slides] [Video]

Directory

  • main/env - Game Environments
  • main/res - Resources including model check points, datasets, and experiment records
  • main/src - Source code including model structures, training pipelines, and utility functions
Text-Editing-as-Imitation-Game
├── README.md
├── assets
├── main
│   ├── config.py
│   ├── envs
│   ├── main.py
│   ├── res
│   │   ├── ckpts
│   │   ├── data
│   │   └── log
│   └── src
│       ├── models
│       ├── trainers
│       └── utils
└── requirements.txt

Dependencies

  • python >= 3.10.6
  • tqdm >= 4.64.1
  • numpy >= 1.23.4
  • torch >= 1.13.0

Setup

Please ensure required packages are already installed. A virtual environment is recommended.

$ cd Text-Editing-AS-Imitation-Game
$ cd main
$ pip install pip --upgrade
$ pip install -r requirements.txt

Models

  • AR - base_seq2seq_lstm
  • AR* - seq2seq_lstm
  • NAR - base_lstm
  • D2 (NAR*) - lstm
  • Decoder0 - lstm0
  • Linear - lstm1
  • Shared D2 - lstm2

Run

Before training, please take a look at the config.py to ensure training configurations.

$ vim config.py
$ python main.py

Output

If everything goes well, there should be a similar progressing shown below.

Initializing Game Environment ...
Constructing Editops with Metric levenshtein ...
*Configuration*
device: cpu
random seed: 0
game: aor
src vocab size: 16
tgt vocab size: 18
model: lstm
trainable parameters: 13,184,580
max trajectory length: 6
max state sequence length: 10
max action sequence length: 2
if load check point: False
original train size: 7000
train size: 7000
valid size: 1500
test size: 1500
if sampling: True
batch size: 256
learning rate: 0.001

Train Loss:2.8253 LR:0.001000: 100%|█████████████████████████████████████| 27/27 [00:55<00:00,  2.05s/it]
Train Epoch 0 Total Step 27 Loss:4.3506 Token Acc:0.2886 Seq Acc:0.1972
 src: - 2 + 11 - 6 + 8 == 11
 tar: <done> <done>
 pred: <done> <done>
Valid Loss:2.7447 LR:0.001000: 100%|██████████████████████████████████████| 6/6 [00:03<00:00,  1.70it/s]
Valid Epoch 0 Total Step 27 Loss:2.6269 Token Acc:0.5951 Seq Acc:0.4076
 src: 2 * 2 6 9 6
 tar: <pos_3> /
 pred: <pos_1> -
Test Loss:2.5733 LR:0.001000: 100%|███████████████████████████████████████| 6/6 [00:03<00:00,  1.72it/s]
Test Epoch 0 Total Step 27 Loss:2.6115 Token Acc:0.5934 Seq Acc:0.4121
 src: 6 + 10 - 2 9 5
 tar: <pos_5> -
 pred: <pos_5> +
 ...

Authors

BibTex

@inproceedings{shi-etal-2022-text,
    title = "Text Editing as Imitation Game",
    author = "Shi, Ning  and
      Tang, Bin  and
      Yuan, Bo  and
      Huang, Longtao  and
      Pu, Yewen  and
      Fu, Jie  and
      Lin, Zhouhan",
    booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2022",
    month = dec,
    year = "2022",
    address = "Abu Dhabi, United Arab Emirates",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2022.findings-emnlp.114",
    pages = "1583--1594",
    abstract = "Text editing, such as grammatical error correction, arises naturally from imperfect textual data. Recent works frame text editing as a multi-round sequence tagging task, where operations {--} such as insertion and substitution {--} are represented as a sequence of tags. While achieving good results, this encoding is limited in flexibility as all actions are bound to token-level tags. In this work, we reformulate text editing as an imitation game using behavioral cloning. Specifically, we convert conventional sequence-to-sequence data into state-to-action demonstrations, where the action space can be as flexible as needed. Instead of generating the actions one at a time, we introduce a dual decoders structure to parallel the decoding while retaining the dependencies between action tokens, coupled with trajectory augmentation to alleviate the distribution shift that imitation learning often suffers. In experiments on a suite of Arithmetic Equation benchmarks, our model consistently outperforms the autoregressive baselines in terms of performance, efficiency, and robustness. We hope our findings will shed light on future studies in reinforcement learning applying sequence-level action generation to natural language processing.",
}

text-editing-as-imitation-game's People

Contributors

dependabot[bot] avatar mrshininnnnn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.