Flan T5 Xl
FLAN-T5 XL是基於T5架構的指令微調語言模型,在1000+任務上微調後,多語言和少樣本性能顯著提升。
下載量 257.40k
發布時間 : 10/21/2022
模型概述
一個經過指令微調的文本到文本生成模型,支持多種語言和任務,性能優於同等規模的T5模型。
模型特點
多任務指令微調
在超過1000項任務上微調,顯著提升零樣本和少樣本學習能力
多語言支持
支持60多種語言的處理和生成
開源可用
Apache 2.0許可證下公開發布,便於研究和商業使用
模型能力
文本翻譯
問答系統
邏輯推理
科學知識解答
布爾表達式計算
數學問題求解
使用案例
語言處理
多語言翻譯
支持60多種語言間的文本翻譯
高質量翻譯效果
知識問答
回答各類知識性問題
準確率優於同等規模模型
教育研究
數學問題求解
解決代數、幾何等數學問題
逐步推理得出正確答案
🚀 FLAN - T5 XL模型卡片
FLAN - T5 XL是基於預訓練T5模型微調的語言模型,在超1000個額外任務上微調,支持多語言,能用於零樣本和少樣本學習的NLP任務,如推理、問答等。
🚀 快速開始
模型使用示例
在transformers
庫中使用該模型的示例腳本如下:
使用PyTorch模型
在CPU上運行模型
點擊展開
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
在GPU上運行模型
點擊展開
# pip install accelerate
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl", device_map="auto")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
在GPU上使用不同精度運行模型
FP16
點擊展開
# pip install accelerate
import torch
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl", device_map="auto", torch_dtype=torch.float16)
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
INT8
點擊展開
# pip install bitsandbytes accelerate
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl", device_map="auto", load_in_8bit=True)
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
✨ 主要特性
- 多語言支持:支持英語、西班牙語、日語、波斯語、印地語、法語、中文等眾多語言。
- 多任務處理:可用於文本生成、問答、邏輯推理、科學知識問答、布爾表達式計算、數學推理等多種任務。
📦 安裝指南
文檔未提及具體安裝命令,跳過該章節。
💻 使用示例
基礎用法
文檔中已給出在不同環境(CPU、GPU、不同精度)下運行模型進行翻譯任務的代碼示例,如在CPU上運行模型的代碼:
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
高級用法
文檔未提及高級用法相關代碼示例,跳過該部分。
📚 詳細文檔
模型詳情
模型描述
屬性 | 詳情 |
---|---|
模型類型 | 語言模型 |
支持語言(NLP) | 英語、西班牙語、日語、波斯語、印地語、法語、中文、孟加拉語、古吉拉特語、德語、泰盧固語、意大利語、阿拉伯語、波蘭語、泰米爾語、馬拉地語、馬拉雅拉姆語、奧里亞語、旁遮普語、葡萄牙語、烏爾都語、加利西亞語、希伯來語、韓語、加泰羅尼亞語、泰語、荷蘭語、印尼語、越南語、保加利亞語、菲律賓語、高棉語、老撾語、土耳其語、俄語、克羅地亞語、瑞典語、約魯巴語、庫爾德語、緬甸語、馬來語、捷克語、芬蘭語、索馬里語、他加祿語、斯瓦希里語、僧伽羅語、卡納達語、壯語、伊博語、科薩語、羅馬尼亞語、海地語、愛沙尼亞語、斯洛伐克語、立陶宛語、希臘語、尼泊爾語、阿薩姆語、挪威語 |
許可證 | Apache - 2.0 |
相關模型 | 所有FLAN - T5檢查點 |
原始檢查點 | 所有原始FLAN - T5檢查點 |
更多信息資源 | 研究論文、GitHub倉庫、Hugging Face FLAN - T5文檔(類似於T5) |
用途
直接使用和下游使用
作者在原論文的模型卡片中指出:該模型的主要用途是語言模型研究,包括零樣本NLP任務和上下文少樣本學習NLP任務的研究,如推理和問答;推動公平性和安全性研究,以及瞭解當前大語言模型的侷限性。更多詳情見研究論文。
超出適用範圍的使用
需要更多信息。
偏差、風險和侷限性
此部分信息摘自模型的官方模型卡片:
- 倫理考量和風險:Flan - T5在大量文本數據上進行微調,這些數據未經過明確內容過濾或現有偏差評估。因此,模型本身可能容易生成不當內容或複製底層數據中固有的偏差。
- 已知侷限性:Flan - T5尚未在現實世界應用中進行測試。
- 敏感使用:Flan - T5不應應用於任何不可接受的用例,例如生成辱罵性言論。
訓練詳情
訓練數據
該模型在多種任務的混合數據上進行訓練,包括下表(來自原論文圖2)中描述的任務:
訓練過程
根據原論文的模型卡片:這些模型基於預訓練的T5(Raffel等人,2020),並使用指令進行微調,以獲得更好的零樣本和少樣本性能。每個T5模型大小對應一個微調後的Flan模型。該模型在TPU v3或TPU v4集群上使用t5x
代碼庫和jax
進行訓練。
評估
測試數據、因素和指標
作者在涵蓋多種語言(總共1836種)的各種任務上對模型進行了評估。以下表格展示了一些定量評估結果:
完整詳情請查看研究論文。
結果
FLAN - T5 - XL的完整結果請查看研究論文中的表3。
環境影響
可以使用Lacoste等人(2019)提出的機器學習影響計算器來估算碳排放:
- 硬件類型:谷歌雲TPU集群 - TPU v3或TPU v4,芯片數量≥4。
- 使用時長:需要更多信息。
- 雲服務提供商:GCP。
- 計算區域:需要更多信息。
- 碳排放:需要更多信息。
引用
BibTeX:
@misc{https://doi.org/10.48550/arxiv.2210.11416,
doi = {10.48550/ARXIV.2210.11416},
url = {https://arxiv.org/abs/2210.11416},
author = {Chung, Hyung Won and Hou, Le and Longpre, Shayne and Zoph, Barret and Tay, Yi and Fedus, William and Li, Eric and Wang, Xuezhi and Dehghani, Mostafa and Brahma, Siddhartha and Webson, Albert and Gu, Shixiang Shane and Dai, Zhuyun and Suzgun, Mirac and Chen, Xinyun and Chowdhery, Aakanksha and Narang, Sharan and Mishra, Gaurav and Yu, Adams and Zhao, Vincent and Huang, Yanping and Dai, Andrew and Yu, Hongkun and Petrov, Slav and Chi, Ed H. and Dean, Jeff and Devlin, Jacob and Roberts, Adam and Zhou, Denny and Le, Quoc V. and Wei, Jason},
keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Scaling Instruction-Finetuned Language Models},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
數據集和標籤
- 支持語言:英語、法語、羅馬尼亞語、德語、多語言
- 標籤:文本到文本生成
- 數據集:svakulenk0/qrecc、taskmaster2、djaym7/wiki_dialog、deepmind/code_contests、lambada、gsm8k、aqua_rat、esnli、quasc、qed
示例
示例文本 | 示例標題 |
---|---|
"Translate to German: My name is Arthur" | 翻譯 |
"Please answer to the following question. Who is going to be the next Ballon d'or?" | 問答 |
"Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering." | 邏輯推理 |
"Please answer the following question. What is the boiling point of Nitrogen?" | 科學知識 |
"Answer the following yes/no question. Can you write a whole Haiku in a single tweet?" | 是非問題 |
"Answer the following yes/no question by reasoning step - by - step. Can you write a whole Haiku in a single tweet?" | 推理任務 |
"Q: ( False or not False or False ) is? A: Let's think step by step" | 布爾表達式 |
"The square root of x is the cube root of y. What is y to the power of 2, if x = 4?" | 數學推理 |
"Premise: At my age you will probably have learnt one lesson. Hypothesis: It's not certain how many lessons you'll learn by your thirties. Does the premise entail the hypothesis?" | 前提和假設 |
📄 許可證
本模型使用的許可證為Apache - 2.0。
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98