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