Edit model card

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

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.

Downloads last month
167
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Model tree for nafisehNik/mt5-persian-summary

Finetunes
1 model

Datasets used to train nafisehNik/mt5-persian-summary

Space using nafisehNik/mt5-persian-summary 1