Mt0 Xxl Mt
模型概述
模型特點
模型能力
使用案例
🚀 BLOOMZ & mT0模型項目
BLOOMZ和mT0是一系列能夠零樣本遵循多種語言人類指令的模型。通過在跨語言任務混合數據集上微調BLOOM和mT5預訓練多語言模型,這些模型能夠對未見任務和語言進行跨語言泛化。
🚀 快速開始
預期用途
推薦使用該模型執行自然語言表達的任務。例如,給定提示“Translate to English: Je t’aime.”,模型很可能回答“I love you.”。以下是論文中的一些提示示例:
- 一個傳奇的開端,一個不滅的神話,這不僅僅是一部電影,而是作為一個走進新時代的標籤,永遠彪炳史冊。你認為這句話的立場是讚揚、中立還是批評?
- Suggest at least five related search terms to "Mạng neural nhân tạo".
- Write a fairy tale about a troll saving a princess from a dangerous dragon. The fairy tale is a masterpiece that has achieved praise worldwide and its moral is "Heroes Come in All Shapes and Sizes". Story (in Spanish):
- Explain in a sentence in Telugu what is backpropagation in neural networks.
歡迎在社區標籤中分享你的生成結果!
使用方法
CPU
點擊展開
# pip install -q transformers
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
checkpoint = "bigscience/mt0-xxl-mt"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
GPU
點擊展開
# pip install -q transformers accelerate
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
checkpoint = "bigscience/mt0-xxl-mt"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint, torch_dtype="auto", device_map="auto")
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
8位GPU
點擊展開
# pip install -q transformers accelerate bitsandbytes
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
checkpoint = "bigscience/mt0-xxl-mt"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint, device_map="auto", load_in_8bit=True)
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
✨ 主要特性
- 能夠零樣本遵循多種語言的人類指令。
- 對未見任務和語言具有跨語言泛化能力。
📦 安裝指南
CPU環境
# pip install -q transformers
GPU環境
# pip install -q transformers accelerate
8位GPU環境
# pip install -q transformers accelerate bitsandbytes
💻 使用示例
基礎用法
# pip install -q transformers
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
checkpoint = "bigscience/mt0-xxl-mt"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
高級用法
# 如果你想在GPU上使用該模型,可參考以下代碼
# pip install -q transformers accelerate
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
checkpoint = "bigscience/mt0-xxl-mt"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint, torch_dtype="auto", device_map="auto")
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
📚 詳細文檔
模型概述
我們推出了BLOOMZ和mT0系列模型,這些模型能夠零樣本遵循多種語言的人類指令。通過在跨語言任務混合數據集(xP3)上微調BLOOM和mT5預訓練多語言模型,我們發現這些模型能夠對未見任務和語言進行跨語言泛化。
- 倉庫地址:bigscience-workshop/xmtf
- 論文地址:Crosslingual Generalization through Multitask Finetuning
- 聯繫人:Niklas Muennighoff
- 支持語言:預訓練語言比例參考mc4,微調語言比例參考xP3。模型能夠理解預訓練和微調所用的語言。
BLOOMZ和mT0模型家族
微調數據集 | 300M | 580M | 1.2B | 3.7B | 13B | 560M | 1.1B | 1.7B | 3B | 7.1B | 176B |
---|---|---|---|---|---|---|---|---|---|---|---|
xP3 | mt0-small | mt0-base | mt0-large | mt0-xl | mt0-xxl | bloomz-560m | bloomz-1b1 | bloomz-1b7 | bloomz-3b | bloomz-7b1 | bloomz |
xP3mt | mt0-xxl-mt | bloomz-7b1-mt | bloomz-mt | ||||||||
P3 | mt0-xxl-p3 | bloomz-7b1-p3 | bloomz-p3 | ||||||||
原始預訓練模型 | mt5-small | mt5-base | mt5-large | mt5-xl | mt5-xxl | bloom-560m | bloom-1b1 | bloom-1b7 | bloom-3b | bloom-7b1 | bloom |
🔧 技術細節
模型
- 架構:與mt5-xxl相同,也可參考
config.json
文件。 - 微調步驟:7000步。
- 微調令牌數:12.9億。
- 精度:bfloat16。
硬件
- TPU:TPUv4 - 256。
軟件
📄 許可證
本項目採用apache - 2.0
許可證。
📈 評估結果
我們參考論文Crosslingual Generalization through Multitask Finetuning中的表7以及bigscience/evaluation-results獲取未見任務的零樣本結果。側邊欄報告了每個數據集配置下最佳提示的零樣本性能。
模型評估指標
任務類型 | 數據集 | 準確率 |
---|---|---|
共指消解 | Winogrande XL (xl) | 62.67 |
共指消解 | XWinograd (en) | 83.31 |
共指消解 | XWinograd (fr) | 78.31 |
共指消解 | XWinograd (jp) | 80.19 |
共指消解 | XWinograd (pt) | 80.99 |
共指消解 | XWinograd (ru) | 79.05 |
共指消解 | XWinograd (zh) | 82.34 |
自然語言推理 | ANLI (r1) | 49.5 |
自然語言推理 | ANLI (r2) | 42 |
自然語言推理 | ANLI (r3) | 48.17 |
自然語言推理 | SuperGLUE (cb) | 87.5 |
自然語言推理 | SuperGLUE (rte) | 84.84 |
自然語言推理 | XNLI (ar) | 58.03 |
自然語言推理 | XNLI (bg) | 59.92 |
自然語言推理 | XNLI (de) | 60.16 |
自然語言推理 | XNLI (el) | 59.2 |
自然語言推理 | XNLI (en) | 62.25 |
自然語言推理 | XNLI (es) | 60.92 |
自然語言推理 | XNLI (fr) | 59.88 |
自然語言推理 | XNLI (hi) | 57.47 |
自然語言推理 | XNLI (ru) | 58.67 |
自然語言推理 | XNLI (sw) | 56.79 |
自然語言推理 | XNLI (th) | 58.03 |
自然語言推理 | XNLI (tr) | 57.67 |
自然語言推理 | XNLI (ur) | 55.98 |
自然語言推理 | XNLI (vi) | 58.92 |
自然語言推理 | XNLI (zh) | 58.71 |
句子完成 | StoryCloze (2016) | 94.66 |
句子完成 | SuperGLUE (copa) | 88 |
句子完成 | XCOPA (et) | 81 |
句子完成 | XCOPA (ht) | 79 |
句子完成 | XCOPA (id) | 90 |
句子完成 | XCOPA (it) | 88 |
句子完成 | XCOPA (qu) | 56 |
句子完成 | XCOPA (sw) | 81 |
句子完成 | XCOPA (ta) | 81 |
句子完成 | XCOPA (th) | 76 |
句子完成 | XCOPA (tr) | 76 |
句子完成 | XCOPA (vi) | 85 |
句子完成 | XCOPA (zh) | 87 |
句子完成 | XStoryCloze (ar) | 91 |
句子完成 | XStoryCloze (es) | 93.38 |
句子完成 | XStoryCloze (eu) | 91.13 |
句子完成 | XStoryCloze (hi) | 90.73 |
句子完成 | XStoryCloze (id) | 93.05 |
句子完成 | XStoryCloze (my) | 86.7 |
句子完成 | XStoryCloze (ru) | 91.66 |
句子完成 | XStoryCloze (sw) | 89.61 |
句子完成 | XStoryCloze (te) | 90.4 |
句子完成 | XStoryCloze (zh) | 93.05 |
📖 引用
@article{muennighoff2022crosslingual,
title={Crosslingual generalization through multitask finetuning},
author={Muennighoff, Niklas and Wang, Thomas and Sutawika, Lintang and Roberts, Adam and Biderman, Stella and Scao, Teven Le and Bari, M Saiful and Shen, Sheng and Yong, Zheng-Xin and Schoelkopf, Hailey and others},
journal={arXiv preprint arXiv:2211.01786},
year={2022}
}
⚠️ 重要提示
提示工程
模型的性能可能會因提示的不同而有所差異。對於BLOOMZ模型,建議明確告知輸入的結束位置,以避免模型繼續生成內容。例如,提示“Translate to English: Je t'aime”如果沒有句末的句號(.),模型可能會嘗試繼續生成法語句子。更好的提示示例包括“Translate to English: Je t'aime.”、“Translate to English: Je t'aime. Translation:”、“What is "Je t'aime." in English?”,這些提示能讓模型明確何時開始回答。此外,建議為模型提供儘可能多的上下文信息。例如,如果你希望模型用泰盧固語回答,可告知模型,如“Explain in a sentence in Telugu what is backpropagation in neural networks.”。
數據集信息
屬性 | 詳情 |
---|---|
數據集 | bigscience/xP3、mc4 |
許可證 | apache - 2.0 |
支持語言 | af、am、ar等多種語言 |
標籤 | text2text - generation |
小部件示例
輸入文本 | 示例標題 |
---|---|
Life is beautiful! Translate to Mongolian. | mn - en translation |
Le mot japonais «憂鬱» veut dire quoi en Odia? | jp - or - fr translation |
Stell mir eine schwierige Quiz Frage bei der es um Astronomie geht. Bitte stell die Frage auf Norwegisch. | de - nb quiz |
一個傳奇的開端,一個不滅的神話,這不僅僅是一部電影,而是作為一個走進新時代的標籤,永遠彪炳史冊。Would you rate the previous review as positive, neutral or negative? | zh - en sentiment |
一個傳奇的開端,一個不滅的神話,這不僅僅是一部電影,而是作為一個走進新時代的標籤,永遠彪炳史冊。你認為這句話的立場是讚揚、中立還是批評? | zh - zh sentiment |
Suggest at least five related search terms to "Mạng neural nhân tạo". | vi - en query |
Proposez au moins cinq mots clés concernant «Réseau de neurones artificiels». | fr - fr query |
Explain in a sentence in Telugu what is backpropagation in neural networks. | te - en qa |
Why is the sky blue? | en - en qa |
Write a fairy tale about a troll saving a princess from a dangerous dragon. The fairy tale is a masterpiece that has achieved praise worldwide and its moral is "Heroes Come in All Shapes and Sizes". Story (in Spanish): | es - en fable |
Write a fable about wood elves living in a forest that is suddenly invaded by ogres. The fable is a masterpiece that has achieved praise worldwide and its moral is "Violence is the last refuge of the incompetent". Fable (in Hindi): | hi - en fable |



