Urdu Paraphrasing Model
This repository contains a trained Urdu paraphrasing model based on the BERT-based encoder-decoder architecture. The model has been fine-tuned on the Urdu Paraphrase Dataset and can generate paraphrases for given input sentences in Urdu.
Model Description
The model is built using the Hugging Face Transformers library and is trained on the BERT-base-uncased model. It employs an encoder-decoder architecture where the BERT model serves as the encoder, and another BERT model is used as the decoder. The model is trained to generate paraphrases by reconstructing the input sentences.
Usage
To use the trained model for paraphrasing Urdu sentences, you can follow the steps below:
- Install the required dependencies by running the following command:
- Load the trained model using the Hugging Face Transformers library:
from transformers import EncoderDecoderModel, BertTokenizer
# Load the model and tokenizer
model = EncoderDecoderModel.from_pretrained("mwz/UrduParaphraseBERT")
tokenizer = BertTokenizer.from_pretrained("mwz/UrduParaphraseBERT")
def paraphrase_urdu_sentence(sentence):
input_ids = tokenizer.encode(sentence, padding="longest", truncation=True, max_length=512, return_tensors="pt")
generated_ids = model.generate(input_ids=input_ids, max_length=128, num_beams=4, no_repeat_ngram_size=2)
paraphrase = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
return paraphrase
sentence = "ایک مثالی روشنی کا مشہور نقطہ آبادی چھوٹی چھوٹی سڑکوں میں اپنے آپ کو خوشگوار کرسکتی ہے۔"
paraphrased_sentence = paraphrase_urdu_sentence(sentence)
print(paraphrased_sentence)
- Downloads last month
- 16
Inference API (serverless) has been turned off for this model.