armandstrickernlp commited on
Commit
fb373b9
·
1 Parent(s): d209321

app + chackpoint

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import (T5Tokenizer,
3
+ T5ForConditionalGeneration,
4
+ AddedToken,
5
+ )
6
+
7
+
8
+ tokenizer = T5Tokenizer.from_pretrained(f"google/flan-t5-base")
9
+ tokenizer.add_special_tokens({"additional_special_tokens": [AddedToken("\n")]})
10
+
11
+ # load model
12
+ model_cktp = "model_checkpoint"
13
+ model = T5ForConditionalGeneration.from_pretrained(model_cktp)
14
+
15
+ def predict(input):
16
+ input_ids = tokenizer.encode(input, return_tensors="pt")
17
+ outputs = model.generate(input_ids,
18
+ max_length=200,
19
+ early_stopping=True)
20
+ response = tokenizer.decode(outputs[0], skip_special_tokens=False)
21
+ response = response.replace("<pad>", "").replace("</s>", "")
22
+ return response
23
+
24
+
25
+ examples = [["""Service: telecom customer service.
26
+ Customer utterance : "I'm trying to find out when my tv service will be turn back on??????"|
27
+ Extract all strictly unnecessary sequences for the service provider to process the request/issue and then classify them using relational tags."""],
28
+ ["""Service: airline customer service.
29
+ Customer utterance : "I need a ticket to Boston this Saturday, my son is graduating!"|
30
+ Extract all strictly unnecessary sequences for the service provider to process the request/issue and classify them using relational tags."""]
31
+ ]
32
+
33
+ description = """This model detects and classifies relational strategies in customer service requests, using an instruction-based approach."""
34
+
35
+ demo = gr.Interface(fn=predict,
36
+ inputs="text",
37
+ outputs="text",
38
+ title="FLAN-T5: Detect and Classify Relational Strategies",
39
+ examples=examples,
40
+ description=description)
41
+
42
+ if __name__ == "__main__":
43
+ demo.launch()
44
+
45
+
46
+
47
+
48
+
49
+
model_checkpoint/.DS_Store ADDED
Binary file (6.15 kB). View file
 
model_checkpoint/config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "google/flan-t5-base",
3
+ "architectures": [
4
+ "T5ForConditionalGeneration"
5
+ ],
6
+ "d_ff": 2048,
7
+ "d_kv": 64,
8
+ "d_model": 768,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "gelu_new",
11
+ "dropout_rate": 0.1,
12
+ "eos_token_id": 1,
13
+ "feed_forward_proj": "gated-gelu",
14
+ "initializer_factor": 1.0,
15
+ "is_encoder_decoder": true,
16
+ "is_gated_act": true,
17
+ "layer_norm_epsilon": 1e-06,
18
+ "model_type": "t5",
19
+ "n_positions": 512,
20
+ "num_decoder_layers": 12,
21
+ "num_heads": 12,
22
+ "num_layers": 12,
23
+ "output_past": true,
24
+ "pad_token_id": 0,
25
+ "relative_attention_max_distance": 128,
26
+ "relative_attention_num_buckets": 32,
27
+ "task_specific_params": {
28
+ "summarization": {
29
+ "early_stopping": true,
30
+ "length_penalty": 2.0,
31
+ "max_length": 200,
32
+ "min_length": 30,
33
+ "no_repeat_ngram_size": 3,
34
+ "num_beams": 4,
35
+ "prefix": "summarize: "
36
+ },
37
+ "translation_en_to_de": {
38
+ "early_stopping": true,
39
+ "max_length": 300,
40
+ "num_beams": 4,
41
+ "prefix": "translate English to German: "
42
+ },
43
+ "translation_en_to_fr": {
44
+ "early_stopping": true,
45
+ "max_length": 300,
46
+ "num_beams": 4,
47
+ "prefix": "translate English to French: "
48
+ },
49
+ "translation_en_to_ro": {
50
+ "early_stopping": true,
51
+ "max_length": 300,
52
+ "num_beams": 4,
53
+ "prefix": "translate English to Romanian: "
54
+ }
55
+ },
56
+ "tie_word_embeddings": false,
57
+ "torch_dtype": "float32",
58
+ "transformers_version": "4.26.0",
59
+ "use_cache": true,
60
+ "vocab_size": 32101
61
+ }
model_checkpoint/generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "decoder_start_token_id": 0,
4
+ "eos_token_id": 1,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.26.0"
7
+ }
model_checkpoint/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21fa8993f500e9404f1df4f4c116bae425d52e1be037f62bd474a94227e3bdbb
3
+ size 990242997
model_checkpoint/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8406259d6fb5df1141b5e09507c2ff97c99a753f3a9eac4ddbba8a3330124a4
3
+ size 3643