ojasaar commited on
Commit
85beddf
1 Parent(s): a8fa292

Update model config and readme

Browse files
Files changed (6) hide show
  1. .README.md.un~ +0 -0
  2. .config.json.un~ +0 -0
  3. README.md +2 -2
  4. README.md~ +81 -0
  5. config.json +1 -19
  6. config.json~ +55 -0
.README.md.un~ ADDED
Binary file (3.1 kB). View file
 
.config.json.un~ ADDED
Binary file (3.63 kB). View file
 
README.md CHANGED
@@ -2,7 +2,7 @@
2
  language:
3
  - en
4
  tags:
5
- - question-answering
6
  - summarization
7
  - emotion-detection
8
  license: Apache 2.0
@@ -20,7 +20,7 @@ metrics:
20
 
21
  This model was finetuned on the CoQa, Squad 2, GoEmotions and CNN/DailyMail.
22
 
23
- It achieves a score of *F1 76.7* on the Squad 2 dev set and a score of *F1 68.5* on the CoQa dev set.
24
 
25
  Summarisation and emotion detection has not been evaluated yet.
26
 
 
2
  language:
3
  - en
4
  tags:
5
+ - qa
6
  - summarization
7
  - emotion-detection
8
  license: Apache 2.0
 
20
 
21
  This model was finetuned on the CoQa, Squad 2, GoEmotions and CNN/DailyMail.
22
 
23
+ It achieves a score of **F1 76.7** on the Squad 2 dev set and a score of **F1 68.5** on the CoQa dev set.
24
 
25
  Summarisation and emotion detection has not been evaluated yet.
26
 
README.md~ ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - question-answering
6
+ - summarization
7
+ - emotion-detection
8
+ license: Apache 2.0
9
+ datasets:
10
+ - coqa
11
+ - squad_v2
12
+ - go_emotions
13
+ - cnn_dailymail
14
+ metrics:
15
+ - f1
16
+ ---
17
+ # T5 Base with QA + Summary + Emotion
18
+
19
+ ## Description
20
+
21
+ This model was finetuned on the CoQa, Squad 2, GoEmotions and CNN/DailyMail.
22
+
23
+ It achieves a score of **F1 76.7** on the Squad 2 dev set and a score of **F1 68.5** on the CoQa dev set.
24
+
25
+ Summarisation and emotion detection has not been evaluated yet.
26
+
27
+ ## Usage
28
+
29
+ ### Question answering
30
+
31
+ ```python
32
+ from transformers import T5ForConditionalGeneration, T5Tokenizer
33
+ model = T5ForConditionalGeneration.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
34
+ tokenizer = T5Tokenizer.from_pretrained("t5-base")
35
+
36
+ def get_answer(question, prev_qa, context):
37
+ input_text = [f"q: {qa[0]} a: {qa[1]}" for qa in prev_qa]
38
+ input_text.append(f"q: {question}")
39
+ input_text.append(f"c: {context}")
40
+ input_text = " ".join(input_text)
41
+ features = tokenizer([input_text], return_tensors='pt')
42
+ tokens = model.generate(input_ids=features['input_ids'],
43
+ attention_mask=features['attention_mask'], max_length=64)
44
+ return tokenizer.decode(tokens[0], skip_special_tokens=True)
45
+
46
+ print(get_answer("Why is the moon yellow?", "I'm not entirely sure why the moon is yellow.")) # unknown
47
+
48
+ context = "Elon Musk left OpenAI to avoid possible future conflicts with his role as CEO of Tesla."
49
+
50
+ print(get_answer("Why not?", [("Does Elon Musk still work with OpenAI", "No")], context)) # to avoid possible future conflicts with his role as CEO of Tesla
51
+ ```
52
+
53
+ ### Summarisation
54
+
55
+ ```python
56
+ from transformers import T5ForConditionalGeneration, T5Tokenizer
57
+ model = T5ForConditionalGeneration.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
58
+ tokenizer = T5Tokenizer.from_pretrained("t5-base")
59
+
60
+ def summary(context):
61
+ input_text = f"summarize: {context}"
62
+ features = tokenizer([input_text], return_tensors='pt')
63
+ tokens = model.generate(input_ids=features['input_ids'],
64
+ attention_mask=features['attention_mask'], max_length=64)
65
+ return tokenizer.decode(tokens[0], skip_special_tokens=True)
66
+ ```
67
+
68
+ ### Emotion detection
69
+
70
+ ```python
71
+ from transformers import T5ForConditionalGeneration, T5Tokenizer
72
+ model = T5ForConditionalGeneration.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
73
+ tokenizer = T5Tokenizer.from_pretrained("t5-base")
74
+
75
+ def emotion(context):
76
+ input_text = f"emotion: {context}"
77
+ features = tokenizer([input_text], return_tensors='pt')
78
+ tokens = model.generate(input_ids=features['input_ids'],
79
+ attention_mask=features['attention_mask'], max_length=64)
80
+ return tokenizer.decode(tokens[0], skip_special_tokens=True)
81
+ ```
config.json CHANGED
@@ -29,26 +29,8 @@
29
  "min_length": 30,
