LLaMa

Problems

403

reclone and request.

代码文件

两个测试样例:

  1. example_text_completion.py: 文本补全示例;
  2. example_chat_completion.py: 对话生成示例.
torchrun --nproc_per_node 1 example_text_completion.py \
    --ckpt_dir llama-2-7b/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 128 --max_batch_size 4
torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir llama-2-7b-chat/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 512 --max_batch_size 6

ckpt_dir: 模型文件路径
tokenizer_path: 分词器文件路径

对于示例一, prompt中提供了需要补全的文本.

对于示例二, prompt以字典形式组织对话. 每个item包含rolecontent两个关键字.

  1. role:user: 用户, 用以输入文本;
  2. role:assistant: 系统, 用以输出文本;
  3. role:system: 对系统生成对话的要求;

LLaMA: Open and Efficient Foundation Language Models

发展:
scale models -> scale data -> fast inference and scale tokens

本文的要点:
通过在更多的token上训练, 使得在不同推理开销下, 达到最佳的性能.

方法

LLaMA采用Auto Regression的方式进行预训练.

预训练数据

公开数据.

请添加图片描述

tokenizer的方法为: bytepair encoding(BPE). 总共包含1.4T个tokens.

结构

采用了之前一些被证明可行的方法:

  1. RMSNorm from GPT3;
  2. SwiGLU from PaLM;
  3. RoPE from GPTNeo.

优化器

  1. AdamW ( β 1 = 0.9 , β 2 = 0.95 , w e i g h t   d e c a y = 0.1 \beta_1=0.9, \beta_2=0.95, weight~decay=0.1 β1=0.9,β2=0.95,weight decay=0.1);
  2. warmup 2000 step and cosine learning rate schedule;
  3. gradient clippping = 1.0;

一些加速的方法

  1. causal multi-head attention;
  2. reduce the amount of activations that recomputed during the backward pass.

2048块80G的A100训练21天.

结果

Common Sense Reasoning

请添加图片描述

zero-shot.

CSR : 基于问题和常识性选择, 让模型做出判断.

请添加图片描述

Closed-book Question Answering

请添加图片描述

请添加图片描述

不依赖于外部信息源, 只凭借训练时学习得到的信息完成问答任务.

自由文本的评估指标. exact match perfromance

Reading Comprehension

请添加图片描述

在这里插入图片描述

Massive Multitask Language Understanding

请添加图片描述

在这里插入图片描述

Mathematical reasoning 和 Code Generation就不再赘述.

Instruction Finetuning

待补充

附录

Question Answering

请添加图片描述
对于Natural Questions 和 TriviaQA 使用1-shot设定. 预先打印字符串:Answer these questions:\n在问题和答案之前.

Generations from LLaMA-65B

Without instruction finetuning.

Prompts are in bold.

Only present part of them.

请添加图片描述

请添加图片描述

Generations from LLaMA-I

请添加图片描述

Llama 2: Open Foundation and Fine-Tuned Chat Models

LLAMA2 : 新的训练数据组织形式, 更大的预训练语料库, 更长的上下文, grouped-query attention.

LLAMA2 : 针对对话场景的微调版本.

pretraining methodology

Pretraining Data

  1. a new mix of data , not including data from Meta’s products or services;
  2. 移除包含私人信息的数据;
  3. 2 trillion tokens and up-sampling the most factual sources.

Training Details

除了RMSNorm, RoPE and SwiGLU, 增加了GQA.

其余与LLaMA 1一致.

fine-tuning methodology

Supervised Fine-Tuning(SFT)

使用公开的instruction tuning data.

提取高质量的部分数据, 模型的效果仍然得到提升. Quality is All You Need.

发现人类写的注释和模型生成+人工检查的注释效果差不多.

微调细节:

  1. cosine learning rate schedule;
  2. initial lr = 2e-5;
  3. weight decay = 0.1;
  4. batch size = 64;
  5. sequence length = 4096.

Reinforcement Learning with Human Feedback (RLHF)

人类从模型的两个输出中选择喜欢的一个. 该反馈随后用于训练一个奖励模型. 该模型学习人类的偏好模式.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

右边是我女神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值