zihangdai / xlnet

XLNet: Generalized Autoregressive Pretraining for Language Understanding
Apache License 2.0
6.18k stars 1.18k forks source link

Why there is not any usage example #176

Open Oxi84 opened 5 years ago

Oxi84 commented 5 years ago

I appreciate you hard work on the language models, but I do not really understand why there is not any code example how to predict a masked word or hidden states at least using pretrained models.

Lets say that I have a sentence such as "This is my sentence".
How do I predict distribution probability for word .

pseudocode:

  text = "This is my <mask> sentence". 
  tokens = tokenize(text)
 masked_index = 3 # for example
 model = something.load(modelfilename)
 predictions = model(tokens)
 logits_masked_index = predictions[masked_index]
hiwaveSupport commented 5 years ago

yes this is sorely missing - just simple example using pre-trained models.