llama2 代码实验记录

torchrun分布式启动,所以要想在云端的环境下在本地的IDE上debug,需要设置一下,具体可以参考这里,需要传入的路径参数全部使用绝对路径。

目录

1、传入的句子

2、tokenizer 的tokenization

3、model的主要组成部分

4、过程中自己的小实验

总结

模型结构(测试只搭建了16层 model)


1、传入的句子

即prompts,实例中的如下所示

['I believe the meaning of life is', 'Simply put, the theory of relativity states that ', 'A brief message congratulating the team on the launch:\n\n        Hi everyone,\n        \n        I just ', 'Translate English to French:\n        \n        sea otter => loutre de mer\n        peppermint => menthe poivrée\n        plush girafe => girafe peluche\n        cheese =>']

2、tokenizer 的tokenization

示例如下 

# 传入
'I believe the meaning of life is'

# tokenizer
[306, 4658, 278, 6593, 310, 2834, 338]

# 加入bos后
[1, 306, 4658, 278, 6593, 310, 2834, 338]
# 传入
'Simply put, the theory of relativity states that '

# 
[3439, 17632, 1925, 29892, 278, 6368, 310, 14215, 537, 5922, 393, 29871]

#
[1, 3439, 17632, 1925, 29892, 278, 6368, 310, 14215, 537, 5922, 393, 29871]

 每个句子都被tokenizer用向量来表示。不过发现并不是逐词对应一个编码,有的对应了两个。其实这就涉及了sentencepiece的原理,见这里。由于兴趣使然,继续探索了一下

'I believe the meaning of life is'
[306, 4658, 278, 6593, 310, 2834, 338]
'I believe, the meaning of life is '
[306, 4658, 29892, 278, 6593, 310, 2834, 338, 29871]

 嗯,可以确定除了单词外,标点符号和空格也算做句子的一个部分。

'Simply' >> [3439, 17632]
'simply' >>[3763]

'Big' >>[7997]
'big' >>[4802]

不再继续探索了,详细的去查看sentencepiece原理,以及字节对编码 (BPE) (byte-pair-encoding (BPE)

3、model的主要组成部分

1、RSMNorm

一种标准化方法,详见这里

2、注意力运算

transformer decoder,应用掩码mask,主要的是采用RoPE位置编码方式,见

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

匿名的魔术师

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

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

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

打赏作者

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

抵扣说明:

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

余额充值