From 1dff06f18e4ab13d416db2ec5ab173cbcf325931 Mon Sep 17 00:00:00 2001 From: Larry Yan Date: Fri, 26 Jul 2019 13:50:58 +0800 Subject: [PATCH] fix(encoder): fix bug for encoder service dealing with empty doc --- gnes/service/encoder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gnes/service/encoder.py b/gnes/service/encoder.py index 168c42f8..45e42191 100644 --- a/gnes/service/encoder.py +++ b/gnes/service/encoder.py @@ -41,8 +41,9 @@ def _handler_index(self, msg: 'gnes_pb2.Message'): vecs = self._model.encode(chunks) s = 0 for d in msg.request.index.docs: - d.chunk_embeddings.CopyFrom(array2blob(vecs[s:(s + len(d.chunks))])) - s += len(d.chunks) + if len(d.chunks): + d.chunk_embeddings.CopyFrom(array2blob(vecs[s:(s + len(d.chunks))])) + s += len(d.chunks) @handler.register(gnes_pb2.Request.TrainRequest) def _handler_train(self, msg: 'gnes_pb2.Message'):