Prerequisites
Please fill in by replacing
[ ]with[x].
bert-as-service?README.md?README.md?System information
Some of this information can be collected via this script.
bert-as-service version: 1.5.0 Please replace
YOUR_SERVER_ARGSandYOUR_CLIENT_ARGSaccordingly. You can also write your own description for reproducing the issue.
I'm using this command to start the server:
bert-serving-start -model_dir PATH -num_worker=4
and calling the server via:
bc = BertClient()
bc.encode()
Then this issue shows up:
I'm giving list (about 135k sentences, it's a list of strings) as an argument to bc.encode. However, the system answer is AttributeError: "texts" must be "List[str]" and non-empty!
I replace all the occurences of '', ' ' and ' ' and so on in my list for a 'empty' string. However, it turned to be unsufficient.
What is considered to be "empty"? And may be there is a possibility of printing this "empty" sentence in except-branch?
Thank you in advance!
The current version behaves as follows:
for k in ([], [''], ['', ''], ['', []], ['\n', '\r\n'], ['', 's', 'ss'], ['s', 'ss'], ['', 2, 'ss'], [2, 'ss']):
print('%s\t%s' % (BertClient._is_valid_input(k), k))
False []
False ['']
False ['', '']
False ['', []]
False ['\n', '\r\n']
False ['', 's', 'ss']
True ['s', 'ss']
False ['', 2, 'ss']
False [2, 'ss']
But you are right, would be better to raise an error on the empty case. Mark it as enhancement and will fix it
fyi, this issue is fixed and available in 1.5.1, please do
pip install -U bert-serving-server bert-serving-client
Why not return np.zeros whenever input is empty?
Most helpful comment
Why not return np.zeros whenever input is empty?