暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
31-大模型(LLMs)推理面.pdf
35
6页
0次
2025-07-07
5墨值下载
大模型(LLMs)推理面
来自: AiGC面试宝典
宁静致远 20231022 22:43
1. 为什么大模型推理时显存涨的那么多还一直占着?
2. 大模型在gpucpu上推理速度如何?
7B量级下:
3. 推理速度上,int8fp16比起来怎么样?
根据实践经验,int8模式一般推理会明显变慢(huggingface的实现)
4. 大模型有推理能力吗?
大模型有推理能力。有下面2个方面的体现:
ChatGPT拥有in-context correction的能力,即如果说错了,给出矫正,ChatGPT听懂错在哪儿了,并向正确
的方向修正。in-context correction要比in-context learning难了太多,描述越详细清楚,ChatGPT回答得越好。
要知道,越详细的描述,在预训练的文本里越难匹配到的。
大模型(LLMs)推理面
1. 为什么大模型推理时显存涨的那么多还一直占着?
2. 大模型在gpucpu上推理速度如何?
3. 推理速度上,int8fp16比起来怎么样?
4. 大模型有推理能力吗?
5. 大模型生成时的参数怎么设置?
6. 有哪些省内存的大语言模型训练/微调/推理方法?
6.1 如何 估算模型所需的RAM
6.2 Fp16-mixed precision
6.3 Int8-bitsandbytes
6.4 LoRA
6.5 Gradient Checkpointing
6.6 Torch FSDP+CPU offload
7. 如何让大模型输出合规化
8. 应用模式变更
9. 模型输出的分布比较稀疏,怎么处理?
1. 首先,序列太长了,有很多Q/K/V
2. 其次,因为是逐个预测next token,每次要缓存K/V加速解码。
cpu推理速度约10token/s
单卡A60008AMD的推理速度通常为 10:1
扫码加
查看更多
在询问ChatGPT互联网上并不存在内容的时候,能给出较好答案(如用ChatGPT学建模);ChatGPT能通过信
息猜你心中的想法;你可以制定一个全新的游戏规则让ChatGPT和你玩,ChatGPT可以理解。
5. 大模型生成时的参数怎么设置?
生成模型预测调参建议:
建议去调整下 top_p, num_beams, repetition_renalty, temperature, do_sample=True;
数据生成有重复,调高repetition_renalty
生成任务表达单一的,样本也不多的,可适当调低 temperature,生成的样子跟训练集的比较像;如果要复现训
练集的效果,temperature=0.01即可。
以上是经验参数,具体调参根据任务而定,不是固定的。
6. 有哪些省内存的大语言模型训练/微调/推理方法?
举例来说,即使 RTX 3090 有着 24GB RAM,是除了 A100 之外显存最大的显卡。但使用一块 RTX 3090
然无法 fp32 精度训练最小号的 LLaMA-6B
参数解释:
top_p=0.9,
#Moderately increase the probability threshold of nucleus sampling to increase the
quantity of candidate tokens and increase generation diversity.
temperature=1.0,
#The previous low temperature parameter could lead to a severe polarization in the
probability distribution of generated words, which degenerates the generation
strategy into greedy decoding.
do_sample=True,
#do_sample parameter is set to False by default. After setting to True, the
generation methods turn into beam-search multinomial sampling decoding strategy.
no_repeat_ngram_size=6,
#Configure the probability of the next repeating n-gram to 0, to ensure that there
are no n-grams appearing twice. This setting is an empirical preliminary
exploration.
repetition_penalty=1.8,
#For words that have appeared before, in the subsequent prediction process, we
reduce the probability of their reoccurrence by introducing the repetition_penalty
parameter. This setting is an empirical preliminary exploration.
动机:大模型(LLMs)现在是 NLP 领域的最主流方法之一,但是大模型的训练/微调/推理需要的内存也越来
越多。
Memory-Efficient LLMs 的训练/微调/推理方法
of 6
5墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