Description
“
ALBERT Model with sequence classification/regression head on top (a linear layer on top of the pooled output) e.g. for multi-class document classification tasks.
albert_base_sequence_classifier_imdb is a fine-tuned ALBERT model that is ready to be used for Sequence Classification tasks such as sentiment analysis or multi-class text classification and it achieves state-of-the-art performance.
We used TFAlbertForSequenceClassification to train this model and used AlbertForSequenceClassification annotator in Spark NLP 🚀 for prediction at scale!
How to use
document_assembler = DocumentAssembler() .setInputCol('text') .setOutputCol('document')
tokenizer = Tokenizer() .setInputCols(['document']) .setOutputCol('token')
sequenceClassifier = AlbertForSequenceClassification .pretrained('albert_base_toxicity', 'en') .setInputCols(['token', 'document']) .setOutputCol('class') .setCaseSensitive(False) .setMaxSentenceLength(512)
pipeline = Pipeline(stages=[
document_assembler,
tokenizer,
sequenceClassifier
])
example = spark.createDataFrame([['I really liked that movie!']]).toDF("text")
result = pipeline.fit(example).transform(example)
val document_assembler = DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val tokenizer = Tokenizer()
.setInputCols("document")
.setOutputCol("token")
val tokenClassifier = AlbertForSequenceClassification.pretrained("albert_base_toxicity", "en")
.setInputCols("document", "token")
.setOutputCol("class")
.setCaseSensitive(false)
.setMaxSentenceLength(512)
val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))
val example = Seq("I really liked that movie!").toDS.toDF("text")
val result = pipeline.fit(example).transform(example)
Model Information
Model Name: | albert_base_toxicity |
Compatibility: | Spark NLP 5.4.2+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [token, document] |
Output Labels: | [label] |
Language: | en |
Size: | 44.2 MB |
Case sensitive: | true |