Git Product home page Git Product logo

bilm-tf's Introduction

Use ELMo as a Language Model

Purpose

Run pretrained ELMo model to get single sentence perplexity.

Modified from Allenai bilm-tf

Installation

pip install tensorflow-gpu==1.2 h5py
python setup.py install

Run Evaluation

  1. Data file format: each line in a file is a sentence to calculate perplexity. data

  2. Split data file into pieces, one sentence per piece.

cd data
split sents.txt -d -l 1 -a 4 cs
  1. Run the evaluation script.
sh evaluate.sh
  1. The perplexity score is shown in stdout
...
5946: 129.57085
5947: 1412.2032
5948: 5172.711
5949: 2126.5542
...

Sentence line number followed by the perplxity (unnormalized by sentence length)

Finetune

To finetune the ELMo on additional corpus, first downlaod the pretrained model to models/

The tensorflow checkpoint is available by downloading these files:

vocabulary checkpoint options 1 2 3

|
|--models
    |--vocab-2016-09-10.txt
    |--checkpoint
            |--checkpoint
            |--options.json
            |--model.ckpt-935588.meta
            |--model.ckpt-935588.index
            |--model.ckpt-935588.data-00000-of-00001

Then use the following script.

sh finetune.sh

After finetuning the model, you can run the evaluation again to see the finetune effect.

bilm-tf's People

Contributors

deneutoy avatar matt-peters avatar philipmay avatar shuailong avatar stephanheijl avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

rulegreen

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.