Code Monkey home page Code Monkey logo

sbert's Introduction

SBERT

Repo for sbert implementation for NLI with siamese BERT transformer architecture from the paper: BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.

grafik

Prerequisites

Conda environment

Install conda environment named "sbert" from yml (more information in conda documentation)

$ conda env create -f environment.yml

Activate environment

$ conda activate sbert

Dataset (raw data)

Download and unpack the raw data from:

https://sbert.net/datasets/AllNLI.tsv.gz

Settings

Adjust settings for your preference.

{
    "general": {
        "job_id" : "Test_Run",
        "train_device": "gpu"
    },
    "network": {
        "architecture": "bert-base-cased",
        "tokenizer_name": "bert-base-cased",
        "pretrained": true,
        "epochs" : 2,
        "batch_size" : 16, 
        "num_target_classes": 3,
        "batch_norm": true,
        "learning_rate": 2e-5,
        "warmup_percent": 0.1,
        "sent_embedding_dim": 768
    },  
    "data" : {
        "base_dir": "C:/Users/fsc/Documents/Privat/sbert/",
        "training_data_path": "C:/Users/fsc/Documents/Privat/sbert/data_raw/train_subset.tsv"
    },
    "data_augmentation" : {
        
    },
    "prediction" : {
        "path_model_pt" : "best_model_weights",
        "path_data" : "C:/Users/fsc/Documents/Privat/sbert/data_raw/test_subset.tsv",
        "do_classification": true
    }   
}

Training

Begin training by

python train.py

Prediction

Predict class label of two sentences with

python prediction.py --sent1 "Children smiling and waving at camera" --sent2 "There are children present"

or predict a whole dataset with

python prediction_from_loader.py

You can also retrieve the embeddings by setting "do_classification": false in settings.json

sbert's People

Contributors

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