Browse Source
Update code
Signed-off-by: shiyu22 <shiyu.chen@zilliz.com>
main
2 changed files with
2 additions and
2 deletions
-
README.md
-
faiss.py
|
|
@ -27,7 +27,7 @@ from towhee.dc2 import pipe, ops |
|
|
|
|
|
|
|
p = pipe.input('vec') \ |
|
|
|
.flat_map('vec', 'rows', ops.ann_search.faiss(findex='index.bin')) \ |
|
|
|
.map('rows', ('id', 'score'), lambda x: (x[0], x[1], x[2])) \ |
|
|
|
.map('rows', ('id', 'score'), lambda x: (x[0], x[1])) \ |
|
|
|
.output('id', 'score') |
|
|
|
|
|
|
|
p(<your-vector>) |
|
|
|
|
|
@ -57,7 +57,7 @@ class Faiss(PyOperator): |
|
|
|
k = self.kv_storage.get(ids[i]) |
|
|
|
else: |
|
|
|
k = ids[i] |
|
|
|
result.extend([k, scores[0][i]]) |
|
|
|
result.append([k, scores[0][i]]) |
|
|
|
# result.append(Entity(**{'key': k, 'score': scores[0][i]})) |
|
|
|
return result |
|
|
|
|
|
|
|