Description
RuBERT for Sentiment Analysis
Short Russian texts sentiment classification
This is a DeepPavlov/rubert-base-cased-conversational model trained on aggregated corpus of 351.797 texts.
Predicted Entities
NEUTRAL
, POSITIVE
, NEGATIVE
How to use
document_assembler = DocumentAssembler() \
.setInputCol('text') \
.setOutputCol('document')
tokenizer = Tokenizer() \
.setInputCols(['document']) \
.setOutputCol('token')
sequenceClassifier = BertForSequenceClassification \
.pretrained('bert_sequence_classifier_rubert_sentiment', 'ru') \
.setInputCols(['token', 'document']) \
.setOutputCol('class') \
.setCaseSensitive(False) \
.setMaxSentenceLength(512)
pipeline = Pipeline(stages=[
document_assembler,
tokenizer,
sequenceClassifier
])
example = spark.createDataFrame([['Ты мне нравишься. Я тебя люблю']]).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_rubert_sentiment", "ru")
.setInputCols("document", "token")
.setOutputCol("class")
.setCaseSensitive(false)
.setMaxSentenceLength(512)
val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))
val example = Seq("Ты мне нравишься. Я тебя люблю").toDS.toDF("text")
val result = pipeline.fit(example).transform(example)
Model Information
Model Name: | bert_sequence_classifier_rubert_sentiment |
Compatibility: | Spark NLP 3.3.2+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [token, document] |
Output Labels: | [class] |
Language: | ru |
Case sensitive: | false |
Max sentense length: | 512 |
Data Source
https://huggingface.co/blanchefort/rubert-base-cased-sentiment