macanv / BERT-BiLSTM-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning And private Server services
https://github.com/macanv/BERT-BiLSMT-CRF-NER
4.71k stars 1.26k forks source link

您好,部署模型后,在预测时,对于句子对分类,应该如何组织输入结构? #345

Open goodluck4s opened 4 years ago

goodluck4s commented 4 years ago

您好: 对于bert做句子对的分类,一个sample有两个句子text_a和text_b,这样应该如何组织输入。 对于源码下面这个函数的texts参数

@_timeout def encode(self, texts, blocking=True, is_tokenized=False): """ Encode a list of strings to a list of vectors

    `texts` should be a list of strings, each of which represents a sentence.
    If `is_tokenized` is set to True, then `texts` should be list[list[str]],
    outer list represents sentence and inner list represent tokens in the sentence.
    Note that if `blocking` is set to False, then you need to fetch the result manually afterwards.

    .. highlight:: python
    .. code-block:: python

        with BertClient() as bc:
            # encode untokenized sentences
            bc.encode(['First do it',
                      'then do it right',
                      'then do it better'])

            # encode tokenized sentences
            bc.encode([['First', 'do', 'it'],
                       ['then', 'do', 'it', 'right'],
                       ['then', 'do', 'it', 'better']], is_tokenized=True)
LiuYi217 commented 4 years ago

同问