跳到主要內容
Open In ColabOpen on GitHub

Alibaba Cloud PAI EAS

Alibaba Cloud 的 AI 機器學習平台 是一個專為企業和開發人員設計的機器學習或深度學習工程平台。它提供易於使用、經濟高效、高效能且易於擴展的外掛程式,可應用於各種產業情境。Machine Learning Platform for AI 內建超過 140 種最佳化演算法,提供全流程 AI 工程功能,包括資料標記 (PAI-iTAG)、模型建置 (PAI-DesignerPAI-DSW)、模型訓練 (PAI-DLC)、編譯最佳化和推論部署 (PAI-EAS)。PAI-EAS 支援不同類型的硬體資源,包括 CPU 和 GPU,並具有高輸送量和低延遲的特性。它讓您只需按幾下滑鼠即可部署大規模複雜模型,並即時執行彈性擴展和縮減。它還提供全面的 O&M 和監控系統。

##Installing the langchain packages needed to use the integration
%pip install -qU langchain-community
from langchain.chains import LLMChain
from langchain_community.llms.pai_eas_endpoint import PaiEasEndpoint
from langchain_core.prompts import PromptTemplate

template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate.from_template(template)

想要使用 EAS LLM 的使用者必須先設定 EAS 服務。啟動 EAS 服務後,即可取得 EAS_SERVICE_URLEAS_SERVICE_TOKEN。使用者可以參考 https://www.alibabacloud.com/help/en/pai/user-guide/service-deployment/ 以取得更多資訊。

import os

os.environ["EAS_SERVICE_URL"] = "Your_EAS_Service_URL"
os.environ["EAS_SERVICE_TOKEN"] = "Your_EAS_Service_Token"
llm = PaiEasEndpoint(
eas_service_url=os.environ["EAS_SERVICE_URL"],
eas_service_token=os.environ["EAS_SERVICE_TOKEN"],
)
llm_chain = prompt | llm

question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
llm_chain.invoke({"question": question})
'  Thank you for asking! However, I must respectfully point out that the question contains an error. Justin Bieber was born in 1994, and the Super Bowl was first played in 1967. Therefore, it is not possible for any NFL team to have won the Super Bowl in the year Justin Bieber was born.\n\nI hope this clarifies things! If you have any other questions, please feel free to ask.'

此頁面是否對您有幫助?