Description
This model is a fine-tune checkpoint of DistilBERT-base-uncased, fine-tuned on SST-2. This model reaches an accuracy of 91.3 on the dev set (for comparison, BERT’s bert-base-uncased
version reaches an accuracy of 92.7).
Predicted Entities
NEGATIVE
, POSITIVE
How to use
document_assembler = DocumentAssembler() \
.setInputCol('text') \
.setOutputCol('document')
tokenizer = Tokenizer() \
.setInputCols(['document']) \
.setOutputCol('token')
sequenceClassifier = DistilBertForSequenceClassification \
.pretrained('distilbert_sequence_classifier_sst2', 'en') \
.setInputCols(['token', 'document']) \
.setOutputCol('class') \
.setMaxSentenceLength(512)
pipeline = Pipeline(stages=[
document_assembler,
tokenizer,
sequenceClassifier
])
example = spark.createDataFrame([['I like you. I love you.']]).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 = DistilBertForSequenceClassification.pretrained("distilbert_sequence_classifier_sst2", "en")
.setInputCols("document", "token")
.setOutputCol("class")
.setMaxSentenceLength(512)
val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))
val example = Seq("I like you. I love you.").toDS.toDF("text")
val result = pipeline.fit(example).transform(example)
import nlu
nlu.load("en.classify.distilbert_sequence.sst2").predict("""I like you. I love you.""")
Model Information
Model Name: | distilbert_sequence_classifier_sst2 |
Compatibility: | Spark NLP 3.3.3+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [token, document] |
Output Labels: | [class] |
Language: | en |
Case sensitive: | true |
Max sentense length: | 512 |
Data Source
https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english
Benchmarking
This model reaches an accuracy of 91.3 on the dev set