Model Card for Hprophetnet-large

<!-- Provide a quick summary of what the model is/does. -->

This model is a fine-tuned version of all-mpnet-base-v2 on HP dataset to predict the popularity of the headlines. The input to the model is a headline and the ouput is a popularity score.

Intended uses & limitations

You can use this model to predict the popularity of the English-written headlines.

Usage

from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

model = AutoModelForSequenceClassification.from_pretrained(
    "omidvaramin/HeadlinePopularity", # We use the 12-layer BERT model, with an uncased vocab.
    num_labels = 1, # The number of output labels--1 for regression.   
    output_attentions = False, # Whether the model returns attentions weights.
    output_hidden_states = False, # Whether the model returns all hidden-states.
).cuda()
tokenizer = AutoTokenizer.from_pretrained("omidvaramin/HeadlinePopularity", do_lower_case=True)

HEADLINE = "Nigeria and Venezuela to Cut Oil Production"
encoded_dict = tokenizer.encode_plus(
                        HEADLINE,                      # Sentence to encode.
                        add_special_tokens = True, # Add '[CLS]' and '[SEP]'
                        max_length = 104,           # Pad & truncate all sentences.
                        pad_to_max_length = True,
                        return_attention_mask = True,   # Construct attn. masks.
                        return_tensors = 'pt',     # Return pytorch tensors.
                   )
    
input_id = encoded_dict['input_ids']
input_id = input_id.cuda() 
attention_mask = encoded_dict['attention_mask']
attention_mask = attention_mask.cuda()
  
with torch.no_grad():
    result = model(input_id, 
                        token_type_ids=None, 
                        attention_mask=attention_mask,
                        return_dict=True)
popularity = result.logits.data[0].item()
print("Popularity: ", popularity)
>>> Popularity:  0.5718647837638855

BibTeX entry and citation info

@ARTICLE{10154027,
  author={Omidvar, Amin and An, Aijun},
  journal={IEEE Access}, 
  title={Learning to Generate Popular Headlines}, 
  year={2023},
  volume={11},
  number={},
  pages={60904-60914},
  doi={10.1109/ACCESS.2023.3286853}}