Spaces:
Build error
Build error
yangxinsci1993
commited on
Commit
•
7b6f763
1
Parent(s):
43793f0
Add application file
Browse files- .DS_Store +0 -0
- app.py +25 -0
- output.zip +3 -0
- output/.DS_Store +0 -0
- output/reframer/config.json +74 -0
- output/reframer/merges.txt +0 -0
- output/reframer/pytorch_model.bin +3 -0
- output/reframer/special_tokens_map.json +51 -0
- output/reframer/tokenizer_config.json +64 -0
- output/reframer/training_args.bin +3 -0
- output/reframer/vocab.json +0 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from transformers import AutoModelForSeq2SeqLM
|
3 |
+
from transformers import AutoTokenizer
|
4 |
+
|
5 |
+
|
6 |
+
# Load trained model
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("/output/reframer")
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("/output/reframer")
|
9 |
+
reframer = pipeline('summarization', model=model, tokenizer=tokenizer)
|
10 |
+
|
11 |
+
|
12 |
+
def reframe(text, strategy):
|
13 |
+
text_with_strategy = text + "Strategy: ['" + strategy + "']"
|
14 |
+
return reframer(text_with_strategy)[0]['summary_text']
|
15 |
+
|
16 |
+
|
17 |
+
import gradio as gr
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
text = gr.Textbox(label="Original Text")
|
20 |
+
radio = gr.Radio(
|
21 |
+
["thankfulness", "neutralizing", "optimism", "growth", "impermanence", "self_affirmation"], label="Strategy to use?"
|
22 |
+
)
|
23 |
+
output = gr.Textbox(label="Reframed Output")
|
24 |
+
radio.change(fn=reframe, inputs=[text, radio], outputs=output)
|
25 |
+
demo.launch()
|
output.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a73c30ab832fbb661f4c12f32c97b3882c7822a0c19ee09b3bc5991c54741b5
|
3 |
+
size 1507093932
|
output/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
output/reframer/config.json
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "facebook/bart-large",
|
3 |
+
"activation_dropout": 0.1,
|
4 |
+
"activation_function": "gelu",
|
5 |
+
"add_bias_logits": false,
|
6 |
+
"add_final_layer_norm": false,
|
7 |
+
"architectures": [
|
8 |
+
"BartForConditionalGeneration"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.1,
|
11 |
+
"bos_token_id": 0,
|
12 |
+
"classif_dropout": 0.1,
|
13 |
+
"classifier_dropout": 0.0,
|
14 |
+
"d_model": 1024,
|
15 |
+
"decoder_attention_heads": 16,
|
16 |
+
"decoder_ffn_dim": 4096,
|
17 |
+
"decoder_layerdrop": 0.0,
|
18 |
+
"decoder_layers": 12,
|
19 |
+
"decoder_start_token_id": 2,
|
20 |
+
"dropout": 0.1,
|
21 |
+
"early_stopping": true,
|
22 |
+
"encoder_attention_heads": 16,
|
23 |
+
"encoder_ffn_dim": 4096,
|
24 |
+
"encoder_layerdrop": 0.0,
|
25 |
+
"encoder_layers": 12,
|
26 |
+
"eos_token_id": 2,
|
27 |
+
"forced_bos_token_id": 0,
|
28 |
+
"forced_eos_token_id": 2,
|
29 |
+
"gradient_checkpointing": false,
|
30 |
+
"id2label": {
|
31 |
+
"0": "LABEL_0",
|
32 |
+
"1": "LABEL_1",
|
33 |
+
"2": "LABEL_2"
|
34 |
+
},
|
35 |
+
"init_std": 0.02,
|
36 |
+
"is_encoder_decoder": true,
|
37 |
+
"label2id": {
|
38 |
+
"LABEL_0": 0,
|
39 |
+
"LABEL_1": 1,
|
40 |
+
"LABEL_2": 2
|
41 |
+
},
|
42 |
+
"max_position_embeddings": 1024,
|
43 |
+
"model_type": "bart",
|
44 |
+
"no_repeat_ngram_size": 3,
|
45 |
+
"normalize_before": false,
|
46 |
+
"num_beams": 4,
|
47 |
+
"num_hidden_layers": 12,
|
48 |
+
"pad_token_id": 1,
|
49 |
+
"scale_embedding": false,
|
50 |
+
"task_specific_params": {
|
51 |
+
"summarization": {
|
52 |
+
"length_penalty": 1.0,
|
53 |
+
"max_length": 128,
|
54 |
+
"min_length": 12,
|
55 |
+
"num_beams": 4
|
56 |
+
},
|
57 |
+
"summarization_cnn": {
|
58 |
+
"length_penalty": 2.0,
|
59 |
+
"max_length": 142,
|
60 |
+
"min_length": 56,
|
61 |
+
"num_beams": 4
|
62 |
+
},
|
63 |
+
"summarization_xsum": {
|
64 |
+
"length_penalty": 1.0,
|
65 |
+
"max_length": 62,
|
66 |
+
"min_length": 11,
|
67 |
+
"num_beams": 6
|
68 |
+
}
|
69 |
+
},
|
70 |
+
"torch_dtype": "float32",
|
71 |
+
"transformers_version": "4.21.1",
|
72 |
+
"use_cache": true,
|
73 |
+
"vocab_size": 50265
|
74 |
+
}
|
output/reframer/merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
output/reframer/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:441f3ebb7b145b377eeae9eaf7b317a3a83e7f13c77f3f41c2276df2e41daa90
|
3 |
+
size 1625537793
|
output/reframer/special_tokens_map.json
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": true,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"cls_token": {
|
10 |
+
"content": "<s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": true,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"eos_token": {
|
17 |
+
"content": "</s>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": true,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"mask_token": {
|
24 |
+
"content": "<mask>",
|
25 |
+
"lstrip": true,
|
26 |
+
"normalized": true,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"pad_token": {
|
31 |
+
"content": "<pad>",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"sep_token": {
|
38 |
+
"content": "</s>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": true,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false
|
43 |
+
},
|
44 |
+
"unk_token": {
|
45 |
+
"content": "<unk>",
|
46 |
+
"lstrip": false,
|
47 |
+
"normalized": true,
|
48 |
+
"rstrip": false,
|
49 |
+
"single_word": false
|
50 |
+
}
|
51 |
+
}
|
output/reframer/tokenizer_config.json
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"bos_token": {
|
4 |
+
"__type": "AddedToken",
|
5 |
+
"content": "<s>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": true,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false
|
10 |
+
},
|
11 |
+
"cls_token": {
|
12 |
+
"__type": "AddedToken",
|
13 |
+
"content": "<s>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": true,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false
|
18 |
+
},
|
19 |
+
"eos_token": {
|
20 |
+
"__type": "AddedToken",
|
21 |
+
"content": "</s>",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": true,
|
24 |
+
"rstrip": false,
|
25 |
+
"single_word": false
|
26 |
+
},
|
27 |
+
"errors": "replace",
|
28 |
+
"mask_token": {
|
29 |
+
"__type": "AddedToken",
|
30 |
+
"content": "<mask>",
|
31 |
+
"lstrip": true,
|
32 |
+
"normalized": true,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false
|
35 |
+
},
|
36 |
+
"model_max_length": 1024,
|
37 |
+
"name_or_path": "facebook/bart-large",
|
38 |
+
"pad_token": {
|
39 |
+
"__type": "AddedToken",
|
40 |
+
"content": "<pad>",
|
41 |
+
"lstrip": false,
|
42 |
+
"normalized": true,
|
43 |
+
"rstrip": false,
|
44 |
+
"single_word": false
|
45 |
+
},
|
46 |
+
"sep_token": {
|
47 |
+
"__type": "AddedToken",
|
48 |
+
"content": "</s>",
|
49 |
+
"lstrip": false,
|
50 |
+
"normalized": true,
|
51 |
+
"rstrip": false,
|
52 |
+
"single_word": false
|
53 |
+
},
|
54 |
+
"special_tokens_map_file": null,
|
55 |
+
"tokenizer_class": "BartTokenizer",
|
56 |
+
"unk_token": {
|
57 |
+
"__type": "AddedToken",
|
58 |
+
"content": "<unk>",
|
59 |
+
"lstrip": false,
|
60 |
+
"normalized": true,
|
61 |
+
"rstrip": false,
|
62 |
+
"single_word": false
|
63 |
+
}
|
64 |
+
}
|
output/reframer/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:96a83905d0b9304036abbf015f0532c9294d80f8540ba7ff646d8cd91fa2d243
|
3 |
+
size 3439
|
output/reframer/vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|