@_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)
您好: 对于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