Word Prediction

See Medium article for a more in-depth explanation

Initialize a HappyWordPrediction object to perform word prediction.

Initialization Arguments:

  1. model_type (string): Specify the model name in all caps, such as “ROBERTA” or “ALBERT”
  2. model_name(string): below is a URL that contains potential models: MODELS
  3. use_auth_token (string): Specify the authentication token to load private models.
  4. trust_remote_code (bool): Allow for custom Python files to be used from the model_name location.

Note: For all Transformers, the masked token is “[MASK]”

We recommend using “HappyWordPrediction(“ALBERT”, “albert-xxlarge-v2”)” for the best performance

Example 4.0:

from happytransformer import HappyWordPrediction
# --------------------------------------#
happy_wp_distilbert = HappyWordPrediction("DISTILBERT", "distilbert-base-uncased")  # default
happy_wp_albert = HappyWordPrediction("ALBERT", "albert-base-v2")
happy_wp_bert = HappyWordPrediction("BERT", "bert-base-uncased")
happy_wp_roberta = HappyWordPrediction("ROBERTA", "roberta-base")
happy_wp_private_roberta = HappyWordPrediction("ROBERTA", "user-repo/roberta-base", use_auth_token="123abc")

Tutorials

Word prediction with training (DistilBERT, RoBERTa)


Table of contents