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