Bedrock
Amazon Bedrock 是一项完全托管的服务,通过单一 API 提供来自领先人工智能公司(如
AI21 Labs、Anthropic、Cohere、Meta、Stability AI和Amazon)的高性能基础模型(FMs)选择,并提供构建具备安全性、隐私性和负责任人工智能的生成式 AI 应用所需的广泛功能。使用Amazon Bedrock,您可以轻松针对您的用例试验和评估顶级基础模型,利用微调和Retrieval Augmented Generation(RAG)等技术使用您的数据对其进行私有化定制,并构建能够利用您的企业系统和数据源执行任务的智能体。由于Amazon Bedrock采用无服务器架构,您无需管理任何基础设施,并且可以使用您早已熟悉的 AWS 服务,将生成式 AI 功能安全地集成和部署到您的应用中。
%pip install --upgrade --quiet boto3
from langchain_aws import BedrockEmbeddings
embeddings = BedrockEmbeddings(
credentials_profile_name="bedrock-admin", region_name="us-east-1"
)
API 参考:Bedrock 嵌入
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"]
)