Use word embeddings for semantic search
masterCogDB supports word embeddings with SIMD-optimized similarity search using SimSIMD. You can load pre-trained embeddings, load from Gensim models, or add them manually to vertices. Once added, you can perform k-nearest neighbor searches or filter vertices based on similarity thresholds using the sim method.
from cog.torque import Graph
# Manual embedding addition
g = Graph("fruits")
g.put("orange", "type", "citrus")
g.put_embedding("orange", [0.9, 0.8, 0.2, 0.1])
# Find k-nearest neighbors
# Search within graph vertices
results = g.v().k_nearest("orange", k=2).all()
# Or search ALL embeddings directly
results = g.k_nearest("orange", k=2).all()