AI / LlamaIndex Interview Questions
How do you integrate a custom vector store like Pinecone or Chroma with LlamaIndex?
LlamaIndex integrates external vector stores through a thin wrapper class per provider, such as PineconeVectorStore or ChromaVectorStore, which implements a common interface so the rest of the framework doesn't need to know which backend is being used.
from llama_index.vector_stores.chroma import ChromaVectorStore from llama_index.core import VectorStoreIndex, StorageContext import chromadb chroma_client = chromadb.PersistentClient(path="./chroma_db") chroma_collection = chroma_client.get_or_create_collection("my_docs") vector_store = ChromaVectorStore(chroma_collection=chroma_collection) storage_context = StorageContext.from_defaults(vector_store=vector_store) index = VectorStoreIndex.from_documents( documents, storage_context=storage_context )
You wrap the provider's client in the matching vector store class, pass it into a StorageContext, and then build the index with that storage context. From then on, embeddings are written to and searched from that external store instead of LlamaIndex's default in-memory store, which is what makes the index durable and scalable beyond a single process.
More Related questions...