(self, ctx=mx.cpu(), dtype='float32', model='bert_12_768_12',
                 dataset_name='book_corpus_wiki_en_uncased', params_path=None,
                 max_seq_length=25, batch_size=256)
Encoding from BERT model.

        Parameters
        ----------
        ctx : Context.
            running BertEmbedding on which gpu device id.
        dtype: str
        data type to use for the model.
        model : str, default bert_12_768_12.
            pre-trained BERT model
        dataset_name : str, default book_corpus_wiki_en_uncased.
            pre-trained model dataset
        params_path: str, default None
            path to a parameters file to load instead of the pretrained model.
        max_seq_length : int, default 25
            max length of each sequence
        batch_size : int, default 256
            batch size
Encoding from BERT model.
Encoding from BERT model .
def __init__(self, ctx=mx.cpu(), dtype='float32', model='bert_12_768_12',
                 dataset_name='book_corpus_wiki_en_uncased', params_path=None,
                 max_seq_length=25, batch_size=256):
        """
        Encoding from BERT model.

        Parameters
        ----------
        ctx : Context.
            running BertEmbedding on which gpu device id.
        dtype: str
        data type to use for the model.
        model : str, default bert_12_768_12.
            pre-trained BERT model
        dataset_name : str, default book_corpus_wiki_en_uncased.
            pre-trained model dataset
        params_path: str, default None
            path to a parameters file to load instead of the pretrained model.
        max_seq_length : int, default 25
            max length of each sequence
        batch_size : int, default 256
            batch size
        """
        self.ctx = ctx
        self.dtype = dtype
        self.max_seq_length = max_seq_length
        self.batch_size = batch_size
        self.dataset_name = dataset_name
        if params_path is not None:
            # Don't download the pretrained models if we have a parameter path
            pretrained = False
        else:
            pretrained = True
        self.bert, self.vocab = gluonnlp.model.get_model(model,
                                                         dataset_name=self.dataset_name,
                                                         pretrained=pretrained,
                                                         ctx=self.ctx,
                                                         use_pooler=False,
                                                         use_decoder=False,
                                                         use_classifier=False)
        self.bert.cast(self.dtype)

        if params_path:
            logger.info('Loading params from %s', params_path)
            self.bert.load_parameters(params_path, ctx=ctx, ignore_extra=True)

        lower = 'uncased' in self.dataset_name

        self.tokenizer = BERTTokenizer(self.vocab, lower=lower)
        self.transform = BERTSentenceTransform(tokenizer=self.tokenizer,
                                               max_seq_length=self.max_seq_length,
                                               pair=False)
def __init__ ( self , ctx = mx . cpu ( ) , dtype = 'float32' , model = 'bert_12_768_12' , dataset_name = 'book_corpus_wiki_en_uncased' , params_path = None , max_seq_length = 25 , batch_size = 256 ) : self . ctx = ctx self . dtype = dtype self . max_seq_length = max_seq_length self . batch_size = batch_size self . dataset_name = dataset_name if params_path is not None : # Don't download the pretrained models if we have a parameter path pretrained = False else : pretrained = True self . bert , self . vocab = gluonnlp . model . get_model ( model , dataset_name = self . dataset_name , pretrained = pretrained , ctx = self . ctx , use_pooler = False , use_decoder = False , use_classifier = False ) self . bert . cast ( self . dtype ) if params_path : logger . info ( 'Loading params from %s' , params_path ) self . bert . load_parameters ( params_path , ctx = ctx , ignore_extra = True ) lower = 'uncased' in self . dataset_name self . tokenizer = BERTTokenizer ( self . vocab , lower = lower ) self . transform = BERTSentenceTransform ( tokenizer = self . tokenizer , max_seq_length = self . max_seq_length , pair = False )