Home

Awesome

Code of our paper "Enhancing Cross-lingual Natural Language Inference by Prompt-learning from Cross-lingual Templates"

Prerequisites

Our codes are based on the bert4keras framework.

Datasets

We use XNLI and PAWS-X in our experiments.

DatasetsDownload Links
XNLIhttps://cims.nyu.edu/~sbowman/xnli/
XNLI (fewshot)https://github.com/mprompting/xlmrprompt
PAWS-Xhttps://github.com/google-research-datasets/paws/tree/master/pawsx

Put the datasets into the directory PCT/datasets/.

We also provide the code for converting the pytorch checkpoint to the tensorflow version (see the directory torch2tf).

Use examples

You can run our models on the google colab platform.

  1. Install requirements:

! pip install keras_bert transformers sentencepiece tensorflow==2.4.0

  1. Train model on TPUs:

! python PCT/train_xnli.py

  1. Evaluate model on TPUs:

! python PCT/predict_xnli.py

We also provide the notebook file, please see MAIN.ipynb

Citation

Please consider citing the following paper if you find our codes helpful. Thank you!

@inproceedings{QiWDC22,
  author    = {Kunxun Qi and Hai Wan and Jianfeng Du and Haolan Chen},
  title     = {Enhancing Cross-lingual Natural Language Inference by Prompt-learning
               from Cross-lingual Templates},
  booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational
               Linguistics},
  pages     = {1910--1923},
  year      = {2022}
}