Description
This model is imported from Hugging Face-models
. It is a BERT-Tiny version of the sms_spam
dataset. It identifies if the SMS is spam or not.
LABEL_0
: No SpamLABEL_1
: Spam
Predicted Entities
LABEL_0
, LABEL_1
How to use
document_assembler = DocumentAssembler() \
.setInputCol('text') \
.setOutputCol('document')
tokenizer = Tokenizer() \
.setInputCols(['document']) \
.setOutputCol('token')
sequenceClassifier = BertForSequenceClassification \
.pretrained('bert_sequence_classifier_sms_spam', 'en') \
.setInputCols(['token', 'document']) \
.setOutputCol('class') \
.setCaseSensitive(True) \
.setMaxSentenceLength(512)
pipeline = Pipeline(stages=[document_assembler, tokenizer, sequenceClassifier])
example = spark.createDataFrame([['Camera - You are awarded a SiPix Digital Camera! call 09061221066 from landline. Delivery within 28 days.']]).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 = BertForSequenceClassification.pretrained("bert_sequence_classifier_sms_spam", "en")
.setInputCols("document", "token")
.setOutputCol("class")
.setCaseSensitive(true)
.setMaxSentenceLength(512)
val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))
val example = Seq.empty["Camera - You are awarded a SiPix Digital Camera! call 09061221066 from landline. Delivery within 28 days."].toDS.toDF("text")
val result = pipeline.fit(example).transform(example)
import nlu
nlu.load("en.classify.bert.sms_spam.").predict("""Camera - You are awarded a SiPix Digital Camera! call 09061221066 from landline. Delivery within 28 days.""")
Results
['LABEL_1']
Model Information
Model Name: | bert_sequence_classifier_sms_spam |
Compatibility: | Spark NLP 3.3.2+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [token, sentence] |
Output Labels: | [label] |
Language: | en |
Case sensitive: | true |
Data Source
https://huggingface.co/mrm8488/bert-tiny-finetuned-sms-spam-detection
Benchmarking
label score
accuracy 0.98