t5 3b

提供商google-t5
分类translation
许可证apache-2.0
下载量363.1K
星标0

简介

T5-3B 是 Google 推出的一款经典 Encoder-Decoder 架构模型,其核心理念是将所有 NLP 任务统一转化为“文本到文本”的格式。虽然在当前大模型时代它显得规模较小,但 3B 参数量使其在保持较高推理效率的同时,在翻译、摘要和文本改写等特定任务上表现稳健。对于开发者而言,它不像 GPT-4 那样依赖 Prompt 工程,而是更适合作为底座进行微调(Fine-tuning),以构建垂直领域的轻量化自然语言处理流水线,是平衡资源成本与任务效果的实用选择。

核心亮点

  • 统一文本到文本框架,兼容多种 NLP 任务
  • 参数规模适中,支持私有化部署与高效微调
  • 在机器翻译和文本摘要场景中表现稳健
  • Apache-2.0 协议,对商业应用极其友好

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("google-t5/t5-3b")
tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-3b")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download google-t5/t5-3b

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download google-t5/t5-3b config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('google-t5/t5-3b')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/google-t5/t5-3b

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/google-t5/t5-3b

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('google-t5/t5-3b')
tokenizer = AutoTokenizer.from_pretrained('google-t5/t5-3b')

完整文档

来源: HuggingFace

---
language:

  • en

  • fr

  • ro

  • de

  • multilingual

license: apache-2.0
tags:
  • summarization

  • translation

datasets:
  • c4

---

Model Card for T5-3B

!model image

Table of Contents

1. Model Details
2. Uses
3. Bias, Risks, and Limitations
4. Training Details
5. Evaluation
6. Environmental Impact
7. Citation
8. Model Card Authors
9. How To Get Started With the Model

Model Details

Model Description

The developers of the Text-To-Text Transfer Transformer (T5) write:

> With T5, we propose reframing all NLP tasks into a unified text-to-text-format where the input and output are always text strings, in contrast to BERT-style models that can only output either a class label or a span of the input. Our text-to-text framework allows us to use the same model, loss function, and hyperparameters on any NLP task.

T5-3B is the checkpoint with 3 billion parameters.

  • Developed by: Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. See associated paper and GitHub repo
  • Model type: Language model
  • Language(s) (NLP): English, French, Romanian, German
  • License: Apache 2.0
  • Resources for more information:
- Research paper - Google's T5 Blog Post - GitHub Repo - Hugging Face T5 Docs

Uses

Direct Use and Downstream Use

The developers write in a blog post that the model:

> Our text-to-text framework allows us to use the same model, loss function, and hyperparameters on any NLP task, including machine translation, document summarization, question answering, and classification tasks (e.g., sentiment analysis). We can even apply T5 to regression tasks by training it to predict the string representation of a number instead of the number itself.

See the blog post and research paper for further details.

Out-of-Scope Use

More information needed.

Bias, Risks, and Limitations

More information needed.

Recommendations

More information needed.

Training Details

Training Data

The model is pre-trained on the Colossal Clean Crawled Corpus (C4), which was developed and released in the context of the same research paper as T5.

The model was pre-trained on a on a multi-task mixture of unsupervised (1.) and supervised tasks (2.).
Thereby, the following datasets were being used for (1.) and (2.):

1. Datasets used for Unsupervised denoising objective:

2. Datasets used for Supervised text-to-text language modeling objective

  • Sentence acceptability judgment
- CoLA Warstadt et al., 2018
  • Sentiment analysis
- SST-2 Socher et al., 2013
  • Paraphrasing/sentence similarity
- MRPC Dolan and Brockett, 2005 - STS-B Ceret al., 2017 - QQP Iyer et al., 2017
  • Natural language inference
- MNLI Williams et al., 2017 - QNLI Rajpurkar et al.,2016 - RTE Dagan et al., 2005 - CB De Marneff et al., 2019
  • Sentence completion
- COPA Roemmele et al., 2011
  • Word sense disambiguation
- WIC Pilehvar and Camacho-Collados, 2018
  • Question answering
- MultiRC Khashabi et al., 2018 - ReCoRD Zhang et al., 2018 - BoolQ Clark et al., 2019

Training Procedure

In their abstract, the model developers write:

> In this paper, we explore the landscape of transfer learning techniques for NLP by introducing a unified framework that converts every language problem into a text-to-text format. Our systematic study compares pre-training objectives, architectures, unlabeled datasets, transfer approaches, and other factors on dozens of language understanding tasks.

The framework introduced, the T5 framework, involves a training procedure that brings together the approaches studied in the paper. See the research paper for further details.

Evaluation

Testing Data, Factors & Metrics

The developers evaluated the model on 24 tasks, see the research paper for full details.

Results

For full results for T5-3B, see the research paper, Table 14.

Environmental Impact

Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).

  • Hardware Type: Google Cloud TPU Pods
  • Hours used: More information needed
  • Cloud Provider: GCP
  • Compute Region: More information needed
  • Carbon Emitted: More information needed

Citation

BibTeX:

bibtex
@article{2020t5,
  author  = {Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu},
  title   = {Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
  journal = {Journal of Machine Learning Research},
  year    = {2020},
  volume  = {21},
  number  = {140},
  pages   = {1-67},
  url     = {http://jmlr.org/papers/v21/20-074.html}
}

APA:

  • Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., ... & Liu, P. J. (2020). Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21(140), 1-67.

Model Card Authors

This model card was written by the team at Hugging Face.

How to Get Started with the Model

See the Hugging Face T5 docs and a Colab Notebook created by the model developers for more context on how to get started with this checkpoint.