微調方法

Python 的 LLM 入門

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

微調

 

LLMs fine-tuning chemistry use case

Python 的 LLM 入門

完整微調

 

  • 更新整個模型權重
  • 計算成本高

 

Full fine-tuning

Python 的 LLM 入門

部分微調

 

  • 固定部分層
  • 僅更新任務專屬層

 

Partial fine-tuning

Python 的 LLM 入門

遷移學習

 

  • 將預訓練模型調適到相關但不同的任務
  • 將一個領域的知識移轉到相近領域

The transfer learning paradigm

Python 的 LLM 入門

N-shot 學習

  • Zero-shot learning:無範例
  • One-shot learning:1 個範例
  • Few-shot learning:數個範例
Python 的 LLM 入門

One-shot 學習

from transformers import pipeline

generator = pipeline(task="sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

input_text = """
Classify the sentiment of this sentence as either Positive or Negative.
Example:
Text: "I'm feeling great today!" Sentiment: Positive
Text: "The weather today is lovely." Sentiment:
"""

result = generator(input_text, max_length=100)
print(result[0]["label"])
POSITIVE
Python 的 LLM 入門

一起來練習吧!

Python 的 LLM 入門

Preparing Video For Download...