Giter Club home page Giter Club logo

nlp-series-sentence-embeddings's Introduction

项目说明

本项目是句子embedding、语义匹配任务的代码复现 包括以下四种方法

  • BERT_avg
  • BERT_whitening
  • SBERT
  • SimCSE

具体方法原理和效果,请看我的知乎博客https://zhuanlan.zhihu.com/p/388680608

环境

  • python=3.6
  • torch=1.7
  • transformers=4.5.0

运行示例

数据集的准备

  1. https://github.com/pluto-junzeng/CNSD 把SNLI数据集和STS-B数据集下载到data文件夹
  2. 运行https://github.com/zhengyanzhao1997/NLP-model/blob/main/model/model/Torch_model/SimCSE-Chinese/SNIL_data_process.py 处理SNLI数据集

BERT_avg

python3 run_BERT_avg.py
--model_path=预训练模型路径
--pooling=first-last

BERT_whitening

python3 run_BERT_whitening.py
--model_path=预训练模型路径
--pooling=first_last
--dim=768

SBERT

python3 run_SBERT.py
--model_path=预训练模型路径
--dataset=STS-B
--max_len=80

SimCSE(unsupervised)

python3 run_SimCSE_unsupervised.py
--model_path=预训练模型路径

SimCSE(supervised)

python3 run_SimCSE_supervised.py
--model_path=预训练模型路径

nlp-series-sentence-embeddings's People

Watchers

James Cloos 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.