Giter Site home page Giter Site logo

lingkai-kong / calibrated-bert-fine-tuning Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 3.0 20.43 MB

Code for Paper: Calibrated Language Model Fine-Tuning for In- and Out-of-Distribution Data

License: Apache License 2.0

Python 100.00%
calibration language-model uncertainty-quantification uncertainty-estimation bert open-world-classification robustness text-classification ood-detection deep-learning

calibrated-bert-fine-tuning's Introduction

Calibrated-BERT-Fine-Tuning

This repo contains our code for paper:

Calibrated Language Model Fine-Tuning for In- and Out-of-Distribution Data, EMNLP2020.

[paper] [slides]

Training

Training with BERT base:

CUDA_VISIBLE_DEVICES=0 python bert.py --dataset 20news-15 --seed 0

Training with manifold smoothing

CUDA_VISIBLE_DEVICES=0,1 python manifold-smoothing.py --dataset 20news-15 --seed 0 --eps_in 0.0001 --eps_out 0.001 --eps_y 0.1

Evaluation

Evaluation with BERT base

python test.py --model base --in_dataset 20news-15 --out_dataset 20news-5 --index 0

Evaluation with temperature scaling [1] (based on the trained BERT-base model)

python test.py --model temperature --in_dataset 20news-15 --out_dataset 20news-5 --index 0

Evaluation with MC-dropout [2] (based on the trained BERT-base model)

python test.py --model mc-dropout --in_dataset 20news-15 --out_dataset 20news-5 --eva_iter 10 --index 0

Evaluation with manifold smoothing

python test.py --model manifold-smoothing --in_dataset 20news-15 --out_dataset 20news-5 --eps_in 0.0001 --eps_out 0.001 --eps_y 0.1

References

[1] Guo, Chuan, Geoff Pleiss, Yu Sun, and Kilian Q. Weinberger. "On Calibration of Modern Neural Networks." In international conference on machine learning, pp. 1321-1330. 2017.

[2] Gal, Yarin, and Zoubin Ghahramani. "Dropout as a bayesian approximation: Representing model uncertainty in deep learning." In international conference on machine learning, pp. 1050-1059. 2016.

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.