Retrieval-Augmented Generation (RAG) doesn't require sending your private documents to OpenAI or Pinecone. You can build a fully sovereign RAG pipeline using Python.
Instead of hitting an API to convert text to vectors, you can use local embedding models like nomic-embed-text (which can be run via Ollama) or models from Hugging Face's sentence-transformers library.
ChromaDB is a highly optimized, open-source vector database that can run completely in-memory or save to your local file system, requiring zero cloud infrastructure.
import chromadb
from chromadb.utils import embedding_functions
# Initialize local persistent ChromaDB
client = chromadb.PersistentClient(path="./local_vectors")
# Use a local embedding model
emb_fn = embedding_functions.DefaultEmbeddingFunction()
collection = client.create_collection(
name="private_docs",
embedding_function=emb_fn
)
collection.add(
documents=["The launch code is 1234", "The server IP is 192.168.1.100"],
ids=["doc1", "doc2"]
)
# Query the local database
results = collection.query(
query_texts=["What is the launch code?"],
n_results=1
)
print(results)