Skip to main content
Pinecone is a vector database with broad functionality.
This notebook shows how to use functionality related to the Pinecone vector database.

Setup

To use the PineconeVectorStore you first need to install the partner package, as well as the other packages used throughout this notebook.
Migration note: if you are migrating from the 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.
If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

Initialization

Before initializing our vector store, let’s connect to a Pinecone index. If one named index_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 the add_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.