Text Models


There are a number of built-in compiled text models in Analytics Zoo TFPark for Natural Language Processing (NLP) tasks based on KerasModel.

After constructing a text model, you can directly call fit, evaluate or predict in a distributed fashion. See here for more instructions.

Remarks:


Intent Extraction

This is a multi-task model used for joint intent extraction and slot filling.

This model has two inputs:

This model has two outputs:

from zoo.tfpark.text.keras import IntentEntity

model = IntentEntity(num_intents, num_entities, word_vocab_size, char_vocab_size, word_length=12, word_emb_dim=100, char_emb_dim=30, char_lstm_dim=30, tagger_lstm_dim=100, dropout=0.2, optimizer=None)

Model Save and Load

Save the IntentEntity model to a single HDF5 file.

model.save_model(path)

Load an existing IntentEntity model (with weights) from HDF5 file.

from zoo.tfpark.text.keras import IntentEntity

model = IntentEntity.load_model(path)

Named Entity Recognition

This model is used for named entity recognition using Bidirectional LSTM with Conditional Random Field (CRF) sequence classifier.

This model has two inputs:

This model outputs entity tags of shape (batch, sequence_length, num_entities).

from zoo.tfpark.text.keras import NER

model = NER(num_entities, word_vocab_size, char_vocab_size, word_length=12, word_emb_dim=100, char_emb_dim=30, tagger_lstm_dim=100, dropout=0.5, crf_mode='reg', optimizer=None)

Model Save and Load

Save the NER model to a single HDF5 file.

model.save_model(path)

Load an existing NER model (with weights) from HDF5 file.

from zoo.tfpark.text.keras import NER

model = NER.load_model(path)

POS Tagging

This model is used as Part-Of-Speech(POS)-tagger and chunker for sentence tagging, which contains three Bidirectional LSTM layers.

This model can have one or two input(s):

This model has two outputs:

from zoo.tfpark.text.keras import SequenceTagger

model = NER(num_pos_labels, num_chunk_labels, word_vocab_size, char_vocab_size=None, word_length=12, feature_size=100, dropout=0.2, classifier='softmax', optimizer=None)

Model Save and Load

Save the SequenceTagger model to a single HDF5 file.

model.save_model(path)

Load an existing SequenceTagger model (with weights) from HDF5 file.

from zoo.tfpark.text.keras import SequenceTagger

model = SequenceTagger.load_model(path)