我想要一天分享一點「LLM從底層堆疊的技術」,並且每篇文章長度控制在三分鐘以內,讓大家不會壓力太大,但是又能夠每天成長一點。
- 訓練的必要模組安裝:AI說書 - 從0開始 - 135
- 載入資料集:AI說書 - 從0開始 - 136
- 資料集窺探:AI說書 - 從0開始 - 137
- 資料前處理與 Tokenization:AI說書 - 從0開始 - 138
- 資料 Padding 與訓練/驗證集切割:AI說書 - 從0開始 - 139
- Data Loader 設定:AI說書 - 從0開始 - 140
- BERT 模型窺探:AI說書 - 從0開始 - 141
- 載入 BERT 模型:AI說書 - 從0開始 - 142
- Optimizer 的 Decay Rate 群組配置:AI說書 - 從0開始 - 143
- BERT 模型的特定「層」參數窺探方法:AI說書 - 從0開始 - 144
- Optimizer 的 Decay Rate 群組窺探:AI說書 - 從0開始 - 145
- 配置 Optimizer 與訓練成效評估函數:AI說書 - 從0開始 - 146
- 訓練程式的撰寫:AI說書 - 從0開始 - 147
- 訓練結果圖示化:AI說書 - 從0開始 - 148
- 準備驗證微調效果的另一份資料前處理:AI說書 - 從0開始 - 149
- 微調模型的預測展示:AI說書 - 從0開始 - 150
- 使用 MCC 分數評估微調後的模型:AI說書 - 從0開始 - 151
- 保存微調好的模型方法:AI說書 - 從0開始 - 152 | 保存微調後的模型
- 預測文法正確與否的函數:AI說書 - 從0開始 - 153 | 製作文法正確與否的預測函數
應用 AI說書 - 從0開始 - 153 | 製作文法正確與否的預測函數 的函數,來做一個聊天介面,首先定義 Interface 函數:
!pip install ipywidgets
import ipywidgets as widgets
from IPython.display import display
def model_predict_interface(sentence):
prediction = predict(sentence, model, tokenizer)
if prediction == 0:
return "Grammatically Incorrect"
elif prediction == 1:
return "Grammatically Correct"
else:
return f"Label: {prediction}"
接著進入主題介面設定:
text_input = widgets.Textarea(placeholder = 'Type something',
description = 'Sentence:',
disabled = False,
layout = widgets.Layout(width = '100%', height = '50px'))
output_label = widgets.Label(value = '',
layout = widgets.Layout(width = '100%', height = '25px'),
style = {'description_width': 'initial'})
def on_text_submit(change):
output_label.value = model_predict_interface(change.new)
text_input.observe(on_text_submit, names = 'value')
display(text_input, output_label)