Coder Social home page Coder Social logo

poleval2018's Introduction

Submission to PolEval - task3 language model

Our solution is an extension of the work done by FastAI team to train language models for English. We extended it with google sentence piece to tokenize polish words.

Slides from our presentation on AI & NLP Day in Warsaw

Weights and sentence piece model

Installation

The source code needs cleaning up to minimise the amount of work needed to run it.

But for now here are rough manual steps:

  • Install fastai from our fork (python PATH)
  • Install sentencepiece from source code (PATH and python PATH)

Training

You should have the following structure:

.
├── data
│   └── task3 # here goes unzipped files
│       ├── test
│       └── train
├── fastai_scripts -> github.com/fastai/fastai/courses/dl2/imdb_scripts/
├── task3
└── work  # this will be created by scripts
    ├── up_low
    │   ├── models
    │   └── tmp
    └── up_low50k
        ├── models
        └── tmp 

Then to train a model run

cd task3/
./prepare-data3-up_low.sh
./prepare-data3-up_low50k.sh
cd ..

# to initially train the model
python fastai_scripts/pretrain_lm.py --dir-path ./work/up_low --cuda-id 0 --cl 10 --bs 192 --lr 0.01\
   --pretrain-id "v100k" --sentence-piece-model sp-100k.model --nl 4

# to check the perplexity
python fastai_scripts/infer.py --dir-path ./work/up_low --cuda-id 0 --bs 22 --pretrain-id "v100k"\
   --sentence-piece-model sp-100k.model --test_set tmp/val_ids.npy --correct_for_up=False --nl 4
   
# to fine tune with smaller dropout
python ./fastai_scripts/finetune_lm.py --dir-path work/up_low \
    --pretrain-path work/up_low --cuda-id 0 --cl 6 --pretrain-id "v100k" --lm-id "v100k_finetune"\
    --bs 192 --lr 0.001 --use_discriminative False --dropmult 0.5 --sentence-piece-model sp-100k.model --sampled True --nl 4 

# to check the perplexity on the valuation data set
python fastai_scripts/infer.py --dir-path ./work/up_low --cuda-id 0 --bs 22 --pretrain-id "v100k_finetune_lm"\
   --sentence-piece-model sp-100k.model --test_set tmp/val_ids.npy --correct_for_up=False --nl 4

To check the perplexity on test set run:

# it expects your model in `work/up_low/models` and sentence piece model in `work/up_low/tmp` 
python fastai_scripts/infer.py --dir-path ./work/up_low --cuda-id 0 --bs 22 --pretrain-id "v100k_finetune_lm"\
   --sentence-piece-model sp-100k.model --test_set tmp/test_ids.npy --correct_for_up=False --nl 4      

poleval2018's People

Contributors

piotrczapla avatar nerd911 avatar mkardas avatar

Watchers

James Cloos 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.