模型:

KernAI/stock-news-destilbert

英文

Stock news分类的distilBERT模型微调

该distilbert模型是使用Kern AI refinery的HuggingFace适配器对50,000条股票新闻文章进行微调的。文章包括标题和摘要。对于微调,使用了一块NVidia K80 GPU,大约花费了四个小时。

如果您对此模型有任何问题,请加入我们的Discord:

DistilBERT是BERT的一个更小、更快、更轻量级的版本。它是通过蒸馏BERT base训练得到的,参数比bert-base-uncased少40%。在保持对GLUE语言理解基准测试上超过95%的BERT性能的同时,它运行速度比BERT快60%。DistilBERT没有token-type embeddings、pooler,并且只保留了Google's BERT的一半的层次。

特点

  • 该模型可以处理各种文本分类任务,特别是股票和金融新闻情感分类。
  • 模型的输出是三个类别:"positive"、"neutral"、"negative",以及对应类别的置信度分数。
  • 该模型是在Kern AI的工具refinery中由我们自定义的数据集进行微调的。
  • 目前,该模型由PyTorch框架支持,并可使用HuggingFace Pipeline API轻松部署在各种平台上。

使用方法

要使用该模型,您需要安装HuggingFace Transformers库:

pip install transformers

然后您可以从HuggingFace Hub加载模型和分词器:

from transformers import AutoModelForSequenceClassification, AutoTokenizer

model = AutoModelForSequenceClassification.from_pretrained("KernAI/stock-news-distilbert")
tokenizer = AutoTokenizer.from_pretrained("KernAI/stock-news-distilbert")

要对单个句子或句子对进行分类,您可以使用HuggingFace Pipeline API:

from transformers import pipeline

classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
result = classifier("This is a positive sentence.")
print(result)
# [{'label': 'POSITIVE', 'score': 0.9998656511306763}]