Oracle 云基础设施 (OCI) 数据科学服务
Oracle Cloud Infrastructure (OCI) 数据科学是一个完全托管、无服务器的平台,供数据科学团队在Oracle云基础设施中构建、训练和管理机器学习模型。
它提供AI快速操作功能,可用于在OCI数据科学中部署嵌入模型。AI快速操作面向希望快速利用AI能力的用户。它们旨在通过提供简化、无需编码且高效的基础模型操作环境,将基础模型的覆盖范围扩展到更广泛的用户群体。AI快速操作可从数据科学笔记本中访问。
关于如何在OCI数据科学中使用AI快速操作部署嵌入模型的详细文档可在此处此处和此处获取。
本笔记本说明如何在LlamaIndex中使用OCI的数据科学嵌入模型。
如果您在 Colab 上打开这个笔记本,您可能需要安装 LlamaIndex 🦙。
%pip install llama-index-embeddings-oci-data-science!pip install llama-index您还需要安装 oracle-ads SDK。
!pip install -U oracle-adsLlamaIndex 支持的认证方法与其他 OCI 服务使用的认证方法相同,遵循标准 SDK 认证方法,具体包括 API 密钥、会话令牌、实例主体和资源主体。更多详细信息可在此处查看。请确保具备访问 OCI 数据科学模型部署端点所需的策略。oracle-ads 有助于简化 OCI 数据科学内的认证流程。
import adsfrom llama_index.embeddings.oci_data_science import OCIDataScienceEmbedding
ads.set_auth(auth="security_token", profile="<replace-with-your-profile>")
embedding = OCIDataScienceEmbedding( endpoint="https://<MD_OCID>/predict",)
e1 = embeddings.get_text_embedding("This is a test document")print(e1)
e2 = embeddings.get_text_embedding_batch( ["This is a test document", "This is another test document"])print(e2)import adsfrom llama_index.embeddings.oci_data_science import OCIDataScienceEmbedding
ads.set_auth(auth="security_token", profile="<replace-with-your-profile>")
embedding = OCIDataScienceEmbedding( endpoint="https://<MD_OCID>/predict",)
e1 = await embeddings.aget_text_embedding("This is a test document")print(e1)
e2 = await embeddings.aget_text_embedding_batch( ["This is a test document", "This is another test document"])print(e2)