GithubHelp home page GithubHelp logo

himanshututeja1998 / textual-entailment-using-bert Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 3.0 8.05 MB

Textual Entailment Using Pytorch BERT pretrained model

License: MIT License

Python 68.05% Jupyter Notebook 31.95%
natural-language-processing bert pytorch textual-entailment

textual-entailment-using-bert's Introduction

Textual-Entailment-Using-BERT

Software requirements: This repo is created on Python 3.5+ and PyTorch 1.0.0.

Basic Library Istallation

PyTorch pretrained bert can be installed by pip as follows: pip install pytorch-pretrained-bert (https://github.com/huggingface/pytorch-pretrained-BERT)

This repository is advanced repositry of the original repository (https://github.com/huggingface/pytorch-pretrained-BERT) that basically provide to do entailment task with great ease.

Other than MNLI you can use it on other datasets. It not just gives the evaluation result it also saves the prediction. Some changes are done in run_classifier.py . All things are just same as mentioned in the above repository.

Given N sentences in any format just comvert that into the following format using file_creation.py Column 0: dummy label "entailment". Column 1: sentence 1 Column 2: sentence 2 Column 3: dummy label "entailment". Column 4: sentence1_no. Column 5: sentence2_no.

#Then copy that file to /examples/multinli_1.0 with the name "dev_mismatched.tsv" and an another copy to /examples/ with name "dev_matched.tsv" .

Then use "python3 run_classifier.py --task_name mnli --do_eval --do_lower_case --data_dir multinli_1.0/ --bert_model uncased_L-12_H-768_A-12/ --max_seq_length 128 --train_batch_size 32 --learning_rate 2e-5 --num_train_epochs 3.0 --output_dir MODEL_OUTPUT" to get the file in MODEL_OUTPUT-MM as entail.csv.

This file basically has 5 columns: Column 0: sentence1_id. Column 1: sentence2_id. Column 2: contradiction. Column 3: entailment. Column 4: neutral.

Column 2-5 indicate the values of (contradiction,entailment,neutral). We just have to take maximum value out of these three and that will be the output.

To design an sentence to sentence entailment matrix you should use /examples/MODEL_OUTPUT-MM/matrix.py file. That the output is shown in the same folder with "matrix.csv"

textual-entailment-using-bert's People

Contributors

himanshututeja1998 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

textual-entailment-using-bert's Issues

Error when try to run --do-train

AttributeError: 'bool' object has no attribute 'mean'

Error is caused by function simple_accuracy, can I skip this step?

File "C:/Users/Sajemiur/Textual-Entailment-Using-BERT/Textual Entailment/examples/run_classifier.py", line 946, in main
    result = compute_metrics(task_name, preds, all_label_ids.numpy())
  File "C:/Users/Sajemiur/Textual-Entailment-Using-BERT/Textual Entailment/examples/run_classifier.py", line 551, in compute_metrics
    return {"acc": simple_accuracy(preds, labels)}
  File "C:/Users/Sajemiur/Textual-Entailment-Using-BERT/Textual Entailment/examples/run_classifier.py", line 515, in simple_accuracy
    return (preds == labels).mean()
AttributeError: 'bool' object has no attribute 'mean'

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.