osanseviero
commited on
Commit
•
d0fbae8
1
Parent(s):
62aef60
test
Browse files- README.md +103 -0
- config.json +34 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- spiece.model +3 -0
- tokenizer_config.json +1 -0
README.md
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: "eng"
|
3 |
+
tags:
|
4 |
+
- wikihow
|
5 |
+
- t5-small
|
6 |
+
- pytorch
|
7 |
+
- lm-head
|
8 |
+
- seq2seq
|
9 |
+
- t5
|
10 |
+
- pipeline:summarization
|
11 |
+
- summarization
|
12 |
+
datasets:
|
13 |
+
- Wikihow
|
14 |
+
widget:
|
15 |
+
- text: "Lack of fluids can lead to dry mouth, which is a leading cause of bad breath. Water
|
16 |
+
can also dilute any chemicals in your mouth or gut that are causing bad breath., Studies show that
|
17 |
+
eating 6 ounces of yogurt a day reduces the level of odor-causing compounds in the mouth. In
|
18 |
+
particular, look for yogurt containing the active bacteria Streptococcus thermophilus or
|
19 |
+
Lactobacillus bulgaricus., The abrasive nature of fibrous fruits and vegetables helps to clean
|
20 |
+
teeth, while the vitamins, antioxidants, and acids they contain improve dental health.Foods that can
|
21 |
+
be particularly helpful include:Apples — Apples contain vitamin C, which is necessary for health
|
22 |
+
gums, as well as malic acid, which helps to whiten teeth.Carrots — Carrots are rich in vitamin A,
|
23 |
+
which strengthens tooth enamel.Celery — Chewing celery produces a lot of saliva, which helps to
|
24 |
+
neutralize bacteria that cause bad breath.Pineapples — Pineapples contain bromelain, an enzyme that
|
25 |
+
cleans the mouth., These teas have been shown to kill the bacteria that cause bad breath and
|
26 |
+
plaque., An upset stomach can lead to burping, which contributes to bad breath. Don’t eat foods that
|
27 |
+
upset your stomach, or if you do, use antacids. If you are lactose intolerant, try lactase tablets.,
|
28 |
+
They can all cause bad breath. If you do eat them, bring sugar-free gum or a toothbrush and
|
29 |
+
toothpaste to freshen your mouth afterwards., Diets low in carbohydrates lead to ketosis — a state
|
30 |
+
in which the body burns primarily fat instead of carbohydrates for energy. This may be good for your
|
31 |
+
waistline, but it also produces chemicals called ketones, which contribute to bad breath.To stop the
|
32 |
+
problem, you must change your diet. Or, you can combat the smell in one of these ways:Drink lots of
|
33 |
+
water to dilute the ketones.Chew sugarless gum or suck on sugarless mints.Chew mint leaves."
|
34 |
+
- text: " Bring 1/2 cup water to the boil.Add the fresh or dried rosemary to the water.Remove
|
35 |
+
from the heat. Set aside for 1/2 an hour to infuse. Added flavour can be released by pressing down
|
36 |
+
on the rosemary leaves with a spoon. Add the pieces to the blender or food processor with the
|
37 |
+
elderflower cordial. Blend or process to a purée.,, Add the lemon or lime juice and stir to
|
38 |
+
combine., Add a cover and place in the freezer.After 2 hours, remove from the freezer and break up
|
39 |
+
with a fork. This helps the ice crystals to form properly.Continue doing this every hour until the
|
40 |
+
granita freezes properly. Scoop the granita into dessert bowls and serve. Garnish with a cucumber
|
41 |
+
curl or a small sprig of rosemary."
|
42 |
+
metrics:
|
43 |
+
- Rouge1: 31.2
|
44 |
+
- RougeL: 24.5
|
45 |
+
---
|
46 |
+
|
47 |
+
# Model name
|
48 |
+
Wikihow T5-small
|
49 |
+
|
50 |
+
## Model description
|
51 |
+
|
52 |
+
This is a T5-small model trained on Wikihow All data set. The model was trained for 3 epochs using a batch size of 16 and learning rate of 3e-4. Max_input_lngth is set as 512 and max_output_length is 150. Model attained a Rouge1 score of 31.2 and RougeL score of 24.5.
|
53 |
+
We have written a blog post that covers the training procedure. Please find it [here](https://medium.com/@priya.dwivedi/fine-tuning-a-t5-transformer-for-any-summarization-task-82334c64c81).
|
54 |
+
|
55 |
+
## Usage
|
56 |
+
|
57 |
+
```
|
58 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
59 |
+
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained("deep-learning-analytics/wikihow-t5-small")
|
61 |
+
model = AutoModelWithLMHead.from_pretrained("deep-learning-analytics/wikihow-t5-small")
|
62 |
+
|
63 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
64 |
+
model = model.to(device)
|
65 |
+
|
66 |
+
text = """"
|
67 |
+
Lack of fluids can lead to dry mouth, which is a leading cause of bad breath. Water
|
68 |
+
can also dilute any chemicals in your mouth or gut that are causing bad breath., Studies show that
|
69 |
+
eating 6 ounces of yogurt a day reduces the level of odor-causing compounds in the mouth. In
|
70 |
+
particular, look for yogurt containing the active bacteria Streptococcus thermophilus or
|
71 |
+
Lactobacillus bulgaricus., The abrasive nature of fibrous fruits and vegetables helps to clean
|
72 |
+
teeth, while the vitamins, antioxidants, and acids they contain improve dental health.Foods that can
|
73 |
+
be particularly helpful include:Apples — Apples contain vitamin C, which is necessary for health
|
74 |
+
gums, as well as malic acid, which helps to whiten teeth.Carrots — Carrots are rich in vitamin A,
|
75 |
+
which strengthens tooth enamel.Celery — Chewing celery produces a lot of saliva, which helps to
|
76 |
+
neutralize bacteria that cause bad breath.Pineapples — Pineapples contain bromelain, an enzyme that
|
77 |
+
cleans the mouth., These teas have been shown to kill the bacteria that cause bad breath and
|
78 |
+
plaque., An upset stomach can lead to burping, which contributes to bad breath. Don’t eat foods that
|
79 |
+
upset your stomach, or if you do, use antacids. If you are lactose intolerant, try lactase tablets.,
|
80 |
+
They can all cause bad breath. If you do eat them, bring sugar-free gum or a toothbrush and
|
81 |
+
toothpaste to freshen your mouth afterwards., Diets low in carbohydrates lead to ketosis — a state
|
82 |
+
in which the body burns primarily fat instead of carbohydrates for energy. This may be good for your
|
83 |
+
waistline, but it also produces chemicals called ketones, which contribute to bad breath.To stop the
|
84 |
+
problem, you must change your diet. Or, you can combat the smell in one of these ways:Drink lots of
|
85 |
+
water to dilute the ketones.Chew sugarless gum or suck on sugarless mints.Chew mint leaves.
|
86 |
+
"""
|
87 |
+
|
88 |
+
preprocess_text = text.strip().replace("\n","")
|
89 |
+
tokenized_text = tokenizer.encode(preprocess_text, return_tensors="pt").to(device)
|
90 |
+
|
91 |
+
summary_ids = model.generate(
|
92 |
+
tokenized_text,
|
93 |
+
max_length=150,
|
94 |
+
num_beams=2,
|
95 |
+
repetition_penalty=2.5,
|
96 |
+
length_penalty=1.0,
|
97 |
+
early_stopping=True
|
98 |
+
)
|
99 |
+
|
100 |
+
output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
101 |
+
|
102 |
+
print ("\n\nSummarized text: \n",output)
|
103 |
+
```
|
config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"T5ForConditionalGeneration"
|
4 |
+
],
|
5 |
+
"d_ff": 2048,
|
6 |
+
"d_kv": 64,
|
7 |
+
"d_model": 512,
|
8 |
+
"decoder_start_token_id": 0,
|
9 |
+
"dropout_rate": 0.1,
|
10 |
+
"eos_token_id": 1,
|
11 |
+
"initializer_factor": 1.0,
|
12 |
+
"is_encoder_decoder": true,
|
13 |
+
"layer_norm_epsilon": 1e-06,
|
14 |
+
"model_type": "t5",
|
15 |
+
"n_positions": 512,
|
16 |
+
"num_heads": 8,
|
17 |
+
"num_layers": 6,
|
18 |
+
"output_past": true,
|
19 |
+
"pad_token_id": 0,
|
20 |
+
"relative_attention_num_buckets": 32,
|
21 |
+
"save_step": 0,
|
22 |
+
"task_specific_params": {
|
23 |
+
"summarization": {
|
24 |
+
"early_stopping": true,
|
25 |
+
"length_penalty": 2.0,
|
26 |
+
"max_length": 200,
|
27 |
+
"min_length": 30,
|
28 |
+
"no_repeat_ngram_size": 3,
|
29 |
+
"num_beams": 4,
|
30 |
+
"prefix": "summarize: "
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"vocab_size": 32128
|
34 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9374d3f2ab7f758b7a00ea70b1ac2608aac13c67d37a7131987cc221b867dc23
|
3 |
+
size 242068027
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>", "additional_special_tokens": ["<extra_id_0>", "<extra_id_1>", "<extra_id_2>", "<extra_id_3>", "<extra_id_4>", "<extra_id_5>", "<extra_id_6>", "<extra_id_7>", "<extra_id_8>", "<extra_id_9>", "<extra_id_10>", "<extra_id_11>", "<extra_id_12>", "<extra_id_13>", "<extra_id_14>", "<extra_id_15>", "<extra_id_16>", "<extra_id_17>", "<extra_id_18>", "<extra_id_19>", "<extra_id_20>", "<extra_id_21>", "<extra_id_22>", "<extra_id_23>", "<extra_id_24>", "<extra_id_25>", "<extra_id_26>", "<extra_id_27>", "<extra_id_28>", "<extra_id_29>", "<extra_id_30>", "<extra_id_31>", "<extra_id_32>", "<extra_id_33>", "<extra_id_34>", "<extra_id_35>", "<extra_id_36>", "<extra_id_37>", "<extra_id_38>", "<extra_id_39>", "<extra_id_40>", "<extra_id_41>", "<extra_id_42>", "<extra_id_43>", "<extra_id_44>", "<extra_id_45>", "<extra_id_46>", "<extra_id_47>", "<extra_id_48>", "<extra_id_49>", "<extra_id_50>", "<extra_id_51>", "<extra_id_52>", "<extra_id_53>", "<extra_id_54>", "<extra_id_55>", "<extra_id_56>", "<extra_id_57>", "<extra_id_58>", "<extra_id_59>", "<extra_id_60>", "<extra_id_61>", "<extra_id_62>", "<extra_id_63>", "<extra_id_64>", "<extra_id_65>", "<extra_id_66>", "<extra_id_67>", "<extra_id_68>", "<extra_id_69>", "<extra_id_70>", "<extra_id_71>", "<extra_id_72>", "<extra_id_73>", "<extra_id_74>", "<extra_id_75>", "<extra_id_76>", "<extra_id_77>", "<extra_id_78>", "<extra_id_79>", "<extra_id_80>", "<extra_id_81>", "<extra_id_82>", "<extra_id_83>", "<extra_id_84>", "<extra_id_85>", "<extra_id_86>", "<extra_id_87>", "<extra_id_88>", "<extra_id_89>", "<extra_id_90>", "<extra_id_91>", "<extra_id_92>", "<extra_id_93>", "<extra_id_94>", "<extra_id_95>", "<extra_id_96>", "<extra_id_97>", "<extra_id_98>", "<extra_id_99>"]}
|
spiece.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d60acb128cf7b7f2536e8f38a5b18a05535c9e14c7a355904270e15b0945ea86
|
3 |
+
size 791656
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"model_max_length": 512}
|