Transformers 文件

FLAN-UL2

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

FLAN-UL2

PyTorch TensorFlow Flax

概述

Flan-UL2 是一個基於 T5 架構的編碼器-解碼器模型。它使用了與去年早些時候釋出的 UL2 模型相同的配置。它使用了“Flan”提示微調和資料集集合進行了微調。與 Flan-T5 類似,使用者可以直接使用 FLAN-UL2 的權重而無需對模型進行微調。

根據原始部落格,以下是顯著的改進:

  • 原始 UL2 模型的訓練感受野僅為 512,這使得它在 N 值較大的 N-shot 提示場景中表現不理想。
  • Flan-UL2 檢查點使用了 2048 的感受野,這使其更適用於少樣本上下文學習(few-shot in-context learning)。
  • 原始 UL2 模型還有模式切換標記(mode switch tokens),這對於獲得良好效能是必需的。然而,它們有些繁瑣,因為這通常需要在推理或微調過程中進行一些更改。在這次更新/更改中,我們在應用 Flan 指令微調之前,繼續用小批次對 UL2 20B 進行額外的 10 萬步訓練,以忘記“模式標記”。這個 Flan-UL2 檢查點不再需要模式標記。Google 釋出了以下變體:

原始檢查點可以在此處找到。

在低資源裝置上執行

該模型非常大(半精度下約 40GB),所以如果你只是想執行模型,請確保以 8 位模式載入模型,並使用 device_map="auto" 以確保不會出現記憶體不足(OOM)問題!

>>> from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

>>> model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-ul2", load_in_8bit=True, device_map="auto")
>>> tokenizer = AutoTokenizer.from_pretrained("google/flan-ul2")

>>> inputs = tokenizer("A step by step recipe to make bolognese pasta:", return_tensors="pt")
>>> outputs = model.generate(**inputs)
>>> print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
['In a large skillet, brown the ground beef and onion over medium heat. Add the garlic']

有關 API 參考、提示、程式碼示例和筆記本,請參閱 T5 的文件頁面

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.