finbert tone

提供商yiyanghkust
分类text-classification
许可证Apache-2.0
下载量667.8K
星标0

简介

FinBERT-Tone 是一款专门针对金融领域文本情感分析的轻量级分类模型。不同于通用模型,它能精准识别金融语境下的“看涨”或“看跌”情绪,有效解决金融术语在通用语境中含义偏移的问题。该模型上手门槛极低,非常适合开发者集成到量化分析流水线、财报自动化分析或股市舆情监控系统中。如果你需要从海量金融新闻或公告中快速提取情绪指标,它是比通用 LLM 更高效、更专注的垂直方案。

核心亮点

  • 深耕金融领域,精准捕捉市场情绪波动
  • 极低推理延迟,适合处理大规模实时行情文本
  • 适配量化交易,将非结构化文本转化为量化信号
  • Apache-2.0 协议,企业级应用部署无压力

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("yiyanghkust/finbert-tone")
tokenizer = AutoTokenizer.from_pretrained("yiyanghkust/finbert-tone")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download yiyanghkust/finbert-tone

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download yiyanghkust/finbert-tone config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('yiyanghkust/finbert-tone')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/yiyanghkust/finbert-tone

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/yiyanghkust/finbert-tone

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('yiyanghkust/finbert-tone')
tokenizer = AutoTokenizer.from_pretrained('yiyanghkust/finbert-tone')

完整文档

来源: HuggingFace

---
language: "en"
tags:

  • financial-sentiment-analysis

  • sentiment-analysis

widget:
  • text: "growth is strong and we have plenty of liquidity"

---

FinBERT is a BERT model pre-trained on financial communication text. The purpose is to enhance financial NLP research and practice. It is trained on the following three financial communication corpus. The total corpora size is 4.9B tokens.

  • Corporate Reports 10-K & 10-Q: 2.5B tokens

  • Earnings Call Transcripts: 1.3B tokens

  • Analyst Reports: 1.1B tokens

More technical details on FinBERT: Click Link

This released finbert-tone model is the FinBERT model fine-tuned on 10,000 manually annotated (positive, negative, neutral) sentences from analyst reports. This model achieves superior performance on financial tone analysis task. If you are simply interested in using FinBERT for financial tone analysis, give it a try.

If you use the model in your academic work, please cite the following paper:

Huang, Allen H., Hui Wang, and Yi Yang. "FinBERT: A Large Language Model for Extracting Information from Financial Text." *Contemporary Accounting Research* (2022).

How to use

You can use this model with Transformers pipeline for sentiment analysis.
python
from transformers import BertTokenizer, BertForSequenceClassification
from transformers import pipeline

finbert = BertForSequenceClassification.from_pretrained('yiyanghkust/finbert-tone',num_labels=3)
tokenizer = BertTokenizer.from_pretrained('yiyanghkust/finbert-tone')

nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)

sentences = ["there is a shortage of capital, and we need extra financing",
"growth is strong and we have plenty of liquidity",
"there are doubts about our finances",
"profits are flat"]
results = nlp(sentences)
print(results) #LABEL_0: neutral; LABEL_1: positive; LABEL_2: negative