bert2bert_cnn_daily_mail

patrickvonplaten

Introduction

The BERT2BERT model is a text summarization model fine-tuned on the CNN/DailyMail dataset. It is implemented using the 🤗EncoderDecoder framework and is designed to generate concise summaries of English text.

Architecture

This model uses a BERT encoder-decoder architecture, which is a transformer-based framework. It leverages the strengths of BERT for both encoding the input text and generating the output summary.

Training

The BERT2BERT model was fine-tuned on the CNN/DailyMail dataset, achieving a ROUGE-2 score of 18.22 on the test dataset. The model's performance metrics include ROUGE-1, ROUGE-2, ROUGE-L, ROUGE-LSUM, and loss values, which indicate its effectiveness in generating summaries.

Guide: Running Locally

To run the BERT2BERT model locally:

  1. Set Up Environment

    • Install the Hugging Face Transformers library and PyTorch.

      pip install transformers torch
      
  2. Load the Model

    • Use the Hugging Face Transformers library to load the model.

      from transformers import EncoderDecoderModel, BertTokenizer
      
      model = EncoderDecoderModel.from_pretrained("patrickvonplaten/bert2bert_cnn_daily_mail")
      tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
      
  3. Inference

    • Prepare your text data and run inference to generate summaries.

      inputs = tokenizer("Your input text here", return_tensors="pt", max_length=512, truncation=True)
      outputs = model.generate(inputs.input_ids, max_length=142, num_beams=4, early_stopping=True)
      summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
      
  4. Cloud GPUs

    • For faster processing, consider using cloud-based GPU services such as AWS EC2, Google Cloud Platform, or Azure for enhanced computational power.

License

The BERT2BERT model is licensed under the Apache 2.0 License, allowing for both personal and commercial use with proper attribution.

More Related APIs in Summarization