Giter VIP home page Giter VIP logo

bert-eval's Introduction

Code for evaluating BERT

This repository contains the code used for the experiments presented in the paper "Is Multilingual BERT Fluent in Language Generation?", and cosists of three tasks of increasing complexity and designed to test the capabilities of BERT with a focus on text generation. The tasks are:

If you find this useful, please cite our paper as:

@inproceedings{ronnqvist-2019-bert-eval,
    title = "Is Multilingual BERT Fluent in Language Generation?",
    author = "R\"onnqvist, Samuel and Kanerva, Jenna and Salakoski, Tapio and Ginter, Filip",
    booktitle = "Proceedings of the First NLPL Workshop on Deep Learning for Natural Language Processing",
    month = oct,
    year = "2019",
    address = "Turku, Finland",
    publisher = "Association for Computational Linguistics"
}

Requirements

pip3 install transformers

Generation (toy example)

Generate text from a given seed.

Usage: python3 generate.py --model /path/to/mybert-model --vocab /path/to/mybert-model/mybert-model.vocab.wp

Where mybert-model is a directory containing pytorch_model.bin and config.json. Use --mask_len to define how many subwords to generate (default is 30).

Cloze test

We mask a random 15% of words in each sentence and try to predict them back. In case a word is composed of several subwords, all subwords are masked. Accuracy is measured on subword level, i.e.\ how many times the model gives the highest confidence score for the original subword.

Usage: python3 cloze.py --model /path/to/mybert-model --vocab /path/to/mybert-model/mybert-model.vocab.wp --test_sentences sentences.txt --max_sent 1000

Run python3 cloze.py -h for more options.

Finnish data

Finnish evaluation data can be downloaded with ./get_finnish_data.sh, this greps UD_Finnish-TDT training sentences, and saves them under a file name finnish_sentences.txt.

bert-eval's People

Contributors

jmnybl avatar sronnqvist avatar vblagoje 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.