🚀 金融情感分析的FinancialBERT
FinancialBERT 是一個在大量金融文本語料庫上預訓練的BERT模型。其目的是推動金融領域的自然語言處理研究與實踐,讓金融從業者和研究人員無需投入大量計算資源來訓練模型,就能從該模型中受益。
該模型在 Financial PhraseBank 數據集上針對情感分析任務進行了微調。實驗表明,該模型的性能優於通用的BERT模型以及其他金融領域特定的模型。
有關 FinancialBERT
預訓練過程的更多詳細信息,請訪問:https://www.researchgate.net/publication/358284785_FinancialBERT_-_A_Pretrained_Language_Model_for_Financial_Text_Mining
✨ 主要特性
- 預訓練優勢:基於大量金融文本語料庫預訓練,能更好地理解金融領域的語義。
- 微調優化:在 Financial PhraseBank 數據集上針對情感分析任務進行微調,性能表現出色。
- 資源友好:讓金融從業者和研究人員無需大量計算資源即可使用。
📦 安裝指南
文檔未提及具體安裝步驟,若使用該模型,可參考 transformers
庫的安裝方法。
💻 使用示例
基礎用法
from transformers import BertTokenizer, BertForSequenceClassification
from transformers import pipeline
model = BertForSequenceClassification.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis",num_labels=3)
tokenizer = BertTokenizer.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis")
nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
sentences = ["Operating profit rose to EUR 13.1 mn from EUR 8.7 mn in the corresponding period in 2007 representing 7.7 % of net sales.",
"Bids or offers include at least 1,000 shares and the value of the shares must correspond to at least EUR 4,000.",
"Raute reported a loss per share of EUR 0.86 for the first half of 2009 , against EPS of EUR 0.74 in the corresponding period of 2008.",
]
results = nlp(sentences)
print(results)
[{'label': 'positive', 'score': 0.9998133778572083},
{'label': 'neutral', 'score': 0.9997822642326355},
{'label': 'negative', 'score': 0.9877365231513977}]
📚 詳細文檔
訓練數據
FinancialBERT模型在 Financial PhraseBank 數據集上進行了微調,該數據集包含4840條按情感(負面、中性、正面)分類的財經新聞。
微調超參數
- 學習率(learning_rate) = 2e-5
- 批次大小(batch_size) = 32
- 最大序列長度(max_seq_length) = 512
- 訓練輪數(num_train_epochs) = 5
評估指標
使用的評估指標為:精確率(Precision)、召回率(Recall)和F1分數(F1-score)。以下是測試集上的分類報告。
情感傾向 |
精確率 |
召回率 |
F1分數 |
樣本數 |
負面 |
0.96 |
0.97 |
0.97 |
58 |
中性 |
0.98 |
0.99 |
0.98 |
279 |
正面 |
0.98 |
0.97 |
0.97 |
148 |
宏平均 |
0.97 |
0.98 |
0.98 |
485 |
加權平均 |
0.98 |
0.98 |
0.98 |
485 |
📄 許可證
文檔未提及許可證信息。
由 Ahmed Rachid Hazourli 創建