takanezawa commited on
Commit
9aae34a
·
1 Parent(s): 0d6d4f8

dense_vecsの初期化を行う

Browse files
__pycache__/handler.cpython-311.pyc CHANGED
Binary files a/__pycache__/handler.cpython-311.pyc and b/__pycache__/handler.cpython-311.pyc differ
 
handler.py CHANGED
@@ -24,8 +24,10 @@ class EndpointHandler():
24
  inputs = data.pop("inputs", data)
25
  parameters = data.pop("parameters", None)
26
 
27
- result = self.model.encode(inputs, return_dense=False, return_sparse=True)
28
- sparse_vectors = result["lexical_weights"]
 
 
29
  # defaultdict(<class 'int'>, {'6': 0.09546, '192661': 0.3323})
30
 
31
  # pass inputs with all kwargs in data
@@ -36,10 +38,10 @@ class EndpointHandler():
36
  # postprocess the prediction
37
 
38
  # レスポンスをの型をkey=str, value=floatのdictにする。なお、numpy.float16はjsonに変換できないので、floatに変換する。
39
- sparse_vectors = {str(k): float(v) for k, v in sparse_vectors.items()}
40
 
41
  return [
42
  [
43
- { "outputs": sparse_vectors}
44
  ]
45
  ]
 
24
  inputs = data.pop("inputs", data)
25
  parameters = data.pop("parameters", None)
26
 
27
+ result = self.model.encode(inputs, return_dense=True, return_sparse=False)
28
+ # print(result)
29
+ dense_vectors = result["dense_vecs"]
30
+ # sparse_vectors = result["lexical_weights"]
31
  # defaultdict(<class 'int'>, {'6': 0.09546, '192661': 0.3323})
32
 
33
  # pass inputs with all kwargs in data
 
38
  # postprocess the prediction
39
 
40
  # レスポンスをの型をkey=str, value=floatのdictにする。なお、numpy.float16はjsonに変換できないので、floatに変換する。
41
+ # sparse_vectors = {str(k): float(v) for k, v in sparse_vectors.items()}
42
 
43
  return [
44
  [
45
+ { "outputs": dense_vectors}
46
  ]
47
  ]