Pinecone is a vector database with broad functionality.本笔记展示如何使用与
Pinecone 向量数据库相关的功能。
设置
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.
凭证
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 namedindex_name doesn’t exist, it will be created.
管理向量存储
创建向量存储后,我们可以通过添加和删除不同的项目来与其交互。向向量存储添加项目
我们可以使用add_documents 函数向向量存储添加项目。
从向量存储删除项目
查询向量存储
一旦创建了向量存储并添加了相关文档,您很可能希望在链或智能体运行期间对其进行查询。直接查询
可以按以下方式执行简单的相似度搜索:带分数的相似度搜索
您也可以进行带分数的搜索:其他搜索方法
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.转换为检索器进行查询
您还可以将向量存储转换为检索器,以便在链中更方便地使用。用于检索增强生成
有关如何将此向量存储用于检索增强生成 (RAG) 的指南,请参阅以下部分:API 参考
For detailed documentation of all features and configurations head to the API reference连接这些文档到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

