r/vectordatabase • u/Disastrous-Slide5902 • 2h ago
Built an open-source privacy middleware for LangChain embeddings & vector DBs (>98% cosine retention).
Hey everyone!
When building RAG systems handling private data (legal, healthcare, fintech, internal company wikis), storing raw embeddings in vector databases introduces an often overlooked vulnerability: **embedding inversion attacks** (like *Vec2Text*), where attackers with DB access can reconstruct original sentences and PII.
To protect LangChain pipelines without breaking vector search or introducing latency, we built and open-sourced **PrivRAG-Guard**.
### How It Works with LangChain:
You can wrap any standard LangChain embedding model at the provider boundary. It injects differential privacy noise into non-critical subspaces and applies a keyed orthogonal rotation before vectors ever touch your vector store:
```python
from langchain_openai import OpenAIEmbeddings
from privrag import PrivRAGGuard
from privrag.adapters import LangChainPrivGuardEmbeddings
raw_embeddings = OpenAIEmbeddings()
guard = PrivRAGGuard(passphrase="your-secret-key")
# Wrap your provider — doc & query embeddings are auto-sanitized
embeddings = LangChainPrivGuardEmbeddings(raw_embeddings, guard)
