Ani-404 commited on
Commit
025d0f3
·
1 Parent(s): 39c18ce

updated and added multiple files

Browse files
finance/finbert_large_emotion_model/config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "id2label": {
12
+ "0": "anger",
13
+ "1": "disgust",
14
+ "2": "fear",
15
+ "3": "joy",
16
+ "4": "neutral",
17
+ "5": "sadness",
18
+ "6": "shame",
19
+ "7": "surprise"
20
+ },
21
+ "initializer_range": 0.02,
22
+ "intermediate_size": 3072,
23
+ "label2id": {
24
+ "anger": 0,
25
+ "disgust": 1,
26
+ "fear": 2,
27
+ "joy": 3,
28
+ "neutral": 4,
29
+ "sadness": 5,
30
+ "shame": 6,
31
+ "surprise": 7
32
+ },
33
+ "layer_norm_eps": 1e-12,
34
+ "max_position_embeddings": 512,
35
+ "model_type": "bert",
36
+ "num_attention_heads": 12,
37
+ "num_hidden_layers": 12,
38
+ "pad_token_id": 0,
39
+ "position_embedding_type": "absolute",
40
+ "problem_type": "single_label_classification",
41
+ "transformers_version": "4.56.1",
42
+ "type_vocab_size": 2,
43
+ "use_cache": true,
44
+ "vocab_size": 30873
45
+ }
finance/finbert_large_emotion_model/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
finance/finbert_large_emotion_model/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
finance/finbert_large_emotion_model/tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 1000000000000000019884624838656,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
finance/finbert_large_emotion_model/vocab.txt ADDED
The diff for this file is too large to render. See raw diff
 
finance/train_finbert.py CHANGED
@@ -27,7 +27,6 @@ def compute_metrics(p):
27
 
28
  def main():
29
  """Main function to load data, fine-tune the FinBERT model, and save it."""
30
- # --- 1. Define Paths for Colab's Temporary Session Storage ---
31
  # This path points to the file you just uploaded.
32
  data_path = "/content/emotion_dataset.csv"
33
  # The final model will be saved here, in the temporary storage.
@@ -59,7 +58,7 @@ def main():
59
 
60
  # --- 3. Load Tokenizer and Model ---
61
  print("Loading FinBERT tokenizer and model...")
62
- model_name = "ProsusAI/finbert"
63
  tokenizer = AutoTokenizer.from_pretrained(model_name)
64
 
65
  model = AutoModelForSequenceClassification.from_pretrained(
@@ -82,12 +81,12 @@ def main():
82
 
83
  training_args = TrainingArguments(
84
  output_dir=output_dir,
85
- num_train_epochs=1,
86
  per_device_train_batch_size=16,
87
  per_device_eval_batch_size=16,
88
  logging_steps=100,
89
  evaluation_strategy="epoch",
90
- save_strategy="epoch",
91
  load_best_model_at_end=True,
92
  )
93
 
 
27
 
28
  def main():
29
  """Main function to load data, fine-tune the FinBERT model, and save it."""
 
30
  # This path points to the file you just uploaded.
31
  data_path = "/content/emotion_dataset.csv"
32
  # The final model will be saved here, in the temporary storage.
 
58
 
59
  # --- 3. Load Tokenizer and Model ---
60
  print("Loading FinBERT tokenizer and model...")
61
+ model_name = 'yiyanghkust/finbert-pretrai'
62
  tokenizer = AutoTokenizer.from_pretrained(model_name)
63
 
64
  model = AutoModelForSequenceClassification.from_pretrained(
 
81
 
82
  training_args = TrainingArguments(
83
  output_dir=output_dir,
84
+ num_train_epochs=3,
85
  per_device_train_batch_size=16,
86
  per_device_eval_batch_size=16,
87
  logging_steps=100,
88
  evaluation_strategy="epoch",
89
+ save_strategy="no",
90
  load_best_model_at_end=True,
91
  )
92