建立 few-shot 範例集
PromptTemplate 與 ChatPromptTemplate 很適合整合變數,但在整合包含許多範例的資料集時就比較吃力。這時就需要 FewShotPromptTemplate!在本練習中,你要建立一個資料集,格式為字典(dictionary)所組成的清單,用來存放以下的問答配對。
- 問題:
How many DataCamp courses has Jack completed? - 答案:
36 - 問題:
How much XP does Jack have on DataCamp? - 答案:
284,320XP - 問題:
What technology does Jack learn about most on DataCamp? - 答案:
Python
在下一個練習中,你會把這些資訊轉換成一個 few-shot 提示範本(prompt template)。
本練習屬於課程
使用 LangChain 開發 LLM 應用
練習說明
- 使用鍵
"question"與"answer",為所提供的問題與答案建立一個字典清單。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create the examples list of dicts
examples = [
{
"question": "____",
"answer": "____"
},
{
"question": "____",
"answer": "____"
},
{
"question": "____",
"answer": "____"
}
]