36

GitHub - IndicoDataSolutions/finetune: Scikit-learn style model finetuning for N...

 5 years ago
source link: https://github.com/IndicoDataSolutions/finetune
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

68747470733a2f2f692e696d6775722e636f6d2f6b594c303538452e706e67

Scikit-learn style model finetuning for NLP

Finetune ships with a pre-trained language model from "Improving Language Understanding by Generative Pre-Training" and builds off the OpenAI/finetune-language-model repository.

Finetune Quickstart Guide

Finetuning the base language model is as easy as calling Classifier.fit:

model = Classifier()               # Load base model
model.fit(trainX, trainY)          # Finetune base model on custom data
predictions = model.predict(testX) # [{'class_1': 0.23, 'class_2': 0.54, ..}, ..]
model.save(path)                   # Serialize the model to disk

Reload saved models from disk by using LanguageModelClassifier.load:

model = Classifier.load(path)
predictions = model.predict(testX)

Documentation

Full documentation and an API Reference for finetune is available at finetune.indico.io.

Installation

Finetune can be installed directly from PyPI by using pip

pip3 install finetune

or installed directly from source:

git clone https://github.com/IndicoDataSolutions/finetune
cd finetune
python3 setup.py develop
python3 -m spacy download en

In order to run finetune on your host, you'll need a working copy of CUDA >= 8.0, libcudnn >= 6, tensorflow-gpu >= 1.6 and up to date nvidia-driver versions.

You can optionally run the provided test suite to ensure installation completed successfully.

pip3 install pytest
pytest

Docker

If you'd prefer you can also run finetune in a docker container. The bash scripts provided assume you have a functional install of docker and nvidia-docker.

./docker/build_docker.sh      # builds a docker image
./docker/start_docker.sh      # starts a docker container in the background
docker exec -it finetune bash # starts a bash session in the docker container

Code Examples

For example usage of Classifier, Entailment, and SequenceLabeler, see the finetune/datasets directory. For purposes of simplicity and runtime these examples use smaller versions of the published datasets.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK