Downloads · 30 days
10
4% of all-time downloads
BEASTBOYJAY/my-fine-tuned-summarizer
my-fine-tuned-summarizer is a machine learning model from BEASTBOYJAY. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This is the model is used for making or generating summary of the provided paragraph.
Downloads · 30 days
10
4% of all-time downloads
All-time downloads
280
Public
Parameters
247M
990 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors990 MB · 100%
From the Hugging Face model README
This is the model is used for making or generating summary of the provided paragraph.
This model is fine-tuned on very small dataset can need more fine-tuning for better results.(Fine-tuned this model only for eductional purposes)
Use the code below to get started with the model.
from transformers import EncoderDecoderModel, BertTokenizer
class TextSummarizer:
def __init__(self, model_path, tokenizer_name="bert-base-uncased"):
self.tokenizer = BertTokenizer.from_pretrained(tokenizer_name)
self.model = EncoderDecoderModel.from_pretrained(model_path)
def summarize(self, text, max_input_length=512):
inputs = self.tokenizer(
text,
return_tensors="pt",
truncation=True,
padding="max_length",
max_length=max_input_length,
)
summary_ids = self.model.generate(
inputs["input_ids"],
attention_mask=inputs["attention_mask"],
decoder_start_token_id=self.tokenizer.cls_token_id,
max_length=128,
num_beams=4,
length_penalty=1.5,
no_repeat_ngram_size=1,
early_stopping=True,
)
summary = self.tokenizer.decode(summary_ids[0], skip_special_tokens=True)
return summary
if __name__ == "__main__":
summarizer = TextSummarizer(model_path="BEASTBOYJAY/my-fine-tuned-summarizer")
test_article = "Your article or paragraph"
summary = summarizer.summarize(test_article)
print("Generated Summary:", summary)