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 2 years ago

ann-search

ANN Search Operator: Faiss

author: shiyu


Desription

Search embedding in Faiss, please make sure you have inserted data to Faiss before search.


Code Example

please insert data into faiss first.

Example

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

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]))  \
    .output('id', 'score')

p('cat')


Factory Constructor

Create the operator via the following factory method:

ann_search.faiss(findex)


Parameters:

findex: str or faiss.INDEX

The path to faiss index file or faiss index.


Interface

Parameters:

query: list

Query embeddings in Faiss


Returns: Entity

Return the results in Faiss with key and score.

shiyu22 ddca89490b Update code for dc2 6 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 3 years ago
file-icon README.md
1.0 KiB
download-icon
Update code for dc2 2 years ago
file-icon __init__.py
87 B
download-icon
Add ann_search.faiss 3 years ago
file-icon faiss.py
2.1 KiB
download-icon
Update code for dc2 2 years ago
file-icon requirements.txt
22 B
download-icon
Add ann_search.faiss 3 years ago
file-icon result.png
56 KiB
download-icon
Add ann_search.faiss 3 years ago