资源算法allennlp-multi-label-document-classification

allennlp-multi-label-document-classification

2020-04-08 | |  37 |   0 |   0

AllenNLP Multi-label Document Classification Plugin

A simple multi-label document classification plugin for AllenNLP.

Installation

This repository requires Python 3.7 or later.

Setting up a virtual environment

Before installing, you should create and activate a Python virtual environment. See here for detailed instructions.

Installing the library and dependencies

First, clone the repository locally

git clone https://github.com/JohnGiorgi/allennlp-multi-label-document-classification.git

Then, install

cd allennlp-multi-label-document-classification
pip install --editable .

For the time being, please install AllenNLP from source. You should also install PyTorch with CUDA support by following the instructions for your system here.

Enabling mixed-precision training

If you want to train with mixed-precision (strongly recommended if your GPU supports it), you will need to install Apex with CUDA and C++ extensions. Once installed, you need only to set "opt_level" to "O1" in your training config.

Usage

Preparing a dataset

Datasets should be JSON lines files, where each line is valid JSON containing the fields "text" and "labels". You can specify different partitions in the configs under "train_data_path""validation_data_path" and "test_data_path".

Training

To train the model, run the following command

allennlp train configs/multi_label_classifier.jsonnet 
    -s output 
    -o '{"train_data_path": "path/to/input.txt"}' 
    --include-package src

During training, models, vocabulary, configuration and log files will be saved to output. This can be changed to any path you like.

Inference

Coming soon.


上一篇:Names-Classification-Using-AllenNLP

下一篇: flair-cache

用户评价
全部评价

热门资源

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • shih-styletransfer

    shih-styletransfer Code from Style Transfer ...