Code Monkey home page Code Monkey logo

attentionguiding's Introduction

Paying More Attention to Self-attention: Improving Pre-trained Language Models via Attention Guiding

by Shanshan Wang, Zhumin Chen, Zhaochun Ren, Muyang Ma, Huasheng Liang, Qiang Yan, Pengjie Ren

@article{wang2022paying,
title={Paying More Attention to Self-attention: Improving Pre-trained Language Models via Attention Guiding},
author={Wang, Shanshan and Chen, Zhumin and Ren, Zhaochun and Ma, Muyang and Liang, Huasheng and Yan, Qiang and Ren, Pengjie},
journal={arXiv preprint arXiv:2204.02922},
year={2022}
}

Running experiments

Requirements

This code is written in PyTorch. Any version later than 1.9 is expected to work with the provided code. Please refer to the official website for an installation guide.

Datasets

The datasets used in this work are MultiNLI for natural language inference, MedNLI for natural language inference on medical domain and Cross-genre-IR for the across medical genres query. And then put the downloaded dataset in the .data/ folder.

Training

  • Run the following scripts for model training on different datasets:
python ./train/multiNLI/multiNLI_main_train.py --model_name='bert-base-uncased' --loss_type='task+both' --pd_factor=0.001 --ad_factor=0.001
python ./train/medNLI/medNLI_main_train.py --model_name='bert-base-uncased' --loss_type='task+both' --pd_factor=0.001 --ad_factor=0.001
python ./train/IR/IR_pair_main_train.py --model_name='bert-base-uncased' --loss_type='task+both' --pd_factor=0.001 --ad_factor=0.001

Evaluating

  • Run the following scripts for model evaluation on different datasets:
python ./test/multiNLI_test.py --model_name='bert-base-uncased' --loss_type='task+both' --pd_factor=0.001 --ad_factor=0.001
python ./test/medNLI_test.py --model_name='bert-base-uncased' --loss_type='task+both' --pd_factor=0.001 --ad_factor=0.001
python ./test/IR_pair_test.py --model_name='bert-base-uncased' --loss_type='task+both' --pd_factor=0.001 --ad_factor=0.001

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.