Description
This model is a Sentiment Analysis fine-tuned model on 12K+ manually annotated (positive, negative, neutral) analyst reports on top of Financial Bert Embeddings. This model achieves superior performance on financial tone analysis task.
Predicted Entities
positive, negative, neutral
How to use
document_assembler = nlp.DocumentAssembler() \
.setInputCol('text') \
.setOutputCol('document')
tokenizer = nlp.Tokenizer() \
.setInputCols(['document']) \
.setOutputCol('token')
sequenceClassifier = finance.BertForSequenceClassification.pretrained("finclf_bert_sentiment", "en", "finance/models")\
.setInputCols(["document",'token'])\
.setOutputCol("class")
pipeline = nlp.Pipeline(stages=[
document_assembler,
tokenizer,
sequenceClassifier
])
# couple of simple examples
example = spark.createDataFrame([["Stocks rallied and the British pound gained."]]).toDF("text")
result = pipeline.fit(example).transform(example)
# result is a DataFrame
result.select("text", "class.result").show()
Results
+--------------------+----------+
| text| result|
+--------------------+----------+
|Stocks rallied an...|[Positive]|
+--------------------+----------+
Model Information
| Model Name: | finclf_bert_sentiment |
| Type: | finance |
| Compatibility: | Finance NLP 1.0.0+ |
| License: | Licensed |
| Edition: | Official |
| Input Labels: | [document, token] |
| Output Labels: | [class] |
| Language: | en |
| Size: | 412.2 MB |
| Case sensitive: | true |
| Max sentence length: | 512 |
References
In-house annotations on financial reports
Benchmarking
label precision recall f1-score support
neutral 0.91 0.87 0.89 588
positive 0.76 0.81 0.78 251
negative 0.83 0.87 0.85 131
accuracy - - 0.86 970
macro-avg 0.83 0.85 0.84 970
weighted-avg 0.86 0.86 0.86 970