logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 8 months ago

ann-search

ANN Search Operator: Faiss

author: shiyu


Desription

Only for local test. If you want to use a vector database in a production environment, you can use Milvus(https://github.com/milvus-io/milvus).


Code Example

please insert data into faiss first.

Example

Write a same pipeline with explicit inputs/outputs name specifications:

from towhee import pipe, ops

p = pipe.input('vec')  \
    .flat_map('vec', 'rows', ops.ann_search.faiss('./data_dir', 5))  \
    .map('rows', ('id', 'score'), lambda x: (x[0], x[1]))  \
    .output('id', 'score')

p(<your-vector>)


Factory Constructor

Create the operator via the following factory method:

ops.ann_search.faiss_index('./data_dir', 5)


Parameters:

data_dir: str

The path to faiss index and meta data.


Interface

Parameters:

query: ndarray

Query embedding in Faiss


Returns: Entity

Return the results in Faiss with key and score.

More Resources

Jael Gu 18be6a3475 Add more resources 13 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 3 years ago
file-icon README.md
2.2 KiB
download-icon
Add more resources 8 months ago
file-icon __init__.py
113 B
download-icon
update 2 years ago
file-icon faiss_search.py
1.5 KiB
download-icon
update 2 years ago
file-icon requirements.txt
16 B
download-icon
update 2 years ago
file-icon result.png
56 KiB
download-icon
Add ann_search.faiss 3 years ago