takanezawa commited on
Commit
ac3ea59
·
1 Parent(s): 4f6d751

サンプルハンドラーレスポンスを採用する

Browse files
__pycache__/handler.cpython-311.pyc ADDED
Binary file (1.85 kB). View file
 
handler.py CHANGED
@@ -8,7 +8,7 @@ class EndpointHandler():
8
  def __init__(self, path="./"):
9
  # load the optimized model
10
  # モデルの準備
11
- model = BGEM3FlagModel("./", use_fp16=False)
12
 
13
 
14
  def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
@@ -26,12 +26,12 @@ class EndpointHandler():
26
 
27
  sparse_embs = []
28
 
29
- result = self.model.encode(inputs, return_dense=False, return_sparse=True)
30
- sparse_vectors = result["lexical_weights"]
31
- for sparse_vector in sparse_vectors:
32
- sparse_values = [value for value in sparse_vector.values()]
33
- sparse_dimensions = [int(key) for key in sparse_vector.keys()]
34
- sparse_embs.append((sparse_values, sparse_dimensions))
35
 
36
  # pass inputs with all kwargs in data
37
  # if parameters is not None:
 
8
  def __init__(self, path="./"):
9
  # load the optimized model
10
  # モデルの準備
11
+ self.model = BGEM3FlagModel("./", use_fp16=False)
12
 
13
 
14
  def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
 
26
 
27
  sparse_embs = []
28
 
29
+ # result = self.model.encode(inputs, return_dense=False, return_sparse=True)
30
+ # sparse_vectors = result["lexical_weights"]
31
+ # for sparse_vector in sparse_vectors:
32
+ # sparse_values = [value for value in sparse_vector.values()]
33
+ # sparse_dimensions = [int(key) for key in sparse_vector.keys()]
34
+ # sparse_embs.append((sparse_values, sparse_dimensions))
35
 
36
  # pass inputs with all kwargs in data
37
  # if parameters is not None: