From b7994ed26a1950e9dc0c882bb2ada1e113ad2a0f Mon Sep 17 00:00:00 2001 From: shiyu22 Date: Fri, 10 Feb 2023 11:40:19 +0800 Subject: [PATCH] Update code Signed-off-by: shiyu22 --- README.md | 4 +--- faiss.py | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7cb4061..b2dc103 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,9 @@ p = pipe.input('vec') \ .map('rows', ('id', 'score'), lambda x: (x[0], x[1], x[2])) \ .output('id', 'score') -p('cat') +p() ``` - -
diff --git a/faiss.py b/faiss.py index b222a25..d14b038 100644 --- a/faiss.py +++ b/faiss.py @@ -2,12 +2,13 @@ import numpy as np from pathlib import Path import faiss from towhee import register +from towhee.operator import PyOperator, SharedType from towhee.utils.thirdparty.faiss_utils import KVStorage # from towhee.functional.entity import Entity @register(output_schema=['result']) -class Faiss: +class Faiss(PyOperator): """ Search for embedding vectors in Faiss. Note that the index has data before searching, refer to DataCollection Mixin `to_faiss`. @@ -59,3 +60,7 @@ class Faiss: result.extend([k, scores[0][i]]) # result.append(Entity(**{'key': k, 'score': scores[0][i]})) return result + + @property + def shared_type(self): + return SharedType.NotShareable