Description
ELECTRA is a BERT-like model that is pre-trained as a discriminator in a set-up resembling a generative adversarial network (GAN). It was originally published by: Kevin Clark and Minh-Thang Luong and Quoc V. Le and Christopher D. Manning: ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators, ICLR 2020.
How to use
...
embeddings = BertEmbeddings.pretrained("electra_large_uncased", "en") \
.setInputCols("sentence", "token") \
.setOutputCol("embeddings")
nlp_pipeline = Pipeline(stages=[document_assembler, sentence_detector, tokenizer, embeddings])
pipeline_model = nlp_pipeline.fit(spark.createDataFrame([[""]]).toDF("text"))
result = pipeline_model.transform(spark.createDataFrame([['I love NLP']], ["text"]))
...
val embeddings = BertEmbeddings.pretrained("electra_large_uncased", "en")
.setInputCols("sentence", "token")
.setOutputCol("embeddings")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, embeddings))
val data = Seq("I love NLP").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = ["I love NLP"]
embeddings_df = nlu.load('en.embed.electra.large_uncased').predict(text, output_level='token')
embeddings_df
Results
en_embed_electra_large_uncased_embeddings token
[0.1289837807416916, -0.18811583518981934, 0.0... I
[-0.02723774127662182, 0.0757141262292862, 0.3... love
[0.4146347939968109, -0.31447598338127136, -0.... NLP
Model Information
Model Name: | electra_large_uncased |
Type: | embeddings |
Compatibility: | Spark NLP 2.6.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [sentence, token] |
Output Labels: | [word_embeddings] |
Language: | [en] |
Dimension: | 1024 |
Case sensitive: | false |
Data Source
The model is imported from https://tfhub.dev/google/electra_large/2