PineconeEmbeddings访问。通过Pinecone服务提供文本嵌入。我们首先安装必要的依赖库:
embed_query将单段文本嵌入为查询嵌入(即RAG中用于搜索的内容):
官方原文:src/oss/python/integrations/embeddings/pinecone.mdx · 非官方翻译,译文由 AI 生成,以英文原文为准。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
使用 LangChain Python 集成 Pinecone 嵌入模型。
PineconeEmbeddings访问。通过Pinecone服务提供文本嵌入。我们首先安装必要的依赖库:
!pip install -qU "langchain-pinecone>=0.2.0"
import os
from getpass import getpass
os.environ["PINECONE_API_KEY"] = os.getenv("PINECONE_API_KEY") or getpass(
"Enter your Pinecone API key: "
)
from langchain_pinecone import PineconeEmbeddings
embeddings = PineconeEmbeddings(model="multilingual-e5-large")
embed_query将单段文本嵌入为查询嵌入(即RAG中用于搜索的内容):
docs = [
"Apple is a popular fruit known for its sweetness and crisp texture.",
"The tech company Apple is known for its innovative products like the iPhone.",
"Many people enjoy eating apples as a healthy snack.",
"Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces.",
"An apple a day keeps the doctor away, as the saying goes.",
]
doc_embeds = embeddings.embed_documents(docs)
doc_embeds
query = "Tell me about the tech company known as Apple"
query_embed = embeddings.embed_query(query)
query_embed
官方原文:src/oss/python/integrations/embeddings/pinecone.mdx · 非官方翻译,译文由 AI 生成,以英文原文为准。