Giter Site home page Giter Site logo

aistrighnlp's Introduction

AistrighNLP



MIT License Release

AistrighNLP is a collection of tools and models used for Aistrigh, the BT Young Scientist 2021 project. Our aim is to bring Irish into the modern era with NLP tools to give it parity with English. The tools included are based around the work in Neural Models for Predicting Celtic Mutations (Scannell, 2020) and our own preliminary paper. Included is all the tools needed to create a demutated Irish/Scots corpus and/or create a dataset to train a custom neural network, which can be used in all sorts of NLP tasks, and models to reinsert them. For the Python API docs visit AistrighNLP Python API

Installing the Package

AistrighNLP can be downloaded using pip

pip install aistrigh-nlp

Lowercasing

When lowercasing either Irish or Scots Gaelic for prediciting mutations, you must be aware of special cases outlined in the paper above. Our lowercaser handles that

aistrigh-nlp lowercase -i input.txt -o output.txt

Removing mutations

To remove mutations from an entire dataset for use for NLP tasks (like Machine Translation) use demutate-corpus. -l/--lang must take ISO 639 language codes like 'ga'.

aistrigh-nlp demutate-corpus -i input.txt -o output.txt -l ga

To remove mutations with a 'window' on either side to train a neural network, use demutate-window, with -w set to your desired window length on each side

aistrigh-nlp demutate-window -i input.txt -o output.csv -l ga -w 16

Predicting the mutations

To predict mutations on each word, use predict-mutations. As of right now, it's only compatible with PyTorch+Torchtext models but we are working on expanding to TensorFlow and Keras. You'll need your vocab, labels and model checkpoint in the same folder (-d/--data). We provide default models to be used here.

aistrigh-nlp predict-mutations -i input.txt -o output.txt -w 16 -d nn_100k

Applying the predicted mutations

To apply the mutations predicted by predict-mutations, use apply-mutations.

aistrigh-nlp apply-mutations -i input.txt -o output.txt -l ga

Scoring Celtic NMT models using Standard and Demutated BLEU

To score NMT models using both these metrics run;

aistrigh-nlp bleu -r reference.txt -p predictions.txt -l ga

If you're scoring a demutated NMT model and haven't reapplied mutations, pass your demutated reference (-d) and predictions, and the original reference (-r).

aistrigh-nlp bleu -d demutated_reference.txt -r reference.txt -p predictions.txt -l ga

NOTE

AistrighNLP uses PyTorch Traces to save the full computational graphs as checkpoints. This way, the model architecture need not be declared into hard-coded scripts. See this StackOverflow Thread for instructions to save a traced checkpoint.

aistrighnlp's People

Contributors

justcunn avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

flalor

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.