Skip to main content

llama-index-vector-stores-polign

LlamaIndex vector store for polign_db.

pip install llama-index-vector-stores-polign

Usage

from llama_index.core import StorageContext, VectorStoreIndex
from llama_index.vector_stores.polign import PolignVectorStore

store = PolignVectorStore(
    collection_name="docs",
    url="http://localhost:23000",   # api_key="plgn_..." when the server requires one
)
storage_context = StorageContext.from_defaults(vector_store=store)
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)

retriever = index.as_retriever(similarity_top_k=5)
retriever.retrieve("what purrs?")

index.delete_ref_doc("document-id")          # removes every chunk of that document

# reopen later without re-indexing
index = VectorStoreIndex.from_vector_store(store)

Collections are created on the first write and take their dimension from the first embedding. Pass client= with an existing polign.Client or polign.GrpcClient to reuse a connection or use the gRPC transport (pip install "llama-index-vector-stores-polign[grpc]").

Metadata filters

MetadataFilters translate to polign's filter language. Supported operators: EQ, NE, GT, GTE, LT, LTE, IN, NIN, ANY, ALL, CONTAINS, IS_EMPTY, with AND, OR, and NOT conditions and nesting. TEXT_MATCH is not supported. query.doc_ids and query.node_ids are honored.

from llama_index.core.vector_stores.types import MetadataFilter, MetadataFilters, FilterOperator

retriever = index.as_retriever(
    similarity_top_k=5,
    filters=MetadataFilters(filters=[
        MetadataFilter(key="lang", value="en"),
        MetadataFilter(key="year", value=2024, operator=FilterOperator.GTE),
    ]),
)

Query modes

Mode What runs
DEFAULT vector search; similarity is 1 / (1 + d) for L2 collections, 1 - d for cosine
TEXT_SEARCH, SPARSE BM25 over the node text; similarity is the BM25 score
HYBRID vector plus BM25 fused server-side; linear with alpha when set, reciprocal rank fusion otherwise
MMR re-ranks the similarity_top_k * mmr_prefetch_factor nearest nodes with mmr_threshold

Pass similarity_fn= to the constructor to change the distance mapping. ef, cold, nprobe, and rescore given as extra query kwargs go to polign.Client.search unchanged.

Text and hybrid modes need a server with a segment store (polign-server -store ...); an in-memory server raises polign.InvalidArgumentError. The BM25 index is built when the server persists a segment, so nodes take part in lexical search only after the next segment is written and the searchers refresh, about half a minute with default settings. Vector search sees writes immediately.

How nodes are stored

  • The polign record id is the node id, also stored under _node_id.
  • The node text lives in the metadata key text, the field the server's BM25 index reads by default. Change it with text_key= only if the server is configured for another field.
  • Everything else is what LlamaIndex's node_to_metadata_dict produces: the node as JSON under _node_content, _node_type, ref_doc_id (also as doc_id and document_id), and the node's metadata at the top level so it can be filtered on. Top-level values polign cannot store (nested objects, None) are JSON-encoded there; the node itself is unaffected.

Limits

  • clear() deletes every record; dropping the collection itself needs the server's -byo-store collection API.
  • Async methods run the synchronous client in a worker thread.
  • Writes are sent in batches of up to 5,000 records, the server's limit.

Development

pip install -e ".[grpc]" pytest pytest-asyncio
pytest                      # boots a polign-server; see tests/conftest.py

License

Apache License 2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_vector_stores_polign-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_vector_stores_polign-0.1.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_vector_stores_polign-0.1.0.tar.gz
Algorithm Hash digest
SHA256 282d1f74b579c0bb7eb8a37833d55f57305259fce212c25feb7714f1f148ddfe
MD5 ef7882964d9ef0ec163dca71910f0a7e
BLAKE2b-256 8250813e60f366fd4f214cb18f41c7532283a485482432fe8410deccb1eeb11c

See more details on using hashes here.

Provenance

The following attestation bundles were made for llama_index_vector_stores_polign-0.1.0.tar.gz:

Publisher: python-publish.yml on Polign/polign

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llama_index_vector_stores_polign-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_vector_stores_polign-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bbacf23eff0b84b3cc88abb803d1f7a88e3b9c4354538b7fdd3b266299e5dd1
MD5 c1a9bd7b95d8eb5c9046d10605d00af2
BLAKE2b-256 e7f95daa04f3bb4c5274f0bfbd3393e99c9637e83a948be6b46104026561ddeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for llama_index_vector_stores_polign-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on Polign/polign

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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