Nepali Article Title Generator

This is a fine-tuned MBart model for generating titles (summaries) for Nepali articles. The model was fine-tuned on a Nepali summarization dataset and is designed to generate concise and relevant titles for given Nepali text.

Model Details

  • Model Type: MBart (Multilingual BART)
  • Fine-Tuned For: Nepali Article Title Generation
  • Languages: Nepali (ne_NP)
  • Model Size: Large
  • Training Dataset: Nepali Summarization Dataset (first 50,000 samples)
  • Fine-Tuning Framework: Hugging Face Transformers
  • Fine-Tuning Epochs: 3
  • Max Input Length: 512 tokens
  • Max Target Length: 128 tokens

How to Use

You can use this model to generate titles for Nepali articles. Below is an example of how to load and use the model.

Installation

First, install the required libraries:

pip install torch transformers
import torch
from transformers import MBartTokenizer, MBartForConditionalGeneration

# Load the fine-tuned model
MODEL_PATH = "Dragneel/nepali-article-title-generator" 
model = MBartForConditionalGeneration.from_pretrained(MODEL_PATH)
tokenizer = MBartTokenizer.from_pretrained(MODEL_PATH)

# Set the source and target language
tokenizer.src_lang = "ne_NP"
tokenizer.tgt_lang = "ne_NP"

# Define the input text
input_text = """
नेपालको पर्यटन उद्योगमा कोरोनाको प्रभावले गर्दा ठूलो मन्दी आएको छ। 
विश्वभर यात्रा प्रतिबन्ध लागू भएपछि नेपाल आउने पर्यटकको संख्या न्यून भएको छ। 
यसले गर्दा होटल, यातायात र अन्य पर्यटन सम्बन्धी व्यवसायमा ठूलो असर परेको छ। 
सरकारले पर्यटन उद्योगलाई बचाउन विभिन्न उपायहरू ल्याएको छ, तर अहिलेसम्म कुनै ठूलो सुधार देखिएको छैन।
"""

# Tokenize the input
inputs = tokenizer(
    input_text,
    return_tensors="pt",
    max_length=512,
    truncation=True,
    padding="max_length"
)

# Generate summary
model.eval()  # Set the model to evaluation mode
with torch.no_grad():
    output_ids = model.generate(
        inputs["input_ids"],
        max_length=128,  # Set the maximum length of the generated text
        num_beams=4,  # Beam search for better quality
        early_stopping=True
    )

# Decode the generated text
summary = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print("Generated Title:", summary)
Downloads last month
26
Safetensors
Model size
611M params
Tensor type
F32
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.

Model tree for Dragneel/nepali-article-title-generator

Finetuned
(25)
this model

Dataset used to train Dragneel/nepali-article-title-generator