30
  "no_repeat_ngram_size": 3,
31
  "num_beams": 4,
32
- "prefix": "summarize: "
33
  },
34
- "translation_en_to_de": {
35
- "early_stopping": true,
36
- "max_length": 300,
37
- "num_beams": 4,
38
- "prefix": "translate English to German: "
39
- },
40
- "translation_en_to_fr": {
41
- "early_stopping": true,
42
- "max_length": 300,
43
- "num_beams": 4,
44
- "prefix": "translate English to French: "
45
- },
46
- "translation_en_to_ro": {
47
- "early_stopping": true,
48
- "max_length": 300,
49
- "num_beams": 4,
50
- "prefix": "translate English to Romanian: "
51
- }
52
  },
53
  "use_cache": true,
54
  "vocab_size": 32128
 
29
  "min_length": 30,
30
  "no_repeat_ngram_size": 3,
31
  "num_beams": 4,
32
+ "prefix": "summarise: "
33
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  },
35
  "use_cache": true,
36
  "vocab_size": 32128
config.json~ ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "t5-base",
3
+ "architectures": [
4
+ "T5ForConditionalGeneration"
5
+ ],
6
+ "d_ff": 3072,
7
+ "d_kv": 64,
8
+ "d_model": 768,
9
+ "decoder_start_token_id": 0,
10
+ "dropout_rate": 0.1,
11
+ "eos_token_id": 1,
12
+ "feed_forward_proj": "relu",
13
+ "initializer_factor": 1.0,
14
+ "is_encoder_decoder": true,
15
+ "layer_norm_epsilon": 1e-06,
16
+ "model_type": "t5",
17
+ "n_positions": 512,
18
+ "num_decoder_layers": 12,
19
+ "num_heads": 12,
20
+ "num_layers": 12,
21
+ "output_past": true,
22
+ "pad_token_id": 0,
23
+ "relative_attention_num_buckets": 32,
24
+ "task_specific_params": {
25
+ "summarization": {
26
+ "early_stopping": true,
27
+ "length_penalty": 2.0,
28
+ "max_length": 200,
29
+ "min_length": 30,
30
+ "no_repeat_ngram_size": 3,
31
+ "num_beams": 4,
32
+ "prefix": "summarize: "
33
+ },
34
+ "translation_en_to_de": {
35
+ "early_stopping": true,
36
+ "max_length": 300,
37
+ "num_beams": 4,
38
+ "prefix": "translate English to German: "
39
+ },
40
+ "translation_en_to_fr": {
41
+ "early_stopping": true,
42
+ "max_length": 300,
43
+ "num_beams": 4,
44
+ "prefix": "translate English to French: "
45
+ },
46
+ "translation_en_to_ro": {
47
+ "early_stopping": true,
48
+ "max_length": 300,
49
+ "num_beams": 4,
50
+ "prefix": "translate English to Romanian: "
51
+ }
52
+ },
53
+ "use_cache": true,
54
+ "vocab_size": 32128
55
+ }