

# mT5 Persian Summary

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](https://huggingface.co/datasets/csebuetnlp/xlsum) and [pn_summary](https://huggingface.co/datasets/pn_summary).

## Usage

```python
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)
```


## Citation

If you find this model useful, make a link to the huggingface model.
{"language": "fa", "license": "mit", "tags": ["summarization"], "datasets": ["pn_summary", "csebuetnlp/xlsum"], "metrics": ["bleu", "rouge", "bertscore"], "widget": [{"text": "\u0628\u0647 \u06af\u0632\u0627\u0631\u0634 \u0634\u0627\u0646\u0627 \u0628\u0647 \u0646\u0642\u0644 \u0627\u0632 \u0634\u0631\u06a9\u062a \u067e\u0627\u0644\u0627\u06cc\u0634 \u06af\u0627\u0632 \u0634\u0647\u06cc\u062f \u0647\u0627\u0634\u0645\u06cc \u0646\u0698\u0627\u062f\u060c \u062c\u0645\u0639\u06cc \u0627\u0632 \u06a9\u0627\u0631\u0634\u0646\u0627\u0633\u0627\u0646\n\u0627\u06cc\u0646 \u067e\u0627\u0644\u0627\u06cc\u0634\u06af\u0627\u0647 \u0628\u0627 \u0647\u062f\u0641 \u0645\u0639\u0631\u0641\u06cc \u0645\u062d\u0635\u0648\u0644 \u06a9\u0648\u062f \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc \u0628\u0647 \u06a9\u0634\u0627\u0648\u0631\u0632\u0627\u0646 \u062f\u0631\n\u0634\u0627\u0646\u0632\u062f\u0647\u0645\u06cc\u0646 \u0646\u0645\u0627\u06cc\u0634\u06af\u0627\u0647 \u062a\u062e\u0635\u0635\u06cc \u06a9\u0634\u0627\u0648\u0631\u0632\u06cc\u060c \u062f\u0627\u0645\u060c \u0637\u06cc\u0648\u0631\u060c \u0645\u0627\u0634\u06cc\u0646 \u0622\u0644\u0627\u062a \u0648 \u0635\u0646\u0627\u06cc\u0639 \u0648\u0627\u0628\u0633\u062a\u0647 \u062f\u0631\n\u0627\u0631\u062f\u0628\u06cc\u0644 \u062d\u0636\u0648\u0631 \u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646\u062f \u0648 \u0628\u0647 \u0645\u0639\u0631\u0641\u06cc \u062f\u0633\u062a\u0627\u0648\u0631\u062f\u0647\u0627\u06cc \u0627\u06cc\u0646 \u0634\u0631\u06a9\u062a \u067e\u0631\u062f\u0627\u062e\u062a\u0646\u062f. \u0628\u0631 \u0627\u0633\u0627\u0633\n\u0627\u06cc\u0646 \u06af\u0632\u0627\u0631\u0634\u060c \u062f\u0634\u062a \u0645\u063a\u0627\u0646 \u0642\u0637\u0628 \u06a9\u0634\u0627\u0648\u0631\u0632\u06cc \u062f\u0631 \u0645\u0646\u0637\u0642\u0647 \u0627\u0631\u062f\u0628\u06cc\u0644 \u0627\u0633\u062a \u0648 \u0628\u06cc\u0634 \u0627\u0632 \u06f8\u06f5 \u0647\u0632\u0627\u0631 \u0647\u06a9\u062a\u0627\u0631\n\u0632\u0645\u06cc\u0646 \u06a9\u0634\u0627\u0648\u0631\u0632\u06cc \u062f\u0627\u0631\u062f \u06a9\u0647 \u0647\u0645\u0647 \u0622\u0646\u0647\u0627 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u06a9\u0648\u062f \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc \u062f\u0627\u0631\u0646\u062f\u060c\n\u0628\u0647 \u0647\u0645\u06cc\u0646 \u062f\u0644\u06cc\u0644\u060c \u06a9\u0627\u0631\u0634\u0646\u0627\u0633\u0627\u0646 \u067e\u0627\u0644\u0627\u06cc\u0634\u06af\u0627\u0647 \u06af\u0627\u0632 \u0647\u0627\u0634\u0645\u06cc \u0646\u0698\u0627\u062f \u062f\u0631 \u0631\u0627\u0633\u062a\u0627\u06cc \u062a\u0648\u0633\u0639\u0647 \u0628\u0627\u0632\u0627\u0631 \u0648\n\u0645\u0639\u0631\u0641\u06cc \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u062c\u0627\u0646\u0628\u06cc \u067e\u0627\u0644\u0627\u06cc\u0634\u06af\u0627\u0647 (\u06a9\u0648\u062f \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc) \u0628\u0647 \u0628\u0627\u0632\u0627\u0631 \u062f\u0627\u062e\u0644\u06cc \u062f\u0631 \u0627\u06cc\u0646\n\u0646\u0645\u0627\u06cc\u0634\u06af\u0627\u0647 \u062d\u0636\u0648\u0631 \u06cc\u0627\u0641\u062a\u0646\u062f. \u0634\u0631\u06a9\u062a \u062f\u0631 \u0627\u06cc\u0646 \u0646\u0645\u0627\u06cc\u0634\u06af\u0627\u0647 \u0633\u0628\u0628 \u0634\u062f \u062a\u0639\u062f\u0627\u062f \u0632\u06cc\u0627\u062f\u06cc \u0627\u0632 \u0628\u0627\u0632\u0631\u06af\u0627\u0646\u0627\u0646\n\u0627\u06cc\u0631\u0627\u0646\u06cc \u0641\u0639\u0627\u0644 \u062f\u0631 \u062d\u0648\u0632\u0647 \u06af\u0648\u06af\u0631\u062f \u0636\u0645\u0646 \u062f\u06cc\u062f\u0627\u0631 \u0627\u0632 \u063a\u0631\u0641\u0647 \u0634\u0631\u06a9\u062a \u067e\u0627\u0644\u0627\u06cc\u0634 \u06af\u0627\u0632 \u0634\u0647\u06cc\u062f \u0647\u0627\u0634\u0645\u06cc\n\u0646\u0698\u0627\u062f \u062e\u0648\u0627\u0633\u062a\u0627\u0631 \u062e\u0631\u06cc\u062f \u0645\u062d\u0635\u0648\u0644 \u06a9\u0648\u062f \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc \u0627\u06cc\u0646 \u0645\u062c\u062a\u0645\u0639 \u06af\u0627\u0632\u06cc \u0634\u0648\u0646\u062f. \u0634\u0631\u06a9\u062a\n\u067e\u0627\u0644\u0627\u06cc\u0634 \u06af\u0627\u0632 \u0634\u0647\u06cc\u062f \u0647\u0627\u0634\u0645\u06cc \u0646\u0698\u0627\u062f \u062f\u0631 \u06a9\u0646\u0627\u0631 \u0631\u0633\u0627\u0644\u062a \u0627\u0635\u0644\u06cc \u062e\u0648\u062f \u0645\u0628\u0646\u06cc \u0628\u0631 \u062a\u0627\u0645\u06cc\u0646 \u06af\u0627\u0632\n\u0645\u0634\u062a\u0631\u06a9\u0627\u0646 \u0634\u0645\u0627\u0644 \u0648 \u0634\u0645\u0627\u0644 \u0634\u0631\u0642 \u06a9\u0634\u0648\u0631\u060c \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u062c\u0627\u0646\u0628\u06cc \u0627\u0631\u0632\u0634\u0645\u0646\u062f \u0645\u0627\u0646\u0646\u062f \u06af\u0648\u06af\u0631\u062f \u0631\u0627 \u062a\u0648\u0644\u06cc\u062f\n\u0645\u06cc \u06a9\u0646\u062f\u060c \u0628\u0647 \u06af\u0648\u0646\u0647 \u0627\u06cc \u06a9\u0647 \u0627\u06a9\u0646\u0648\u0646 \u0628\u0627 \u062a\u0648\u0644\u06cc\u062f \u0631\u0648\u0632\u0627\u0646\u0647 \u0628\u06cc\u0634 \u0627\u0632 \u06f2 \u0647\u0632\u0627\u0631 \u062a\u0646 \u06af\u0648\u06af\u0631\u062f \u0645\u0630\u0627\u0628\u060c\n\u062a\u0648\u0644\u06cc\u062f \u0631\u0648\u0632\u0627\u0646\u0647 \u06f6\u06f0\u06f0 \u062a\u0646 \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc (\u0645\u0637\u0627\u0628\u0642 \u0646\u06cc\u0627\u0632 \u0628\u0627\u0632\u0627\u0631) \u0648 \u062a\u0648\u0644\u06cc\u062f \u0633\u0627\u0644\u0627\u0646\u0647 \u0628\u06cc\u0634\n\u0627\u0632 \u06f2\u06f0 \u0647\u0632\u0627\u0631 \u062a\u0646 \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc\u060c \u0628\u0632\u0631\u06af \u062a\u0631\u06cc\u0646 \u062a\u0648\u0644\u06cc\u062f\u06a9\u0646\u0646\u062f\u0647 \u06af\u0648\u06af\u0631\u062f \u062f\u0631 \u06a9\u0634\u0648\u0631 \u0627\u0633\u062a. \u06a9\u0648\u062f\n\u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc \u0646\u06cc\u0632 \u062f\u0631 \u0631\u0627\u0633\u062a\u0627\u06cc \u0627\u0631\u062a\u0642\u0627\u06cc \u06a9\u06cc\u0641\u06cc \u062e\u0627\u06a9 \u0648 \u062a\u0627\u0645\u06cc\u0646 \u0639\u0646\u0627\u0635\u0631 \u0645\u0648\u0631\u062f \u0646\u06cc\u0627\u0632 \u0631\u0634\u062f\n\u06af\u06cc\u0627\u0647\u0627\u0646 \u062a\u0627\u062b\u06cc\u0631\u06cc \u0628\u0633\u0632\u0627 \u062f\u0631 \u0628\u0627\u0632\u062f\u0647 \u062a\u0648\u0644\u06cc\u062f \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u06a9\u0634\u0627\u0648\u0631\u0632\u06cc \u062f\u0627\u0631\u062f. \u06a9\u0648\u062f \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc\n\u062a\u0648\u0644\u06cc\u062f\u06cc \u067e\u0627\u0644\u0627\u06cc\u0634\u06af\u0627\u0647 \u0647\u0627\u0634\u0645\u06cc \u0646\u0698\u0627\u062f\u060c \u0628\u0627 \u0627\u0633\u062a\u0627\u0646\u062f\u0627\u0631\u062f\u0647\u0627\u06cc \u062c\u0647\u0627\u0646\u06cc \u062a\u0648\u0644\u06cc\u062f \u0634\u062f\u0647 \u0648 \u062c\u0627\u06cc\u06af\u0627\u0647 \u062e\u0648\u062f\n\u0631\u0627 \u062f\u0631 \u0628\u0627\u0632\u0627\u0631\u0647\u0627\u06cc \u062f\u0627\u062e\u0644\u06cc \u0648 \u062e\u0627\u0631\u062c\u06cc \u06a9\u0633\u0628 \u06a9\u0631\u062f\u0647 \u0627\u0633\u062a. \u0645\u0637\u0627\u0628\u0642 \u0628\u0631\u0646\u0627\u0645\u0647 \u0631\u06cc\u0632\u06cc \u0647\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u0634\u062f\u0647\n\u0648 \u0628\u0631\u0631\u0633\u06cc \u0631\u0648\u0646\u062f \u0631\u0648 \u0628\u0647 \u0631\u0634\u062f \u0645\u0635\u0631\u0641 \u0627\u06cc\u0646 \u06a9\u0648\u062f \u062f\u0631 \u0628\u0627\u0632\u0627\u0631\u060c \u067e\u06cc\u0634 \u0628\u06cc\u0646\u06cc \u0645\u06cc \u0634\u0648\u062f \u0645\u06cc\u0632\u0627\u0646 \u0645\u0635\u0631\u0641\n\u06a9\u0648\u062f \u06af\u0648\u06af\u0631\u062f \u0628\u0646\u062a\u0648\u0646\u06cc\u062a\u06cc \u062a\u0627 \u067e\u0646\u062c \u0633\u0627\u0644 \u0622\u06cc\u0646\u062f\u0647 \u0628\u0647 \u06f1\u06f0\u06f0 \u0647\u0632\u0627\u0631 \u062a\u0646 \u062f\u0631 \u0633\u0627\u0644 \u0628\u0631\u0633\u062f.\t\n", "example_title": "Example 1"}]}
transformers pytorch mt5 text2text-generation summarization fa dataset:pn_summary dataset:csebuetnlp/xlsum license:mit autotrain_compatible endpoints_compatible has_space text-generation-inference region:us
TAGS
#transformers #pytorch #mt5 #text2text-generation #summarization #fa #dataset-pn_summary #dataset-csebuetnlp/xlsum #license-mit #autotrain_compatible #endpoints_compatible #has_space #text-generation-inference #region-us 



# mT5 Persian Summary

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.

## Usage




If you find this model useful, make a link to the huggingface model.
# mT5 Persian Summary

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. ## Usage




If you find this model useful, make a link to the huggingface model.
TAGS
#transformers #pytorch #mt5 #text2text-generation #summarization #fa #dataset-pn_summary #dataset-csebuetnlp/xlsum #license-mit #autotrain_compatible #endpoints_compatible #has_space #text-generation-inference #region-us 
 # mT5 Persian Summary

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. ## Usage




If you find this model useful, make a link to the huggingface model.
passage: TAGS
#transformers #pytorch #mt5 #text2text-generation #summarization #fa #dataset-pn_summary #dataset-csebuetnlp/xlsum #license-mit #autotrain_compatible #endpoints_compatible #has_space #text-generation-inference #region-us 
# mT5 Persian Summary

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.## Usage




If you find this model useful, make a link to the huggingface model.