Update README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: `eng`"
|
| 3 |
+
thumbnail: "url to a thumbnail used in social sharing"
|
| 4 |
+
tags:
|
| 5 |
+
- wikihow
|
| 6 |
+
- t5-small
|
| 7 |
+
- pytorch
|
| 8 |
+
- lm-head
|
| 9 |
+
- seq2seq
|
| 10 |
+
- t5
|
| 11 |
+
- pipeline:summarization
|
| 12 |
+
- summarization
|
| 13 |
+
datasets:
|
| 14 |
+
- Wikihow
|
| 15 |
+
metrics:
|
| 16 |
+
- Rouge1: 31.2, RougeL: 24.5
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Model name
|
| 20 |
+
Wikihow T5-small
|
| 21 |
+
|
| 22 |
+
## Model description
|
| 23 |
+
|
| 24 |
+
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.
|
| 25 |
+
We have written a blog post that covers the training procedure. Please find it here.
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
```
|
| 30 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 31 |
+
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained("deep-learning-analytics/wikihow-t5-small")
|
| 33 |
+
model = AutoModelWithLMHead.from_pretrained("deep-learning-analytics/wikihow-t5-small")
|
| 34 |
+
|
| 35 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 36 |
+
model = model.to(device)
|
| 37 |
+
|
| 38 |
+
text = """"
|
| 39 |
+
Lack of fluids can lead to dry mouth, which is a leading cause of bad breath. Water
|
| 40 |
+
can also dilute any chemicals in your mouth or gut that are causing bad breath., Studies show that
|
| 41 |
+
eating 6 ounces of yogurt a day reduces the level of odor-causing compounds in the mouth. In
|
| 42 |
+
particular, look for yogurt containing the active bacteria Streptococcus thermophilus or
|
| 43 |
+
Lactobacillus bulgaricus., The abrasive nature of fibrous fruits and vegetables helps to clean
|
| 44 |
+
teeth, while the vitamins, antioxidants, and acids they contain improve dental health.Foods that can
|
| 45 |
+
be particularly helpful include:Apples — Apples contain vitamin C, which is necessary for health
|
| 46 |
+
gums, as well as malic acid, which helps to whiten teeth.Carrots — Carrots are rich in vitamin A,
|
| 47 |
+
which strengthens tooth enamel.Celery — Chewing celery produces a lot of saliva, which helps to
|
| 48 |
+
neutralize bacteria that cause bad breath.Pineapples — Pineapples contain bromelain, an enzyme that
|
| 49 |
+
cleans the mouth., These teas have been shown to kill the bacteria that cause bad breath and
|
| 50 |
+
plaque., An upset stomach can lead to burping, which contributes to bad breath. Don’t eat foods that
|
| 51 |
+
upset your stomach, or if you do, use antacids. If you are lactose intolerant, try lactase tablets.,
|
| 52 |
+
They can all cause bad breath. If you do eat them, bring sugar-free gum or a toothbrush and
|
| 53 |
+
toothpaste to freshen your mouth afterwards., Diets low in carbohydrates lead to ketosis — a state
|
| 54 |
+
in which the body burns primarily fat instead of carbohydrates for energy. This may be good for your
|
| 55 |
+
waistline, but it also produces chemicals called ketones, which contribute to bad breath.To stop the
|
| 56 |
+
problem, you must change your diet. Or, you can combat the smell in one of these ways:Drink lots of
|
| 57 |
+
water to dilute the ketones.Chew sugarless gum or suck on sugarless mints.Chew mint leaves.
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
preprocess_text = text.strip().replace("\n","")
|
| 61 |
+
tokenized_text = tokenizer.encode(preprocess_text, return_tensors="pt").to(device)
|
| 62 |
+
|
| 63 |
+
summary_ids = model.generate(
|
| 64 |
+
tokenized_text,
|
| 65 |
+
max_length=150,
|
| 66 |
+
num_beams=2,
|
| 67 |
+
repetition_penalty=2.5,
|
| 68 |
+
length_penalty=1.0,
|
| 69 |
+
early_stopping=True
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 73 |
+
|
| 74 |
+
print ("\n\nSummarized text: \n",output)
|
| 75 |
+
```
|