Python client library for the NNext. A ⚡ blazingly fast, 🔍 nearest-neighbors vector search engine for building delightful ML apps
Project description
About
NNext is a
⚡ blazingly fast
📖 source-available [Elastic License 2.0]
🔍 nearest-neighbors vector search engine
Quick Start
Here’s a quick example showcasing how you can create an index, insert vectors/documents and search it on NNext.
Let’s begin by starting the NNext server via Docker:
docker run -p 6040:6040 -v/tmp/data:/data nnext/nnext:latest --data-dir /data --api-key=Hu52dwsas2AdxdE
We have a API Client in python only, but let’s use it for this example.
Install the Python client for NNext:
pip install nnext
We can now initialize the client and create a movies index:
import nnext
from nnext import _and, _eq, _gte, _in
nnclient = nnext.Client({
'api_key': 'Hu52dwsas2AdxdE',
'nodes': [{
'host': 'localhost',
'port': '6040'
}],
'connection_timeout_seconds': 2
})
Broadly speaking, you can create two types of indices
1. Simple indices
nnindex = client.index.create({
"name": "movies_simple",
"index_type": "approximated",
"dims": 768
})
You can simply insert vector embeddings into the index.
1. Compound indices
nnindex = client.index.create({
"name": "movies",
"schema": {
"id" : "string", #⬅ inferred primary key
"title" : "string",
"released_year" : "int32",
"genre" : "float",
"wikipage" : "string",
"plot" : "string",
"rating" : "float"
},
"index_type": "approximated",
"dims": 768
})
Now, let’s add a vector to the collection we just created:
vector = {
"id": "124",
"company_name": "Stark Industries",
"num_employees": 5215,
"country": "USA",
}
nnindex.documents.create(document)
Finally, let’s search for the document we just indexed:
q_filter = {
_and: [
{ "Release Year": { _gte: 2015 } },
{ "Genre": { _eq: "comedy" } },
{ "actors": { _in: ["Russell Crowe"] } }
]
}
client.collections['companies'].documents.search(search_parameters)
Contributing
Introduction
First off, 🙏🏾 thank you for considering contributing to nnext. We value community contributions!
How can you help?
You may already know what you want to contribute – a fix for a bug you encountered, or a new feature your team wants to use.
If you don’t know what to contribute, keep an open mind! Here’s some examples of helpful contributions that mean less work for you
Improving documentation
bug triaging
writing tutorials
Checkout guide to contributing to learn more.
Documentation
All NNext Server and Client documentation, including pynext integration articles and helpful recipes, can be found at:
FAQs
How does this differ from Faiss, ScaNN and Annoy?
First of all, NNext uses Faiss under the hood. The main thing to note about these software come as python packages installable via PIP or Conda. These libraries are very easy to use, from install to the API. However, while allowing you to quickly get started, they don’t allow for persistence, index growth or high availability. If your application goes down for whatever reason, so do your search indices and data.
How does this differ from Milvus?
Milvus is a large piece of software, that takes non-trivial amount of effort to setup, administer, scale and fine-tune. It offers you a few thousand configuration parameters to get to your ideal configuration. So it’s better suited for large teams who have the bandwidth to get it production-ready, regularly monitor it and scale it, especially when they have a need to store billions of documents and petabytes of data (eg: logs).
NNext is built specifically for decreasing the “time to market” for a delightful nearest-neighbor search experience. It is a light-weight yet powerful & scaleable alternative that focuses on Developer Happiness and Experience with a clean well-documented API, clear semantics and smart defaults so it just works well out-of-the-box, without you having to turn many knobs.
See a side-by-side feature comparison here.
How does this differ other fully managed solutions like Pinecone?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for nnext-0.0.26-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab5b96c530fbf6ba819abc83a9fb03e9dbe189c7a427f2ac9b6c05864978b508 |
|
MD5 | 74004b75e64f076e1131bf8bd32378e7 |
|
BLAKE2b-256 | 370c70bc65c32968ec9c6bcb51194f8c27ed8643a3c73414f4fafc2a2c55629f |