Skip to content

Instantly share code, notes, and snippets.

@sam-writer
Last active January 30, 2020 16:32
Show Gist options
  • Save sam-writer/9a4f9bd17d62ac5ea05ceb86926bbbc3 to your computer and use it in GitHub Desktop.
Save sam-writer/9a4f9bd17d62ac5ea05ceb86926bbbc3 to your computer and use it in GitHub Desktop.
announcing-fitbert
from fitbert import FitBert
# currently supported models: bert-large-uncased and distilbert-base-uncased
# this takes a while and loads a whole big BERT into memory
fb = FitBert()
masked_string = "Why Bert, you're looking ***mask*** today!"
options = ['buff', 'handsome', 'strong']
ranked_options = fb.rank(masked_string, options=options)
# >>> ['handsome', 'strong', 'buff']
# or
filled_in = fb.fitb(masked_string, options=options)
# >>> "Why Bert, you're looking handsome today!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment