大型語言模型(LLM)入門

Python 的 LLM 入門

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

先備知識

  • 瀏覽 Hugging Face Hub
  • 深度學習模型

卡通大腦在看書

Python 的 LLM 入門

LLM 簡介

 

燈泡與大腦圖示,代表理解

Python 的 LLM 入門

LLM 簡介

 

筆電插圖,代表使用

Python 的 LLM 入門

大型語言模型的抽象插圖

Python 的 LLM 入門

帶有摘要泡泡的大型語言模型抽象插圖

Python 的 LLM 入門

帶有摘要與產生泡泡的大型語言模型抽象插圖

Python 的 LLM 入門

帶有摘要、產生與翻譯泡泡的大型語言模型抽象插圖

Python 的 LLM 入門

帶有摘要、產生、翻譯、問答泡泡的大型語言模型抽象插圖

LLM 標誌

Python 的 LLM 入門

LLM

 

  • 建立於 深度學習 架構之上

 

  • 最常見為 transformers

 

  • 超大 神經網路,含大量參數與文本資料

Hugging Face 標誌

Python 的 LLM 入門

使用 Hugging Face 模型

from transformers import pipeline


summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn")
text = "Walking amid Gion's Machiya wooden houses is a mesmerizing experience. The beautifully preserved structures exuded an old-world charm that transports visitors back in time, making them feel like they had stepped into a living museum. The glow of lanterns lining the narrow streets add to the enchanting ambiance, making each stroll a memorable journey through Japan's rich cultural history." summary = summarizer(text, max_length=50)
  • clean_up_tokenization_spaces=True:移除不必要的空白
Python 的 LLM 入門

模型輸出

print(summary)
[{'summary_text': "Gion's Machiya
  wooden houses exuded an old-world 
  charm that transports visitors back 
  in time. The glow of lanterns lining 
  the narrow streets add to the 
  enchanting ambiance, making each 
  stroll a memorable journey through 
  Japan's"}]
print(summary[0]["summary_text"])
Gion's Machiya wooden houses exuded an 
old-world charm that transports 
visitors back in time. The glow of 
lanterns lining the narrow streets add 
to the enchanting ambiance, making each 
stroll a memorable journey through 
Japan's
Python 的 LLM 入門

接下來

 

  • 強化既有的 LLM 知識
  • 執行新任務
  • 了解 LLM 的構成
  • 微調 LLM
  • 評估 LLM 表現

學習路徑

Python 的 LLM 入門

一起來練習吧!

Python 的 LLM 入門

Preparing Video For Download...