🚀 股票相關評論情感推理模型
本項目由新加坡國立大學信息系統學院的學生 Frank Cao、Gerong Zhang、Jiaqi Yao、Sikai Ni、Yunduo Zhang 共同完成,旨在構建一個用於分析股票相關評論情感的模型。該模型基於 RoBERTa-base 進行微調,能夠有效判斷評論中的情感傾向,為投資者提供有價值的參考。
🚀 快速開始
此模型是基於 RoBERTa-base 模型,在來自 Stocktwits 的 3200000 條評論上進行微調得到的。這些評論帶有用戶標註的 “Bullish”(看漲)或 “Bearish”(看跌)標籤。你可以在推理 API 上嘗試輸入個人投資者在投資論壇上可能會說的內容,例如 “red”(跌)和 “green”(漲)。
查看 GitHub 代碼
✨ 主要特性
- 精準情感分析:通過大量股票評論數據訓練,能準確判斷評論的看漲或看跌情感。
- 易於使用:提供簡單的代碼示例,方便開發者集成到自己的項目中。
📦 安裝指南
文檔未提及安裝步驟,暫不提供。
💻 使用示例
基礎用法
from transformers import RobertaForSequenceClassification, RobertaTokenizer
from transformers import pipeline
import pandas as pd
import emoji
def process_text(texts):
texts = re.sub(r'https?://\S+', "", texts)
texts = re.sub(r'www.\S+', "", texts)
texts = texts.replace(''', "'")
texts = re.sub(r'(\#)(\S+)', r'hashtag_\2', texts)
texts = re.sub(r'(\$)([A-Za-z]+)', r'cashtag_\2', texts)
texts = re.sub(r'(\@)(\S+)', r'mention_\2', texts)
texts = emoji.demojize(texts, delimiters=("", " "))
return texts.strip()
tokenizer_loaded = RobertaTokenizer.from_pretrained('zhayunduo/roberta-base-stocktwits-finetuned')
model_loaded = RobertaForSequenceClassification.from_pretrained('zhayunduo/roberta-base-stocktwits-finetuned')
nlp = pipeline("text-classification", model=model_loaded, tokenizer=tokenizer_loaded)
sentences = pd.Series(['just buy','just sell it',
'entity rocket to the sky!',
'go down','even though it is going up, I still think it will not keep this trend in the near future'])
sentences = list(sentences)
results = nlp(sentences)
print(results)
🔧 技術細節
訓練信息
輪次 |
訓練損失 |
驗證損失 |
驗證準確率 |
epoch1 |
0.3495 |
0.2956 |
0.8679 |
epoch2 |
0.2717 |
0.2235 |
0.9021 |
epoch3 |
0.2360 |
0.1875 |
0.9210 |
epoch4 |
0.2106 |
0.1603 |
0.9343 |
📄 許可證
本項目採用 Apache-2.0 許可證。
📚 詳細文檔
屬性 |
詳情 |
模型類型 |
文本分類 |
訓練數據 |
來自 Stocktwits 的 3200000 條評論,帶有 “Bullish” 或 “Bearish” 標籤 |
評估指標 |
準確率 |
庫名稱 |
transformers |
標籤 |
金融 |