cta2106 commited on
Commit
38d4932
1 Parent(s): 850e40d

initial commit

Browse files
Files changed (5) hide show
  1. .gitignore +3 -0
  2. app.py +13 -0
  3. model/config.json +57 -0
  4. model/pytorch_model.bin +3 -0
  5. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ venv
2
+ .DS_Store
3
+ .idea/
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline, LongformerForSequenceClassification, LongformerTokenizer, Trainer
2
+ import gradio as gr
3
+
4
+
5
+ def predict_fn(text: str) -> str:
6
+ model = LongformerForSequenceClassification.from_pretrained("model")
7
+ tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-base-4096")
8
+
9
+ p = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
10
+ return p(text)["label"]
11
+
12
+
13
+ gr.Interface(predict_fn, "textbox", "label").launch()
model/config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "allenai/longformer-base-4096",
3
+ "architectures": [
4
+ "LongformerForSequenceClassification"
5
+ ],
6
+ "attention_mode": "longformer",
7
+ "attention_probs_dropout_prob": 0.1,
8
+ "attention_window": [
9
+ 512,
10
+ 512,
11
+ 512,
12
+ 512,
13
+ 512,
14
+ 512,
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512,
19
+ 512,
20
+ 512
21
+ ],
22
+ "bos_token_id": 0,
23
+ "classifier_dropout": null,
24
+ "eos_token_id": 2,
25
+ "gradient_checkpointing": false,
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": 0,
39
+ "LABEL_1": 1,
40
+ "LABEL_2": 2
41
+ },
42
+ "layer_norm_eps": 1e-05,
43
+ "max_position_embeddings": 4098,
44
+ "model_type": "longformer",
45
+ "num_attention_heads": 12,
46
+ "num_hidden_layers": 12,
47
+ "onnx_export": false,
48
+ "pad_token_id": 1,
49
+ "position_embedding_type": "absolute",
50
+ "problem_type": "multi_label_classification",
51
+ "sep_token_id": 2,
52
+ "torch_dtype": "float32",
53
+ "transformers_version": "4.23.1",
54
+ "type_vocab_size": 1,
55
+ "use_cache": true,
56
+ "vocab_size": 50265
57
+ }
model/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:963dc4d435b943d3f2a60faece01bd04798f5b6d30e12aa55a5ce9d92f3c4447
3
+ size 594740127
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ transformers
2
+ torch
3
+ torchvision
4
+ gradio