Transformer 介紹

Large Language Models (LLMs) 概念

Vidhi Chugh

AI strategist and ethicist

我們現在在哪裡?

進度圖:我們來到 transformer 學習階段

Large Language Models (LLMs) 概念

什麼是 transformer?

  • 「Attention Is All You Need」
    • 徹底改變語言建模

 

  • Transformer 架構
    • 詞與詞的關係
    • 元件:前處理、位置編碼、Encoder、Decoder

論文「Attention is all you need」節錄

1 arXiv: Attention Is All You Need
Large Language Models (LLMs) 概念

Transformer 內部運作

 

  • 輸入:Jane, who lives in New York and works as a software

 

Transformer 的內部元件與資料流

 

  • 輸出:engineer, loves exploring new restaurants in the city.
Large Language Models (LLMs) 概念

Transformer 就像一個管弦樂團

一張管弦樂團的圖片

Large Language Models (LLMs) 概念

文字前處理與表示

  • 文字前處理:分詞、停用詞移除、詞形還原
  • 文字表示:詞嵌入

Transformer 第一個元件與若干音符的強調圖

Large Language Models (LLMs) 概念

位置編碼

  • 每個詞的位置資訊
  • 理解相隔較遠的詞

Transformer 第二個元件與一段樂譜的強調圖

Large Language Models (LLMs) 概念

Encoders

  • Attention 機制:聚焦特定詞與其關係
  • 神經網路:處理特定特徵

Transformer 流程中的 Encoder

Large Language Models (LLMs) 概念

Decoders

  • 包含 attention 與神經網路
  • 產生輸出

Transformer 的 Decoder 元件

Large Language Models (LLMs) 概念

Transformer 與長距依存

 

  • 起初的挑戰:長距依存
  • Attention:聚焦輸入的不同部分

 

  • 例句:"Jane, who lives in New York and works as a software engineer, loves exploring new restaurants in the city."

  • "Jane" --- "loves exploring new restaurants"

Large Language Models (LLMs) 概念

同時處理多個部分

  • 傳統語言模型的限制
    • 序列式——一次一個詞

 

  • Transformers
    • 可同時處理多個部分
    • 更快的處理速度

 

  • 例如
    • "The cat sat on the mat"
    • 同步處理 "cat,"、"sat,"、"on,"、"the,"、"mat"
Large Language Models (LLMs) 概念

一起來練習吧!

Large Language Models (LLMs) 概念

Preparing Video For Download...