Views
No views yet
mt5-small on a custom Persian dataset for the task of title generation. The model was trained for 4 epochs on a dataset containing 25,000 rows of Persian text, using an NVIDIA P100 GPU. It is designed to generate titles for Persian text, making it useful for applications such as summarizing articles, generating headlines, and creating titles for various text inputs.mt5-smalltransformers library as follows:1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
2
3# Load the tokenizer and model
4tokenizer = AutoTokenizer.from_pretrained("NLPclass/mt5-title-generation")
5model = AutoModelForSeq2SeqLM.from_pretrained("NLPclass/mt5-title-generation")
6
7# Example text in Persian
8input_text = "به گزارش ایمنا، در دیدار سوپر جام فوتبال روسیه زنیت سنپترزبورگ قهرمان رقابتهای لیگ و جام حذفی این کشور در حضور عدهای معدود از تماشاگران به دیدار لوکوموتیو مسکو نایب قهرمان لیگ روسیه رفت"
9inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
10outputs = model.generate(inputs.input_ids, max_length=50, num_beams=5, early_stopping=True)
11
12# Decode the generated title
13generated_title = tokenizer.decode(outputs[0], skip_special_tokens=True)
14print(generated_title)
15
16
17# Create a text generation pipeline
18title_generation_pipeline = pipeline("text-generation", model="NLPclass/mt5-title-generation")
19generated_title = title_generation_pipeline(input_text, max_length=50, num_beams=5, early_stopping=True)
20print(generated_title)
211@misc{NLPclass,
2 author = {NLPclass},
3 title = {Title Generation for Persian using Transformers},
4 year = {2024},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/NLPclass/mt5-title-generation}},
7}