>Amazon Bedrock 是一项完全托管的服务,提供多种高性能 > 来自领先 AI 公司的高性能基础模型 (FM),例如 AI21 Labs, Anthropic, Cohere, > Meta, Stability AI等 Amazon ,并通过单一 API 提供构建生成式 AI 应用所需的各种功能 > ,包括安全性、隐私性和负责任的 AI。使用 Amazon Bedrock, > ,您可以轻松尝试和评估顶级 FM 以找到适合您用例的模型,并通过以下方式私下自定义它们 > 使用您的数据,通过微调和 Retrieval Augmented Generation (RAG)等技术,并构建 > 通过您的企业系统和数据源执行任务的代理。由于 Amazon Bedrock is > 采用无服务器架构,您无需管理任何基础设施,并且可以安全地集成和部署 > 您已经熟悉的 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"]
)