Skip to main content
Amazon Bedrock 是一项完全托管的服务,它通过单一 API 提供来自领先 AI 公司(如 AI21 LabsAnthropicCohereMetaStability AIAmazon)的高性能基础模型(FMs)选择,以及构建生成式 AI 应用程序所需的一系列广泛功能,这些功能具备安全性、隐私性和负责任的 AI。使用 Amazon Bedrock,您可以轻松地为您的用例试验和评估顶级基础模型,使用微调和 检索增强生成RAG)等技术私下使用您的数据对其进行自定义,并构建使用您的企业系统和数据源执行任务的代理。由于 Amazon Bedrock 是无服务器的,您无需管理任何基础设施,并且可以使用您已经熟悉的 AWS 服务安全地将生成式 AI 功能集成并部署到您的应用程序中。
pip install -qU  boto3
from langchain_aws import BedrockEmbeddings

embeddings = BedrockEmbeddings(
    credentials_profile_name="bedrock-admin", region_name="us-east-1"
)
embeddings.embed_query("This is a content of the document")
embeddings.embed_documents(
    ["This is a content of the document", "This is another document"]
)
# async embed query
await embeddings.aembed_query("This is a content of the document")
# async embed documents
await embeddings.aembed_documents(
    ["This is a content of the document", "This is another document"]
)