File size: 3,672 Bytes
31f667c
 
048ed96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31f667c
 
e0ff921
7e0106b
f94a3b0
fd20764
21faeae
c95b3cd
 
 
21faeae
24cdc59
 
f94a3b0
 
 
21faeae
 
 
f94a3b0
 
 
 
 
 
 
 
 
 
 
 
 
7e0106b
 
f94a3b0
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
widget:
- text: >-
    NEW YORK (TheStreet) -- Microsoft (MSFT) - Get Free Report had its price
    target raised to $39 from $38 by analysts at Jefferies who maintained their
    'underperform' rating. In Thursday's pre-market trading session shares are
    advancing 1.24% to $44.79. This action comes as Microsoft said yesterday
    that it will eliminate up to 7,800 jobs mostly in its phone unit as it looks
    to restructure its phone hardware business that has been struggling, the New
    York Times reports.
  example_title: MSFT news (positive)
- text: >-
    Adobe Brings Major New Innovations to Video Tools SAN JOSE,
    Calif.--(BUSINESS WIRE)--Today, ahead of the 2023 NAB Show – the preeminent
    conference and exhibition driving the evolution of broadcast, media and
    entertainment – Adobe (Nasdaq:ADBE) announced industry-first innovations
    across its family of video applications, including AI-powered text-based
    video editing and automated color tone-mapping capabilities in Premiere Pro.
    SAN JOSE, Calif.--(BUSINESS WIRE).
  example_title: ADBE news (neutral)
- text: >-
    Unilever PLC (NYSE: UL)’s stock price has gone decline by -0.61 in
    comparison to its previous close of 54.27, however, the company has
    experienced a -1.61% decrease in its stock price over the last five trading
    days. The Wall Street Journal reported on 10/24/22 that Dry Shampoo Recalled
    Due to Potential Cancer-Causing Ingredient.
  example_title: UL news (negative)
license: mit
---


# Finetuned distilBERT model for stock news classification

This distilbert model was fine-tuned on 50.000 stock news articles using the HuggingFace adapter from Kern AI refinery. The articles consisted of the headlines plus abstract of the article.
For the finetuning, a single NVidia K80 was used for about four hours. 

Join our Discord if you have questions about this model: https://discord.gg/MdZyqSxKbe

DistilBERT is a smaller, faster and lighter version of BERT. It was trained by distilling BERT base and has 40% less parameters than bert-base-uncased. 
It runs 60% faster while preserving over 95% of BERT’s performances as measured on the GLUE language understanding benchmark. 
DistilBERT does not have token-type embeddings, pooler and retains only half of the layers from Google’s BERT.
## Features

- The model can handle various text classification tasks, especially when it comes to stock and finance news sentiment classification.
- The output of the model are the three classes "positive", "neutral" and "negative" plus the models respective confidence score of the class. 
- The model was fine-tuned on a custom datasets that was curated by Kern AI and labeled in our tool refinery.
- The model is currently supported by the PyTorch framework and can be easily deployed on various platforms using the HuggingFace Pipeline API.

## Usage

To use the model, you need to install the HuggingFace Transformers library:

```bash
pip install transformers
```
Then you can load the model and the tokenizer from the HuggingFace Hub:

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer

model = AutoModelForSequenceClassification.from_pretrained("KernAI/stock-news-distilbert")
tokenizer = AutoTokenizer.from_pretrained("KernAI/stock-news-distilbert")
```
To classify a single sentence or a sentence pair, you can use the HuggingFace Pipeline API:

```python
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}]
```