Arcee
本筆記本示範如何使用 Arcee
類別,以使用 Arcee 的領域調整語言模型 (DALM) 來產生文字。
##Installing the langchain packages needed to use the integration
%pip install -qU langchain-community
設定
在使用 Arcee 之前,請確保 Arcee API 金鑰設定為 ARCEE_API_KEY
環境變數。您也可以將 API 金鑰作為具名參數傳遞。
from langchain_community.llms import Arcee
# Create an instance of the Arcee class
arcee = Arcee(
model="DALM-PubMed",
# arcee_api_key="ARCEE-API-KEY" # if not already set in the environment
)
API 參考:Arcee
其他設定
您也可以根據需要設定 Arcee 的參數,例如 arcee_api_url
、arcee_app_url
和 model_kwargs
。在物件初始化時設定 model_kwargs
會將這些參數用作後續所有產生回應呼叫的預設值。
arcee = Arcee(
model="DALM-Patent",
# arcee_api_key="ARCEE-API-KEY", # if not already set in the environment
arcee_api_url="https://custom-api.arcee.ai", # default is https://api.arcee.ai
arcee_app_url="https://custom-app.arcee.ai", # default is https://app.arcee.ai
model_kwargs={
"size": 5,
"filters": [
{
"field_name": "document",
"filter_type": "fuzzy_search",
"value": "Einstein",
}
],
},
)
產生文字
您可以透過提供提示詞,從 Arcee 產生文字。以下範例
# Generate text
prompt = "Can AI-driven music therapy contribute to the rehabilitation of patients with disorders of consciousness?"
response = arcee(prompt)
其他參數
Arcee 允許您套用 filters
並設定檢索文件的 size
(以計數為單位)來輔助文字產生。篩選器有助於縮小結果範圍。以下說明如何使用這些參數
# Define filters
filters = [
{"field_name": "document", "filter_type": "fuzzy_search", "value": "Einstein"},
{"field_name": "year", "filter_type": "strict_search", "value": "1905"},
]
# Generate text with filters and size params
response = arcee(prompt, size=5, filters=filters)