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

84 lines
2.2 KiB

# ANN Search Operator: Faiss
3 years ago
*author: shiyu*
<br />
## 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).
<br />
## Code Example
> please insert data into faiss first.
### Example
*Write a same pipeline with explicit inputs/outputs name specifications:*
```python
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>)
```
<br />
## Factory Constructor
Create the operator via the following factory method:
***ops.ann_search.faiss_index('./data_dir', 5)***
<br />
**Parameters:**
***data_dir:*** *str*
The path to faiss index and meta data.
<br />
## Interface
**Parameters:**
***query:*** *ndarray*
Query embedding in Faiss
<br />
**Returns:** *Entity*
Return the results in Faiss with `key` and `score`.
# More Resources
- [Zilliz Triumphed in Billion-Scale ANN Search Challenge of NeurIPS 2021 - Zilliz Newsroom; Zilliz Triumphed in Billion-Scale ANN Search Challenge of NeurIPS 2021](https://zilliz.com/news/zilliz-triumphed-Neurips-2021): Zilliz team has won the first place in the Disk-based ANN Search track in NeurIPS 2021. The performance of BBAnn developed by Zilliz research team peaked during the search in the SimSearchNet++ dataset.
- [What is Faiss (Facebook AI Similarity Search)? - Zilliz blog](https://zilliz.com/learn/faiss): Faiss (Facebook AI similarity search) is an open-source library for efficient similarity search of unstructured data and clustering of dense vectors.
- [What is approximate nearest neighbor search (ANNS)?](https://zilliz.com/glossary/anns): Learn how to use Approximate nearest neighbor search (ANNS) for efficient nearest-neighbor search in large datasets.
- [Setting Up With Facebook AI Similarity Search (FAISS) - Zilliz blog](https://zilliz.com/blog/set-up-with-facebook-ai-similarity-search-faiss): Here's your FAISS tutorial that helps you set up FAISS, get it up and running, and demonstrate its power through a sample search program.