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 withtext_key=only if the server is configured for another field. - Everything else is what LlamaIndex's
node_to_metadata_dictproduces: the node as JSON under_node_content,_node_type,ref_doc_id(also asdoc_idanddocument_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-storecollection 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_vector_stores_polign-0.1.0.tar.gz.
File metadata
- Download URL: llama_index_vector_stores_polign-0.1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
282d1f74b579c0bb7eb8a37833d55f57305259fce212c25feb7714f1f148ddfe
|
|
| MD5 |
ef7882964d9ef0ec163dca71910f0a7e
|
|
| BLAKE2b-256 |
8250813e60f366fd4f214cb18f41c7532283a485482432fe8410deccb1eeb11c
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llama_index_vector_stores_polign-0.1.0.tar.gz -
Subject digest:
282d1f74b579c0bb7eb8a37833d55f57305259fce212c25feb7714f1f148ddfe - Sigstore transparency entry: 2790956785
- Sigstore integration time:
-
Permalink:
Polign/polign@2167a1e35a10601bbc01882ce61ddf731f8c791e -
Branch / Tag:
refs/tags/llamaindex/v0.1.0 - Owner: https://github.com/Polign
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2167a1e35a10601bbc01882ce61ddf731f8c791e -
Trigger Event:
push
-
Statement type:
File details
Details for the file llama_index_vector_stores_polign-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_vector_stores_polign-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bbacf23eff0b84b3cc88abb803d1f7a88e3b9c4354538b7fdd3b266299e5dd1
|
|
| MD5 |
c1a9bd7b95d8eb5c9046d10605d00af2
|
|
| BLAKE2b-256 |
e7f95daa04f3bb4c5274f0bfbd3393e99c9637e83a948be6b46104026561ddeb
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llama_index_vector_stores_polign-0.1.0-py3-none-any.whl -
Subject digest:
7bbacf23eff0b84b3cc88abb803d1f7a88e3b9c4354538b7fdd3b266299e5dd1 - Sigstore transparency entry: 2790956835
- Sigstore integration time:
-
Permalink:
Polign/polign@2167a1e35a10601bbc01882ce61ddf731f8c791e -
Branch / Tag:
refs/tags/llamaindex/v0.1.0 - Owner: https://github.com/Polign
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2167a1e35a10601bbc01882ce61ddf731f8c791e -
Trigger Event:
push
-
Statement type: