Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from fitbert import FitBert
  2.  
  3.  
  4. # in theory you can pass a model_name and tokenizer, but currently only
  5. # bert-large-uncased and BertTokenizer are available
  6. # this takes a while and loads a whole big BERT into memory
  7. fb = FitBert()
  8.  
  9. masked_string = "Why Bert, you're looking ***mask*** today!"
  10. options = ['buff', 'handsome', 'strong']
  11.  
  12. ranked_options = fb.rank(masked_string, options=options)
  13. # >>> ['handsome', 'strong', 'buff']
  14. # or
  15. filled_in = fb.fitb(masked_string, options=options)
  16. # >>> "Why Bert, you're looking handsome today!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement