or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
AI / ML領域相關學習筆記入口頁面
Deeplearning.ai GenAI/LLM系列課程筆記
Large Language Models with Semantic Search。大型語言模型與語義搜索
Finetuning Large Language Models。微調大型語言模型
LangChain for LLM Application Development
LangChain for LLM Application Development LangChain教學、系列課程筆記
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →source : LangChain.dart
整體內容是好的,但授課技巧、程式碼範例跟簡報內容的組織欠佳
如果直接跟著上課順序先看程式碼大概會很亂,建議影片內容先看後面的概念說明在看程式碼會比較好理解
以下筆記根據個人理解重新組織架構(有點頭痛)
LangChain - Models, Prompts and Output Parsers
Outline
LangChain提供簡化操作的抽象,使重複使用模型、提示模型、解析輸出變得容易
Models, Prompts and Output Parsers
這節課探討如何使用LangChain工具來簡化和強化與大型語言模型的互動
1. 內容概述
本章主要在介紹Model I/O的部分,包含
模型(Models)、提示(Prompts)和解析器(Parsers)的概念
利用LangChain簡化和抽象化這些操作。
更詳盡的介紹見官方文件-model_io
2. 啟動代碼
3. 語言翻譯示例
4. 提示模板
範例:語氣調換
在
customer_style
指定想要的語氣將客戶信件從“英式海盜(English Pirate)”口吻轉換為“平和恭敬的美式英語(American English in a calm and respectful tone)”的語氣
接著把客服回覆的語氣也做調換
原本客服正式的回覆語氣變成靠北的8+9語氣
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →5. 解析輸出
以下顧客留言為非結構化的自然語言,要如何提取為結構化或量化的資訊呢?
我們希望可以透過提示模板,讓LLM幫我們從客戶留言中提取出結構化的輸出,例如類似下面json或dict格式,方便串接後面的分析
使用提示模板可以幫助我們把大量重覆的任務以模組化的方式進行
直接使用openAI的API
產出的結果看似為json結構實為
str
格式,不利後續解析使用
dict
的get
方法會得到錯誤回報使用LangChain的解析器
透過定義響應模式、建立結構化輸出解析器、建立評論模板,並最後格式化消息,實現了一個流程,用於從客戶評論中提取和結構化特定資訊。這種方法允許將文本資料轉化為結構化資料,以便於分析和處理
本節程式碼流程圖
建立響應模式
分別為 "gift", "delivery_days", 和 "price_value" 建立三個響應模式(ResponseSchema)。將我們想要的三種輸出結果,使用
ResponseSchema
封裝name
description
: 輸入要模型執行的工作建立結構化輸出解析器
response_schemas
StructuredOutputParser
和response_schemas
建立一個結構化的輸出解析器output_parser
建立評論模板
format_instructions
套入模板中格式化消息
檢視經過
StructuredOutputParser
解析LLM輸出的結果,資料格式已經轉為python的dict,而且也能用get
方法取值AutoGen
微軟在2023.08推出的智能代理框架,使用上看來比Langchain更簡單易用
[2023.10。01coder。AutoGen + LangChain + ChromaDB = Super AI Agents
有一系列LLM部署架構相關的教學
AutoGen doesn't support connecting to various external data sources natively. This is exactly where LangChain can come into play.