shadow91102 commited on
Commit
d26d312
·
verified ·
1 Parent(s): 4b69c5b

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. Negative +0 -0
  2. README.md +106 -0
  3. config.json +36 -0
  4. model.safetensors +3 -0
  5. special_tokens_map.json +37 -0
  6. tokenizer_config.json +57 -0
  7. vocab.txt +0 -0
Negative ADDED
File without changes
README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - sentiment analysis
5
+ - financial sentiment analysis
6
+ - bert
7
+ - text-classification
8
+ - finance
9
+ - finbert
10
+ - financial
11
+ ---
12
+ # Trading Hero Financial Sentiment Analysis
13
+
14
+ Model Description: This model is a fine-tuned version of [FinBERT](https://huggingface.co/yiyanghkust/finbert-pretrain), a BERT model pre-trained on financial texts. The fine-tuning process was conducted to adapt the model to specific financial NLP tasks, enhancing its performance on domain-specific applications for sentiment analysis.
15
+
16
+ ## Model Use
17
+
18
+ Primary Users: Financial analysts, NLP researchers, and developers working on financial data.
19
+
20
+ ## Training Data
21
+
22
+ Training Dataset: The model was fine-tuned on a custom dataset of financial communication texts. The dataset was split into training, validation, and test sets as follows:
23
+
24
+ Training Set: 10,918,272 tokens
25
+
26
+ Validation Set: 1,213,184 tokens
27
+
28
+ Test Set: 1,347,968 tokens
29
+
30
+ Pre-training Dataset: FinBERT was pre-trained on a large financial corpus totaling 4.9 billion tokens, including:
31
+
32
+ Corporate Reports (10-K & 10-Q): 2.5 billion tokens
33
+
34
+ Earnings Call Transcripts: 1.3 billion tokens
35
+
36
+ Analyst Reports: 1.1 billion tokens
37
+
38
+ ## Evaluation
39
+
40
+ * Test Accuracy = 0.908469
41
+ * Test Precision = 0.927788
42
+ * Test Recall = 0.908469
43
+ * Test F1 = 0.913267
44
+ * **Labels**: 0 -> Neutral; 1 -> Positive; 2 -> Negative
45
+
46
+
47
+ ## Usage
48
+
49
+ ```
50
+ import torch
51
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
52
+ tokenizer = AutoTokenizer.from_pretrained("fuchenru/Trading-Hero-LLM")
53
+ model = AutoModelForSequenceClassification.from_pretrained("fuchenru/Trading-Hero-LLM")
54
+ nlp = pipeline("text-classification", model=model, tokenizer=tokenizer)
55
+ # Preprocess the input text
56
+ def preprocess(text, tokenizer, max_length=128):
57
+ inputs = tokenizer(text, truncation=True, padding='max_length', max_length=max_length, return_tensors='pt')
58
+ return inputs
59
+
60
+ # Function to perform prediction
61
+ def predict_sentiment(input_text):
62
+ # Tokenize the input text
63
+ inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True)
64
+
65
+ # Perform inference
66
+ with torch.no_grad():
67
+ outputs = model(**inputs)
68
+
69
+ # Get predicted label
70
+ predicted_label = torch.argmax(outputs.logits, dim=1).item()
71
+
72
+ # Map the predicted label to the original labels
73
+ label_map = {0: 'neutral', 1: 'positive', 2: 'negative'}
74
+ predicted_sentiment = label_map[predicted_label]
75
+
76
+ return predicted_sentiment
77
+
78
+ stock_news = [
79
+ "Market analysts predict a stable outlook for the coming weeks.",
80
+ "The market remained relatively flat today, with minimal movement in stock prices.",
81
+ "Investor sentiment improved following news of a potential trade deal.",
82
+ .......
83
+ ]
84
+
85
+
86
+ for i in stock_news:
87
+ predicted_sentiment = predict_sentiment(i)
88
+ print("Predicted Sentiment:", predicted_sentiment)
89
+ ```
90
+ ```
91
+ Predicted Sentiment: neutral
92
+ Predicted Sentiment: neutral
93
+ Predicted Sentiment: positive
94
+ ```
95
+
96
+ ## Citation
97
+
98
+ ```
99
+ @misc{yang2020finbert,
100
+ title={FinBERT: A Pretrained Language Model for Financial Communications},
101
+ author={Yi Yang and Mark Christopher Siy UY and Allen Huang},
102
+ year={2020},
103
+ eprint={2006.08097},
104
+ archivePrefix={arXiv},
105
+ }
106
+ ```
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "model_df_7",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "id2label": {
12
+ "0": "LABEL_0",
13
+ "1": "LABEL_1",
14
+ "2": "LABEL_2"
15
+ },
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 3072,
18
+ "label2id": {
19
+ "LABEL_0": 0,
20
+ "LABEL_1": 1,
21
+ "LABEL_2": 2
22
+ },
23
+ "layer_norm_eps": 1e-12,
24
+ "max_position_embeddings": 512,
25
+ "model_type": "bert",
26
+ "num_attention_heads": 12,
27
+ "num_hidden_layers": 12,
28
+ "pad_token_id": 0,
29
+ "position_embedding_type": "absolute",
30
+ "problem_type": "single_label_classification",
31
+ "torch_dtype": "float32",
32
+ "transformers_version": "4.41.1",
33
+ "type_vocab_size": 2,
34
+ "use_cache": true,
35
+ "vocab_size": 30873
36
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5411019d7b22b5376249eb3d50ed59772f0b93419849580e16e7d060935f69a7
3
+ size 439039996
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "2": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "3": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "4": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "5": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 1000000000000000019884624838656,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "BertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff