Skip to main content

llama-index-vector-stores-ngt

LlamaIndex vector store integration for NGT (Neighborhood Graph and Tree).

Installation

pip install llama-index-vector-stores-ngt

Parameters

NGTVectorStore accepts the following parameters:

  • index_path: Directory path where NGT persists its index.
  • dimension: Dimensionality of the vectors to be stored.
  • distance_type: Distance function. Default: "L2".
    • Available values: "L1", "L2", "Normalized L2", "Angle", "Normalized Angle", "Cosine", "Normalized Cosine", "Hamming", "Jaccard", "Inner Product".
  • edge_size_for_creation: Number of edges used when building the graph. Default: 10.
  • edge_size_for_search: Number of edges explored during search. Default: 40.
  • epsilon: Exploration range for approximate search. Larger values are more accurate but slower. Default: 0.1.

Usage

from llama_index.core import VectorStoreIndex, StorageContext
from llama_index.core.schema import TextNode
from llama_index.vector_stores.ngt import NGTVectorStore

vector_store = NGTVectorStore(
    index_path="ngt_index",
    dimension=128,
    distance_type="L2",
)

storage_context = StorageContext.from_defaults(vector_store=vector_store)

nodes = [
    TextNode(text="apple is red and sweet"),
    TextNode(text="banana is yellow and sweet"),
]

index = VectorStoreIndex(nodes, storage_context=storage_context)
retriever = index.as_retriever(similarity_top_k=2)
results = retriever.retrieve("yellow fruit")

for node in results:
    print(node.score, node.text)

Query options

  • similarity_top_k: Number of nearest neighbors to retrieve. Pass it to as_retriever() or as_query_engine().
  • epsilon: Override the exploration range for a single query. Set vector_store.epsilon before querying, or pass epsilon directly to vector_store.query().
  • edge_size: Override the search graph exploration size. Set vector_store.edge_size_for_search before querying, or pass edge_size directly to vector_store.query().

Persistence

Call persist() before exiting to save both the NGT index and LlamaIndex metadata.

vector_store.persist(persist_dir="ngt_index_persisted")

Later, or in another process, reopen the persisted index:

vector_store = NGTVectorStore(
    index_path="ngt_index_persisted",
    dimension=128,
    distance_type="L2",
)

storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex([], storage_context=storage_context)

results = index.as_retriever(similarity_top_k=2).retrieve("yellow fruit")

Use persist_dir="" to save into the original index_path instead.

Notes

  • NGT stores only vectors and integer IDs. Text and metadata are kept by the wrapper and serialised alongside the NGT index.
  • Metadata filtering is not supported by NGT itself. If you need it, pre-filter IDs on the Python side or combine with another metadata store.

Metadata

Release files for llama-index-vector-stores-ngt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-vector-stores-ngt 0.1.0
File Size Uploaded Provenance Actions
llama_index_vector_stores_ngt-0.1.0.tar.gz 6.1 kB Without provenance Details for llama_index_vector_stores_ngt-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-vector-stores-ngt 0.1.0
File Interpreter ABI Platform Actions
llama_index_vector_stores_ngt-0.1.0-py3-none-any.whl Python 3 none any Details for llama_index_vector_stores_ngt-0.1.0-py3-none-any.whl

Total release size: 13.1 kB

Release files / llama_index_vector_stores_ngt-0.1.0.tar.gz

Download URL llama_index_vector_stores_ngt-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18a9fb25ee50db61ff2fc2fc5c500b2d8e4622b77c432997afa922797b559e1b
BLAKE2b-256 checksum
How to use checksums
a1097e16a663e3ceeaec96c0f1a46e8327a483c1608f666a36e9fd34a2c4b878
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / llama_index_vector_stores_ngt-0.1.0-py3-none-any.whl

Download URL llama_index_vector_stores_ngt-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f27abc2f617836174c4e0d90c79711cfdefdd0882da76b86f30580d9b3d8f99
BLAKE2b-256 checksum
How to use checksums
cf5ea3c76c7957c2e6ecb16cc63cc54d84b1a16cb55fc6e4fcf480ebc218bdc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for llama-index-vector-stores-ngt 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page