Standard embeddings flatten JSON into text, making critical field changes invisible to your vector database. StructVector separates "Evil Twins" with 99.9% accuracy.
{
"user_id": "u_8921",
"amount": 450.00,
"currency": "USD",
"signals": {
"ip_risk": "low",
"kyc": true
},
"meta": { ...noise... }
}
{
"user_id": "u_8921",
"amount": 450.00,
"currency": "USD",
"signals": {
"ip_risk": "low",
"kyc": false
},
"meta": { ...noise... }
}
We used t-SNE to visualize the embedding space of 100 "Safe" events and their corresponding "Fraud" clones.
While standard models collapse these distinct events into a single point, StructVector learns a Structure-Aware Manifold. It physically pushes urgent field changes away from the baseline, creating distinct clusters for anomaly detection.
import structvector as sv # 1. Define your schema priorities schema = sv.Schema({ "prediction.label": "urgent", # 10x weight "transaction.amount": "high", # 5x weight "meta.processingTime": "none" # Ignored }) # 2. Initialize the adapter (runs on CPU) embedder = sv.StructEmbedder(model_path="fraud_v1.pth") # 3. Generate structure-aware vectors vector = embedder.encode({ "id": "tx_123", "amount": 5000, "label": "fraud" }, schema) print(vector.shape) # (512,)
Runs on any hardware. No GPU required.
View on GitHub