This guide documents the current Python API surface for iris-vector-graph v1.28.0.
pip install iris-vector-graph
pip install iris-vector-graph[full]
pip install iris-vector-graph[plaid]- Core (
iris-vector-graph): minimal install, includesintersystems-irispython. [full]: adds FastAPI/GraphQL and common data tooling.[plaid]: addsnumpy+scikit-learnforplaid_build().
Canonical connection pattern:
import iris
conn = iris.connect(
hostname="localhost",
port=1972,
namespace="USER",
username="_SYSTEM",
password="SYS",
)from iris_vector_graph.engine import IRISGraphEngine
engine = IRISGraphEngine(
conn,
embedding_dimension=768, # required before initialize_schema()
embedder=None, # optional
embedding_config=None, # optional IRIS EMBEDDING() config name
)engine.initialize_schema(auto_deploy_objectscript=True)
engine.create_node(
node_id="node:1",
labels=["Entity"],
properties={"name": "Example"},
)
engine.create_edge(
source_id="node:1",
predicate="RELATED_TO",
target_id="node:2",
qualifiers={"confidence": 0.9},
)
node = engine.get_node("node:1")
nodes = engine.get_nodes(["node:1", "node:2"])
ok = engine.delete_node("node:2")
anchors = engine.get_kg_anchors(["E11.9", "J18.0"], bridge_type="icd10_to_mesh")initialize_schema()is idempotent and installs SQL schema/procedures.create_node(),create_edge(),delete_node()returnbool.get_node()returnsdict | None;get_nodes()returnslist[dict].get_kg_anchors()returns only bridge targets that exist in the KG.
Lightweight ANN index backed by ObjectScript globals (Graph.KG.VecIndex).
engine.vec_create_index("my_idx", dim=384, metric="cosine", num_trees=4, leaf_size=50)
engine.vec_insert("my_idx", "doc:1", [0.1, 0.2, 0.3])
engine.vec_bulk_insert("my_idx", [
{"id": "doc:2", "embedding": [0.2, 0.3, 0.4]},
{"id": "doc:3", "embedding": [0.3, 0.4, 0.5]},
])
engine.vec_build("my_idx")
hits = engine.vec_search("my_idx", [0.1, 0.2, 0.3], k=5, nprobe=8)
multi_hits = engine.vec_search_multi("my_idx", [[0.1, 0.2, 0.3], [0.3, 0.2, 0.1]], k=5, nprobe=8)
info = engine.vec_info("my_idx")
engine.vec_expand("my_idx", seed_id="doc:1", k=5)
engine.vec_drop("my_idx")vec_create_index(name, dim, metric="cosine", num_trees=4, leaf_size=50) -> dictvec_insert(index_name, doc_id, embedding) -> Nonevec_bulk_insert(index_name, items) -> int(items=[{"id","embedding"}, ...])vec_build(index_name) -> dictvec_search(index_name, query_embedding, k=10, nprobe=8) -> listvec_search_multi(index_name, query_embeddings, k=10, nprobe=8) -> listvec_info(index_name) -> dictvec_drop(index_name) -> Nonevec_expand(index_name, seed_id, k=5) -> list
ColBERT-style multi-vector retrieval (Graph.KG.PLAIDSearch).
docs = [
{"id": "doc:1", "tokens": [[0.1, 0.2], [0.3, 0.4]]},
{"id": "doc:2", "tokens": [[0.2, 0.1], [0.4, 0.3]]},
]
engine.plaid_build("plaid_idx", docs, n_clusters=None, dim=2)
results = engine.plaid_search("plaid_idx", query_tokens=[[0.1, 0.2], [0.3, 0.4]], k=10, nprobe=4)
engine.plaid_insert("plaid_idx", "doc:3", token_embeddings=[[0.5, 0.6], [0.7, 0.8]])
info = engine.plaid_info("plaid_idx")
engine.plaid_drop("plaid_idx")plaid_build(name, docs, n_clusters=None, dim=128) -> dictplaid_search(name, query_tokens, k=10, nprobe=4) -> listplaid_insert(name, doc_id, token_embeddings) -> Noneplaid_info(name) -> dictplaid_drop(name) -> None
plaid_build() requires [plaid] dependencies (numpy, scikit-learn).
from iris_vector_graph.operators import IRISGraphOperators
ops = IRISGraphOperators(conn)vec_hits = ops.kg_KNN_VEC('[0.1, 0.2, 0.3]', k=10, label_filter=None)
neighbors = ops.kg_NEIGHBORS(["doc:1", "doc:2"], predicate="MENTIONS", direction="out")
mentions = ops.kg_MENTIONS(["doc:1", "doc:2"]) # alias for MENTIONS neighborsglobal_pr = ops.kg_PAGERANK(damping=0.85, max_iterations=20)
personalized_pr = ops.kg_PAGERANK(seed_entities=["doc:1"], damping=0.85, max_iterations=20)kg_PAGERANK(seed_entities=None, ...):seed_entities=None-> global PageRankseed_entities=[...]-> personalized PageRank
wcc = ops.kg_WCC(max_iterations=100)
cdlp = ops.kg_CDLP(max_iterations=10)
sub = ops.kg_SUBGRAPH(seed_ids=["doc:1"], k_hops=2)
guided = ops.kg_PPR_GUIDED_SUBGRAPH(
seed_ids=["doc:1"],
alpha=0.15,
eps=1e-5,
top_k=50,
max_hops=5,
)Use execute_cypher() from IRISGraphEngine:
result = engine.execute_cypher(
"MATCH (n:Entity) RETURN n.id LIMIT 5",
parameters=None,
)result = engine.execute_cypher(
"MATCH p = (a)-[r]->(b) RETURN p, length(p), nodes(p), relationships(p)"
)result = engine.execute_cypher(
"MATCH (p:Protein) "
"CALL { WITH p MATCH (p)-[:INTERACTS_WITH]->(q) RETURN count(q) AS deg } "
"RETURN p.id, deg"
)# vector search
engine.execute_cypher(
"CALL ivg.vector.search('Gene', 'embedding', [0.1, 0.2], 5) "
"YIELD node, score RETURN node, score"
)
# 1-hop neighbors
engine.execute_cypher(
"CALL ivg.neighbors(['A','B'], 'MENTIONS', 'out') "
"YIELD neighbor RETURN neighbor"
)
# personalized PageRank
engine.execute_cypher(
"CALL ivg.ppr(['A','B'], 0.85, 20) "
"YIELD node, score RETURN node, score"
)execute_cypher() returns a dict with keys like columns, rows, sql, params, and metadata.
The engine supports optional Arno/NKG acceleration with automatic detection and fallback:
khop_result = engine.khop(seed="node:1", hops=2, max_nodes=500)
ppr_result = engine.ppr(seed="node:1", alpha=0.85, max_iter=20, top_k=20)
walks = engine.random_walk(seed="node:1", length=20, num_walks=10)Behavior:
- If
Graph.KG.NKGAccelis available and supports the algorithm, accelerated path is used. - If unavailable or an accelerated call errors, engine falls back to non-Arno paths.
- GraphQL support exists, but details are documented separately (see
README.mdandiris_vector_graph/gql/). - NetworkX and Pandas integrations exist in the project examples/tests.
- Performance benchmark details:
docs/performance/BENCHMARKS.mdandREADME.md.