Pinecone is a vector database with broad functionality.本笔记展示如何使用与
Pinecone 向量数据库相关的功能。
设置
To use thePineconeSparseVectorStore you first need to install the partner package, as well as the other packages used throughout this notebook.
凭证
Create a new Pinecone account, or sign into your existing one, and create an API key to use in this notebook.初始化
Before initializing our vector store, let’s connect to a Pinecone index. If one named index_name doesn’t exist, it will be created.pinecone-sparse-english-v0, we initialize it like so:
管理向量存储
创建向量存储后,我们可以通过添加和删除不同的项目来与其交互。向向量存储添加项目
我们可以使用add_documents 函数向向量存储添加项目。
从向量存储删除项目
We can delete records from our vector store using thedelete method, providing it with a list of document IDs to delete.
查询向量存储
Once we have loaded our documents into the vector store we’re most likely ready to begin querying. There are various method for doing this in LangChain. First, we’ll see how to perform a simple vector search by querying ourvector_store directly via the similarity_search method:
source=="social":
"website" source. In our latter, filtered, query—this is no longer the case.
Similarity search and scores
We can also search while returning the similarity score in a list of(document, score) tuples. Where the document is a LangChain Document object containing our text content and metadata.
As a retriever
In our chains and agents we’ll often use the vector store as aVectorStoreRetriever. To create that, we use the as_retriever method:
invoke method:
用于检索增强生成
有关如何将此向量存储用于检索增强生成 (RAG) 的指南,请参阅以下部分:API 参考
For detailed documentation of all features and configurations head to the API reference: API reference Sparse Embeddings: API reference连接这些文档到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

