com.johnsnowlabs.nlp.embeddings
internal types to show Rows as a relevant StructType Should be deleted once Spark releases UserDefinedTypes to @developerAPI
internal types to show Rows as a relevant StructType Should be deleted once Spark releases UserDefinedTypes to @developerAPI
takes a document and annotations and produces new annotations of this annotator's annotation type
takes a document and annotations and produces new annotations of this annotator's annotation type
Annotations in batches that correspond to inputAnnotationCols generated by previous annotators if any
any number of annotations processed for every input annotation. Not necessary one to one relationship
Size of every batch (Default depends on model).
Size of every batch (Default depends on model).
Whether to ignore case in index lookups (Default depends on model)
Whether to ignore case in index lookups (Default depends on model)
ConfigProto from tensorflow, serialized into byte array.
ConfigProto from tensorflow, serialized into byte array. Get with config_proto.SerializeToString()
requirement for annotators copies
requirement for annotators copies
Number of embedding dimensions (Default depends on model)
Number of embedding dimensions (Default depends on model)
Override for additional custom schema checks
Override for additional custom schema checks
Size of every batch.
Size of every batch.
input annotations columns currently used
Gets annotation column name going to generate
Gets annotation column name going to generate
Input Annotator Types: DOCUMENT, TOKEN
Input Annotator Types: DOCUMENT, TOKEN
columns that contain annotations necessary to run this annotator AnnotatorType is used both as input and output columns if not specified
columns that contain annotations necessary to run this annotator AnnotatorType is used both as input and output columns if not specified
Max sentence length to process (Default: 128
)
Output Annotator Types: WORD_EMBEDDINGS
Output Annotator Types: WORD_EMBEDDINGS
Size of every batch.
Size of every batch.
Overrides required annotators column if different than default
Overrides required annotators column if different than default
Overrides annotation column name when transforming
Overrides annotation column name when transforming
It contains TF model signatures for the laded saved model
Unique identifier for storage (Default: this.uid
)
Unique identifier for storage (Default: this.uid
)
Given requirements are met, this applies ML transformation within a Pipeline or stand-alone Output annotation will be generated as a new column, previous annotations are still available separately metadata is built at schema level to record annotations structural information outside its content
Given requirements are met, this applies ML transformation within a Pipeline or stand-alone Output annotation will be generated as a new column, previous annotations are still available separately metadata is built at schema level to record annotations structural information outside its content
Dataset[Row]
requirement for pipeline transformation validation.
requirement for pipeline transformation validation. It is called on fit()
required uid for storing annotator to disk
required uid for storing annotator to disk
takes a Dataset and checks to see if all the required annotation types are present.
takes a Dataset and checks to see if all the required annotation types are present.
to be validated
True if all the required types are present, else false
A list of (hyper-)parameter keys this annotator can take. Users can set and get the parameter values through setters and getters, respectively.
Required input and expected output annotator types
ALBERT: A LITE BERT FOR SELF-SUPERVISED LEARNING OF LANGUAGE REPRESENTATIONS - Google Research, Toyota Technological Institute at Chicago
These word embeddings represent the outputs generated by the Albert model. All official Albert releases by google in TF-HUB are supported with this Albert Wrapper:
Ported TF-Hub Models:
"albert_base_uncased"
| albert_base | 768-embed-dim, 12-layer, 12-heads, 12M parameters"albert_large_uncased"
| albert_large | 1024-embed-dim, 24-layer, 16-heads, 18M parameters"albert_xlarge_uncased"
| albert_xlarge | 2048-embed-dim, 24-layer, 32-heads, 60M parameters"albert_xxlarge_uncased"
| albert_xxlarge | 4096-embed-dim, 12-layer, 64-heads, 235M parametersThis model requires input tokenization with SentencePiece model, which is provided by Spark-NLP (See tokenizers package).
Pretrained models can be loaded with
pretrained
of the companion object:The default model is
"albert_base_uncased"
, if no name is provided.For extended examples of usage, see the Spark NLP Workshop and the AlbertEmbeddingsTestSpec.
Sources:
ALBERT: A LITE BERT FOR SELF-SUPERVISED LEARNING OF LANGUAGE REPRESENTATIONS
https://github.com/google-research/ALBERT
https://tfhub.dev/s?q=albert
Paper abstract:
Increasing model size when pretraining natural language representations often results in improved performance on downstream tasks. However, at some point further model increases become harder due to GPU/TPU memory limitations and longer training times. To address these problems, we present two parameter reduction techniques to lower memory consumption and increase the training speed of BERT (Devlin et al., 2019). Comprehensive empirical evidence shows that our proposed methods lead to models that scale much better compared to the original BERT. We also use a self-supervised loss that focuses on modeling inter-sentence coherence, and show it consistently helps downstream tasks with multi-sentence inputs. As a result, our best model establishes new state-of-the-art results on the GLUE, RACE, and SQuAD benchmarks while having fewer parameters compared to BERT-large.
Tips: ALBERT uses repeating layers which results in a small memory footprint, however the computational cost remains similar to a BERT-like architecture with the same number of hidden layers as it has to iterate through the same number of (repeating) layers.
Example
Annotators Main Page for a list of transformer based embeddings