Giter Club home page Giter Club logo

bert_sim's Introduction

Bert_sim

This repository restore the sorce code and datasets for "Using Prior Knowledge to Guide BERT’s Attention in Semantic Textual Matching Tasks"

ESIM

1.First, you can use the get_similarity.py file in the ESIM/scripts/preprocessing folder to obtain the similarity matrix of the msrp/sts/url dataset. For QQP dataset, you should use get_similarity_quora.py. You can also use the matrix we have built, then this step can be skipped.

3.Then run the preprocess_msrp.py file in the preprocessing folder to preprocess the data.

5.Run under the ESIM/scripts/training folder.

python main_msrp.py --proportion 0.1 --output 10

--proportion specifies the size of the dataset, --output determines the storage location of models trained on datasets of different sizes, where 10 is 10% of the data
You can run python main_msrp.py directly, and use the default 100% data at this time.

Here is the data we have processed, Please place it under the ESIM/data/dataset folder after downloading.

We use glove.840B.300d as embedding, which can be downloaded here, and then please put it in the ESIM\data\embeddings folder.

BERT

1.Download the data we have processed, and put it in the UER/datasets folder, Or you can use the get_similarity.py file in ESIM to preprocess the data.

2.The data we provide cannot be directly used in the BERT model, so further preprocessing is required to adapt to the structure of the BERT model, use get_similarity.py in UER folder to further preprocess the data.

3.Then use the following command to run the BERT model

python run.py --train_path datasets/msrp/train.tsv 
--dev_path datasets/msrp/dev.tsv 
--test_path datasets/msrp/test.tsv 
--output_model_path models/msrp_100.bin 
--proportion 1.0

The pretrained_model can be dowmloaded here.

Citation

If you use this code, please cite this paper:

@inproceedings{xia2021using,
  title={Using Prior Knowledge to Guide BERT’s Attention in Semantic Textual Matching Tasks},
  author={Xia, Tingyu and Wang, Yue and Tian, Yuan and Chang, Yi},
  booktitle={Proceedings of the Web Conference 2021},
  pages={2466--2475},
  year={2021}
}

bert_sim's People

Contributors

xiatingyu 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.