Spaces:
Runtime error
Runtime error
cta2106
commited on
Commit
•
52e8dae
1
Parent(s):
4d37ccb
fixed
Browse files- app.py +6 -4
- model/config.json +10 -8
- model/pytorch_model.bin +2 -2
app.py
CHANGED
@@ -8,9 +8,11 @@ def predict_fn(text: str) -> Tuple[Any, Any]:
|
|
8 |
model = LongformerForSequenceClassification.from_pretrained("model")
|
9 |
tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-base-4096")
|
10 |
p = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
11 |
-
results = p(text)
|
12 |
-
|
13 |
-
|
14 |
|
|
|
15 |
|
16 |
-
|
|
|
|
8 |
model = LongformerForSequenceClassification.from_pretrained("model")
|
9 |
tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-base-4096")
|
10 |
p = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
11 |
+
results = p(text, top_k=3)
|
12 |
+
WEIGHTS = {"Dovish": -100, "Neutral": 0, "Hawkish": 100}
|
13 |
+
scores = [d["score"] * WEIGHTS.get(d["label"]) for d in results]
|
14 |
|
15 |
+
return results[0]["label"], round(sum(scores), 0)
|
16 |
|
17 |
+
|
18 |
+
gr.Interface(predict_fn, "textbox", ["label", "label"]).launch(share=True)
|
model/config.json
CHANGED
@@ -26,17 +26,19 @@
|
|
26 |
"hidden_act": "gelu",
|
27 |
"hidden_dropout_prob": 0.1,
|
28 |
"hidden_size": 768,
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
"ignore_attention_mask": false,
|
34 |
"initializer_range": 0.02,
|
35 |
"intermediate_size": 3072,
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
"layer_norm_eps": 1e-05,
|
41 |
"max_position_embeddings": 4098,
|
42 |
"model_type": "longformer",
|
|
|
26 |
"hidden_act": "gelu",
|
27 |
"hidden_dropout_prob": 0.1,
|
28 |
"hidden_size": 768,
|
29 |
+
"id2label": {
|
30 |
+
"0": "Dovish",
|
31 |
+
"1": "Neutral",
|
32 |
+
"2": "Hawkish"
|
33 |
+
},
|
34 |
"ignore_attention_mask": false,
|
35 |
"initializer_range": 0.02,
|
36 |
"intermediate_size": 3072,
|
37 |
+
"label2id": {
|
38 |
+
"LABEL_0": "Dovish",
|
39 |
+
"LABEL_1": "Neutral",
|
40 |
+
"LABEL_2": "Hawkish"
|
41 |
+
},
|
42 |
"layer_norm_eps": 1e-05,
|
43 |
"max_position_embeddings": 4098,
|
44 |
"model_type": "longformer",
|
model/pytorch_model.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f71b1e9b130a6356c987737aa2f9e9154cabff16f6c581e86548de746941f2b7
|
3 |
+
size 594740127
|