模型:
该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的一半的层次。
要使用该模型,您需要安装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}]