File size: 1,657 Bytes
9eacb85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# WikiBert2WikiBert
Bert language models can be employed for Summarization tasks. WikiBert2WikiBert is an encoder-decoder transformer model that is initialized using the Persian WikiBert Model weights. The WikiBert Model is a Bert language model which is fine-tuned on Persian Wikipedia. After using the WikiBert weights for initialization, the model is trained for five epochs on PN-summary and Persian BBC datasets.
## How to Use:
You can use the code below to get the model's outputs, or you can simply use the demo on the right.
```
from transformers import (
BertTokenizerFast,
EncoderDecoderConfig,
EncoderDecoderModel,
BertConfig
)
model_name = 'Arashasg/WikiBert2WikiBert'
tokenizer = BertTokenizerFast.from_pretrained(model_name)
config = EncoderDecoderConfig.from_pretrained(model_name)
model = EncoderDecoderModel.from_pretrained(model_name, config=config)
def generate_summary(text):
inputs = tokenizer(text, padding="max_length", truncation=True, max_length=512, return_tensors="pt")
input_ids = inputs.input_ids.to("cuda")
attention_mask = inputs.attention_mask.to("cuda")
outputs = model.generate(input_ids, attention_mask=attention_mask)
output_str = tokenizer.batch_decode(outputs, skip_special_tokens=True)
return output_str
input = 'your input comes here'
summary = generate_summary(input)
```
---
language:
- fa
tags:
- Wikipedia
- Summarizer
- bert2bert
task_categories:
- summarization
- text generation
task_ids:
- news-articles-summarization
license:
- apache-2.0
multilinguality:
- monolingual
datasets:
- pn-summary
- XL-Sum
metrics:
- rouge-1
- rouge-2
- rouge-l
---
|