ritessshhh commited on
Commit
3e4ee15
·
verified ·
1 Parent(s): e96071f

Upload folder using huggingface_hub

Browse files
config.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "dtype": "float32",
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 1024,
13
+ "id2label": {
14
+ "0": "CSR/Brand",
15
+ "1": "Deal",
16
+ "2": "Dividend",
17
+ "3": "Employment",
18
+ "4": "Expense",
19
+ "5": "Facility",
20
+ "6": "FinancialReport",
21
+ "7": "Financing",
22
+ "8": "Investment",
23
+ "9": "Legal",
24
+ "10": "Macroeconomics",
25
+ "11": "Merger/Acquisition",
26
+ "12": "Product/Service",
27
+ "13": "Profit/Loss",
28
+ "14": "Rating",
29
+ "15": "Revenue",
30
+ "16": "SalesVolume",
31
+ "17": "SecurityValue"
32
+ },
33
+ "initializer_range": 0.02,
34
+ "intermediate_size": 4096,
35
+ "label2id": {
36
+ "CSR/Brand": 0,
37
+ "Deal": 1,
38
+ "Dividend": 2,
39
+ "Employment": 3,
40
+ "Expense": 4,
41
+ "Facility": 5,
42
+ "FinancialReport": 6,
43
+ "Financing": 7,
44
+ "Investment": 8,
45
+ "Legal": 9,
46
+ "Macroeconomics": 10,
47
+ "Merger/Acquisition": 11,
48
+ "Product/Service": 12,
49
+ "Profit/Loss": 13,
50
+ "Rating": 14,
51
+ "Revenue": 15,
52
+ "SalesVolume": 16,
53
+ "SecurityValue": 17
54
+ },
55
+ "layer_norm_eps": 1e-05,
56
+ "max_position_embeddings": 514,
57
+ "model_type": "roberta",
58
+ "num_attention_heads": 16,
59
+ "num_hidden_layers": 24,
60
+ "pad_token_id": 1,
61
+ "position_embedding_type": "absolute",
62
+ "problem_type": "multi_label_classification",
63
+ "transformers_version": "4.57.2",
64
+ "type_vocab_size": 1,
65
+ "use_cache": true,
66
+ "vocab_size": 50265
67
+ }
handler.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import numpy as np
3
+ from typing import Dict, List, Any
4
+
5
+ class EndpointHandler:
6
+ def __init__(self, path=""):
7
+ # Load the model and tokenizer
8
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
9
+ self.model = AutoModelForSequenceClassification.from_pretrained(path)
10
+ self.tokenizer = AutoTokenizer.from_pretrained(path)
11
+
12
+ # Load per-class thresholds
13
+ thresholds_path = f"{path}/thresholds.npy"
14
+ self.thresholds = np.load(thresholds_path)
15
+
16
+ self.model.eval()
17
+
18
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
19
+ """
20
+ Args:
21
+ data (Dict[str, Any]): Input data containing 'inputs' key
22
+ Returns:
23
+ List[Dict[str, Any]]: Predictions with labels and scores
24
+ """
25
+ inputs_text = data.pop("inputs", data)
26
+
27
+ # Tokenize
28
+ inputs = self.tokenizer(
29
+ inputs_text,
30
+ return_tensors="pt",
31
+ truncation=True,
32
+ padding="max_length",
33
+ max_length=128
34
+ )
35
+
36
+ # Inference
37
+ with torch.no_grad():
38
+ outputs = self.model(**inputs)
39
+ logits = outputs.logits[0]
40
+ probs = torch.sigmoid(logits).cpu().numpy()
41
+
42
+ # Apply per-class thresholds
43
+ predictions = []
44
+ for idx, prob in enumerate(probs):
45
+ if prob >= self.thresholds[idx]:
46
+ predictions.append({
47
+ "label": self.model.config.id2label[idx],
48
+ "score": float(prob)
49
+ })
50
+
51
+ # Sort by score descending
52
+ predictions = sorted(predictions, key=lambda x: x["score"], reverse=True)
53
+
54
+ return predictions
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2fea05419ed4f1c5d52f6d731e0aec523403703e35d23c689b45521de08ad8c
3
+ size 1421561016
readme.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RoBERTa Multi-Label Financial Event Classifier (SENTiVENT)
2
+
3
+ This model is a fine-tuned **RoBERTa** classifier that predicts one or more **financial event types** from a news headline or short piece of text.
4
+
5
+ Given a headline, the model outputs probabilities for multiple event categories such as mergers, earnings reports, legal actions, investments, and more. It is designed for **multi-label classification**, meaning a single headline can belong to multiple event types at once.
6
+
7
+ ---
8
+
9
+ ## Event Labels
10
+
11
+ The model predicts the following 18 event categories:
12
+
13
+ - CSR/Brand
14
+ - Deal
15
+ - Dividend
16
+ - Employment
17
+ - Expense
18
+ - Facility
19
+ - FinancialReport
20
+ - Financing
21
+ - Investment
22
+ - Legal
23
+ - Macroeconomics
24
+ - Merger/Acquisition
25
+ - Product/Service
26
+ - Profit/Loss
27
+ - Rating
28
+ - Revenue
29
+ - SalesVolume
30
+ - SecurityValue
31
+
32
+ ---
33
+
34
+ ## Intended Use
35
+
36
+ This model is useful for:
37
+
38
+ - Financial news analysis
39
+ - Market event extraction
40
+ - Trading signal pipelines
41
+ - Knowledge graph population
42
+ - Research in finance-focused NLP
43
+
44
+ It works best on **short financial news headlines or sentences**.
45
+
46
+ ---
47
+
48
+ ## Model Details
49
+
50
+ - Base model: `roberta-base`
51
+ - Task: Multi-label text classification
52
+ - Activation: Sigmoid (per-label probabilities)
53
+ - Loss: Binary Cross Entropy
54
+ - Problem type: `multi_label_classification`
55
+
56
+ The model configuration includes `id2label`, `label2id`, and the correct problem type so it works cleanly with Hugging Face pipelines.
57
+
58
+ ---
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
thresholds.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae12d5e934f881025c5b757c8fe3b3222b03acb23d95742ba193178f7086c7bf
3
+ size 418
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "model_max_length": 512,
53
+ "pad_token": "<pad>",
54
+ "sep_token": "</s>",
55
+ "tokenizer_class": "RobertaTokenizer",
56
+ "trim_offsets": true,
57
+ "unk_token": "<unk>"
58
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4777712ed9d7b32a340e8548f6cfa3388f82beba906b15f717b297b0eae2a82
3
+ size 5777
vocab.json ADDED
The diff for this file is too large to render. See raw diff