跳至主要內容

阿里巴巴雲 PAI EAS

阿里云人工智能平台是一個專為企業和開發人員設計的機器學習或深度學習工程平台。它提供易於使用、經濟高效、高效能且易於擴展的插件,可應用於各種產業場景。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.'

此頁面是否對您有幫助?