Downloads · 30 days
565
1% of all-time downloads
nafisehNik/mt5-persian-summary
mt5-persian-summary is a summarization model from nafisehNik. Use it when you need a shorter version of a longer text. It is set up for transformers. The card lists the license as mit.
This model is fine-tuned to generate summaries based on the input provided. It has been fine-tuned on a wide range of Persian news data, including BBC news and pnsummary.
Downloads · 30 days
565
1% of all-time downloads
All-time downloads
109K
Public
Repo size
3.6 GB
Likes
7
Public
Click a slice to open those files.
.bin1.2 GB · 100%
From the Hugging Face model README
This model is fine-tuned to generate summaries based on the input provided. It has been fine-tuned on a wide range of Persian news data, including BBC news and pn_summary.
from transformers import AutoModelForSeq2SeqLM, MT5Tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained('nafisehNik/mt5-persian-summary')
tokenizer = MT5Tokenizer.from_pretrained("nafisehNik/mt5-persian-summary")
# method for summary generation, using the global model and tokenizer
def generate_summary(model, abstract, num_beams = 2, repetition_penalty = 1.0,
length_penalty = 2.0, early_stopping = True, max_output_length = 120):
source_encoding=tokenizer(abstract, max_length=1000, padding="max_length", truncation=True, return_attention_mask=True, add_special_tokens=True, return_tensors="pt")
generated_ids=model.generate(
input_ids=source_encoding["input_ids"],
attention_mask=source_encoding["attention_mask"],
num_beams=num_beams,
max_length=max_output_length,
repetition_penalty=repetition_penalty,
length_penalty=length_penalty,
early_stopping=early_stopping,
use_cache=True
)
preds=[tokenizer.decode(gen_id, skip_special_tokens=True, clean_up_tokenization_spaces=True)
for gen_id in generated_ids]
return "".join(preds)
text = "YOUR INPUT TEXT"
result = generate_summary(model=model, abstract=text, num_beams=2, max_output_length=120)
If you find this model useful, make a link to the huggingface model.