Pinecone is a vector database with broad functionality.This notebook shows how to use functionality related to the
Pinecone vector database.
Setup
To use thePineconeVectorStore you first need to install the partner package, as well as the other packages used throughout this notebook.
langchain_community.vectorstores implementation of Pinecone, you may need to remove your pinecone-client v2 dependency before installing langchain-pinecone, which relies on pinecone-client v6.
Credentials
Create a new Pinecone account, or sign into your existing one, and create an API key to use in this notebook.Initialization
Before initializing our vector store, let’s connect to a Pinecone index. If one namedindex_name doesn’t exist, it will be created.
Manage vector store
Once you have created your vector store, we can interact with it by adding and deleting different items.Add items to vector store
We can add items to our vector store by using theadd_documents function.
Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Similarity search with score
You can also search with score:Other search methods
There are more search methods (such as MMR) not listed in this notebook, to find all of them be sure to read the API reference.Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:API reference
For detailed documentation of all features and configurations head to the API reference: python.langchain.com/api_reference/pinecone/vectorstores/langchain_pinecone.vectorstores.PineconeVectorStore.htmlConnect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.