Vector and matrix operations built for embeddings and numeric analysis. Cosine similarity, distance metrics, subspace projection, k-means clustering, SVD, and PCA — the heavy decompositions run in native Rust, and every result is deterministic with no AI premium.
Embeddings are everywhere — semantic search, RAG, clustering, dedup — but comparing and reducing them means real linear algebra, not something an LLM can eyeball. Linalg tools give an agent exact cosine similarity for nearest-neighbour ranking, honest distance metrics, and SVD-backed PCA for dimensionality reduction. The math is identical across runs, and the expensive decompositions (SVD, PCA) are computed in a native Rust NIF rather than the model's head.
top_k), or a full pairwise matrix
k always yield the same clusters, centroids, sizes, and inertia
k truncation
cosine_sim + top_k, entirely server-side
pca to 2–3 components for plotting or to compress features before downstream modeling
cluster assignments
svd for low-rank approximation, rank estimation, and matrix factorization
// Rank documents against a query embedding (semantic nearest-neighbour) { "name": "data-grout@1/linalg.cosine_sim@1", "arguments": { "matrix": "$embeddings.vectors", "query": [0.12, -0.04, 0.88], "top_k": 5 } } // Reduce high-dimensional embeddings to their top 2 principal components { "name": "data-grout@1/linalg.pca@1", "arguments": { "vectors": "$embeddings.vectors", "k": 2 } } // Cluster the reduced points into 4 groups (deterministic k-means) { "name": "data-grout@1/linalg.cluster@1", "arguments": { "vectors": "$pca.scores", "k": 4 } }
scores and similarity records are chart-ready — pass them to
prism.chart
to plot the reduced space.
Pull embeddings or numeric columns through Data
or Frame
tools, then rank, reduce, or cluster them here. Feed pca.scores
or the pairwise matrix into Prism Chart
for visualization, or pair with Math
for descriptive statistics on the projected components.