mrm8488/bert-small2bert-small-finetuned-cnn_daily_mail-summarization

🤗 Hugging Face 来源summarizationapache-2.0494 MBother✓ 2 个校验和今天更新
一条命令提交

在你的模型文件夹旁边运行它。它会制作种子、将文件与 Hugging Face 比对,然后提交。你只需开始做种,并粘贴你账户中的密钥。它只读取你的文件,绝不修改。如果愿意,可以先阅读脚本。

curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo mrm8488/bert-small2bert-small-finetuned-cnn_daily_mail-summarization ./model-folder
需要做种者 →

Bert-small2Bert-small Summarization with 🤗EncoderDecoder Framework

This model is a warm-started BERT2BERT (small) model fine-tuned on the CNN/Dailymail summarization dataset.

The model achieves a 17.37 ROUGE-2 score on CNN/Dailymail's test dataset.

For more details on how the model was fine-tuned, please refer to this notebook.

Results on test set 📝

Metric # Value
ROUGE-2 17.37

Model in Action 🚀

from transformers import BertTokenizerFast, EncoderDecoderModel
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
tokenizer = BertTokenizerFast.from_pretrained('mrm8488/bert-small2bert-small-finetuned-cnn_daily_mail-summarization')
model = EncoderDecoderModel.from_pretrained('mrm8488/bert-small2bert-small-finetuned-cnn_daily_mail-summarization').to(device)

def generate_summary(text):
    # cut off at BERT max length 512
    inputs = tokenizer([text], padding="max_length", truncation=True, max_length=512, return_tensors="pt")
    input_ids = inputs.input_ids.to(device)
    attention_mask = inputs.attention_mask.to(device)

    output = model.generate(input_ids, attention_mask=attention_mask)

    return tokenizer.decode(output[0], skip_special_tokens=True)
  
text = "your text to be summarized here..."
generate_summary(text)

Created by Manuel Romero/@mrm8488 | LinkedIn

Made with ♥ in Spain