Skip to content

Latest commit

 

History

History
 
 

modeling

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

NLP Modeling Library

This library provides a set of Keras primitives (Layers, Networks, and Models) that can be assembled into transformer-based models. They are flexible, validated, interoperable, and both TF1 and TF2 compatible.

  • layers are the fundamental building blocks for NLP models. They can be used to assemble new layers, networks, or models.

  • networks are combinations of layers (and possibly other networks). They are sub-units of models that would not be trained alone. They encapsulate common network structures like a classification head or a transformer encoder into an easily handled object with a standardized configuration.

  • models are combinations of layers and networks that would be trained. Pre-built canned models are provided as both convenience functions and canonical examples.

  • losses contains common loss computation used in NLP tasks.

Please see the colab [nlp_modeling_library_intro.ipynb] (https://colab.sandbox.google.com/github/tensorflow/models/blob/master/official/colab/nlp/nlp_modeling_library_intro.ipynb) for how to build transformer-based NLP models using above primitives.

Besides the pre-defined primitives, it also provides scaffold classes to allow easy experimentation with noval achitectures, e.g., you don’t need to fork a whole Transformer object to try a different kind of attention primitive, for instance.

Please see the colab [customize_encoder.ipynb] (https://colab.sandbox.google.com/github/tensorflow/models/blob/master/official/colab/nlp/customize_encoder.ipynb) for how to use scaffold classes to build noval achitectures.

BERT and ALBERT models in this repo are implemented using this library. Code examples can be found in the corresponding model folder.