🚀 GPT - JT
GPT - JT是基于GPT - J(6B)微调的模型,借助新的去中心化训练算法和多种技术,在分类基准测试中表现出色,超越了许多参数超100B的模型。
🚀 快速开始
from transformers import pipeline
pipe = pipeline(model='togethercomputer/GPT-JT-6B-v1')
pipe('''"I love this!" Is it positive? A:''')
或者
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/GPT-JT-6B-v1")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/GPT-JT-6B-v1")
✨ 主要特性
- 微调优化:基于EleutherAI的GPT - J(6B)进行微调,采用UL2的训练目标,使模型能看到提示的双向上下文。
- 数据多样:在大量不同类型的数据上进行训练,包括Chain - of - Thought (CoT)、Public Pool of Prompts (P3) 数据集、Natural - Instructions (NI) 数据集等。
- 性能提升:在分类任务上的表现显著优于原始的GPT - J,甚至超越了大多数参数超100B的模型。
📦 安装指南
文档未提及具体安装步骤,暂无法提供。
💻 使用示例
基础用法
from transformers import pipeline
pipe = pipeline(model='togethercomputer/GPT-JT-6B-v1')
pipe('''"I love this!" Is it positive? A:''')
高级用法
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/GPT-JT-6B-v1")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/GPT-JT-6B-v1")
📚 详细文档
模型概述
借助新的去中心化训练算法,我们在35.3亿个标记上对GPT - J(6B)进行微调,得到了GPT - JT(6B)。该模型在分类基准测试中的表现超越了许多参数超100B的模型。
我们整合了一系列开放技术和数据集来构建GPT - JT:
- GPT - JT是EleutherAI的GPT - J(6B)的一个分支;
- 采用了UL2的训练目标,使模型能够看到提示的双向上下文;
- 模型在大量不同类型的数据上进行训练,包括Chain - of - Thought (CoT)、Public Pool of Prompts (P3) 数据集、Natural - Instructions (NI) 数据集。
通过上述技术,GPT - JT在分类任务上的性能相较于原始的GPT - J有了显著提升,甚至超越了大多数参数超100B的模型!
数据集
属性 |
详情 |
数据集 |
natural_instructions、the_pile、cot、Muennighoff/P3 |
推理参数
属性 |
详情 |
最大新标记数 |
5 |
温度 |
1.0 |
前k个 |
1 |
小部件示例
- 情感分析:任务是将帖子的情感标记为悲伤、喜悦、爱、愤怒、恐惧或惊讶。
- 输入:I'm feeling quite sad and sorry for myself but ill snap out of it soon. 输出:sadness
- 输入:I am just feeling cranky and blue. 输出:anger
- 输入:I can have for a treat or if i am feeling festive. 输出:
- 国家货币:返回给定国家的货币。
- 输入:Switzerland 输出:Swiss Franc
- 输入:India 输出:
- 推文评估仇恨:标记以下推文是否包含针对移民或女性的仇恨言论。
- 推文:HOW REFRESHING! In South Korea, there is no such thing as 'political correctness" when it comes to dealing with Muslim refugee wannabes via @user 标记:hate speech
- 推文:New to Twitter-- any men on here know what the process is to get #verified? 标记:not hate speech
- 推文:Dont worry @user you are and will always be the most hysterical woman. 标记:
- 实体识别:从以下句子中提取所有的人名、地名和组织名。
- 句子:Satya Nadella, the CEO of Microsoft, was visiting the Bahamas last May. 实体:Satya Nadella, Microsoft, Bahamas
- 句子:Pacific Northwest cities include Seattle and Portland, which I have visited with Vikash. 实体:
- 数据清理:将数据格式化为CSV文件。
- 输入:Jane Doe jane.doe@gmail.com (520) 382 2435 输出:Jane Doe,jane.doe@gmail.com,520 - 382 - 2435
- 输入:Peter Lee (510) 333 - 2429 email: peter@yahoo.com 输出:
🔧 技术细节
UL2训练目标
我们使用UL2训练目标 [1][2] 来训练GPT - JT。原始的GPT - J在自回归生成时使用因果掩码(如下左图所示),因此每个标记只能看到其之前的上下文。
为了充分利用上下文信息,我们继续使用UL2训练目标对GPT - J进行训练,并使用带前缀的因果掩码(如下右图所示)——对提示/输入使用双向注意力,对标记生成使用因果注意力。直观地说,能够双向查看上下文可能会改善需要此信息的下游任务。
$$
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \
1 & 1 & 0 & 0 & 0 \
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 1 & 0 \
1 & 1 & 1 & 1 & 1
\end{bmatrix}
\begin{bmatrix}
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 1 & 0 \
1 & 1 & 1 & 1 & 1
\end{bmatrix}
$$
此外,我们利用了大量的数据,包括 [Natural - Instructions](https://github.com/allenai/natural - instructions)、P3、[MMLU - COT](https://github.com/jasonwei20/flan - 2/blob/main/mmlu - cot.json) 和 the Pile。
具体来说,我们首先在the Pile上使用UL2损失对26.2亿个标记进行训练,然后使用上述数据集的混合对0.92亿个标记进行训练:5%的COT、20%的P3、20%的NI和55%的the Pile。
超参数
我们使用AdamW优化器,学习率为1e - 5,全局批量大小为64(每个数据并行工作器为16)。
我们使用混合精度训练,其中激活值使用FP16,而优化器状态使用FP32。
我们同时使用数据并行和流水线并行进行训练。
在训练过程中,我们将输入序列截断为2048个标记,对于包含少于2048个标记的输入序列,我们将多个序列连接成一个长序列以提高数据效率。
基础设施
我们使用 the Together Research Computer 进行训练。
📄 许可证
GPT - JT - 6B - v1的权重遵循Apache许可证2.0版本。
📖 参考文献
[1]: Tay, Yi, Mostafa Dehghani, Vinh Q. Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Neil Houlsby, and Donald Metzler. "Unifying Language Learning Paradigms." arXiv preprint arXiv:2205.05131 (2022).
[2]: Tay, Yi, Jason Wei, Hyung Won Chung, Vinh Q. Tran, David R. So, Siamak Shakeri, Xavier Garcia et al. "Transcending scaling laws with 0.1% extra compute." arXiv preprint arXiv:2210.11399 (2022).