当前位置: 首页 > news >正文

怎么查看自己网站有没有做301专业seo站长工具

怎么查看自己网站有没有做301,专业seo站长工具,佛山网络公司哪家最好,余姚做网站设计欢迎关注我的CSDN:https://spike.blog.csdn.net/ 本文地址:https://spike.blog.csdn.net/article/details/143749468 免责声明:本文来源于个人知识与公开资料,仅用于学术交流,欢迎讨论,不支持转载。 影响 (…

欢迎关注我的CSDN:https://spike.blog.csdn.net/
本文地址:https://spike.blog.csdn.net/article/details/143749468

免责声明:本文来源于个人知识与公开资料,仅用于学术交流,欢迎讨论,不支持转载。


Img

影响 (多模态)大语言模型 参数量的主要网络模块,即 Linear、Embedding、Norm(LayerNorm or RMSNorm) 等 3 个部分,其中,多模态大模型还包括 Conv3D,手动计算参数量,与 PyTorch 直接计算保持一致。

PyTorch 源码:

def count_parameters(model):return sum(p.numel() for p in model.parameters() if p.requires_grad)

Qwen2-VL-7B-InstructQwen2-7B-InstructLlama-3.1-8B-Instruct 为例。

网络结构参数量:

  • Linear:参数矩阵,或者加上biasLinear(in_features=w, out_features=h, bias=True) 参数量是 x=w*h+h,当 bias=False, 则是 x=w*h
  • Embedding:认为是没有 bias 的 Linear。
  • Norm:
    • LayerNorm 包括 2 个可训练参数 γ \gamma γ β \beta β,假设 hidden_size 的大小为 h,hidden_size 每一维都有两个参数,即 2*hidden_size
    • RMSNorm 每 1 维则只有 1 个可训练参数 , 即 hidden_size
  • Conv3D:即 Conv3d(3, 1280, kernel_size=(2, 14, 14), stride=(2, 14, 14), bias=False),即参数量=输入维度*输出维度*卷积核3*1280*2*14*14=1505280
  • RotaryEmbedding、Activition 和 Dropout:旋转位置编码、激活函数、Dropout 都没有可训练参数

Llama-3.1-8B-Instruct 参数量:

128256 ∗ 4096 + 32 ∗ ( 4096 ∗ 4096 ∗ 2 + 4096 ∗ 1024 ∗ 2 + 4096 ∗ 14336 ∗ 3 + 2 ∗ 4096 ) + 4096 + 4096 ∗ 128256 = 8030261248 = 8 B 128256*4096 + 32*(4096*4096*2 + 4096*1024*2 + 4096*14336*3 + 2*4096) + 4096 + 4096*128256 = 8030261248 = 8B 1282564096+32(409640962+409610242+4096143363+24096)+4096+4096128256=8030261248=8B

即:

P a r a m e t e r s = E m b e d d i n g + l a y e r s ∗ ( L i n e a r Q K V O + L i n e a r m l p + R M S N o r m ) + R M S N o r m + L i n e a r Parameters = Embedding + layers*(Linear_{QKVO} + Linear_{mlp}+RMSNorm) + RMSNorm + Linear Parameters=Embedding+layers(LinearQKVO+Linearmlp+RMSNorm)+RMSNorm+Linear

计算参数量:[Info] parameters: 8030261248

大语言模型 Llama-3.1-8B-Instruct 的网络结构:

LlamaForCausalLM((model): LlamaModel((embed_tokens): Embedding(128256, 4096)(layers): ModuleList((0-31): 32 x LlamaDecoderLayer((self_attn): LlamaSdpaAttention((q_proj): Linear(in_features=4096, out_features=4096, bias=False)(k_proj): Linear(in_features=4096, out_features=1024, bias=False)(v_proj): Linear(in_features=4096, out_features=1024, bias=False)(o_proj): Linear(in_features=4096, out_features=4096, bias=False)(rotary_emb): LlamaRotaryEmbedding())(mlp): LlamaMLP((gate_proj): Linear(in_features=4096, out_features=14336, bias=False)(up_proj): Linear(in_features=4096, out_features=14336, bias=False)(down_proj): Linear(in_features=14336, out_features=4096, bias=False)(act_fn): SiLU())(input_layernorm): LlamaRMSNorm((4096,), eps=1e-05)(post_attention_layernorm): LlamaRMSNorm((4096,), eps=1e-05)))(norm): LlamaRMSNorm((4096,), eps=1e-05)(rotary_emb): LlamaRotaryEmbedding())(lm_head): Linear(in_features=4096, out_features=128256, bias=False)
)

多模态视觉大模型 Qwen2-VL-7B-Instruct 的网络结构:

Qwen2VLForConditionalGeneration((visual): Qwen2VisionTransformerPretrainedModel((patch_embed): PatchEmbed((proj): Conv3d(3, 1280, kernel_size=(2, 14, 14), stride=(2, 14, 14), bias=False))(rotary_pos_emb): VisionRotaryEmbedding()(blocks): ModuleList((0-31): 32 x Qwen2VLVisionBlock((norm1): LayerNorm((1280,), eps=1e-06, elementwise_affine=True)(norm2): LayerNorm((1280,), eps=1e-06, elementwise_affine=True)(attn): VisionSdpaAttention((qkv): Linear(in_features=1280, out_features=3840, bias=True)(proj): Linear(in_features=1280, out_features=1280, bias=True))(mlp): VisionMlp((fc1): Linear(in_features=1280, out_features=5120, bias=True)(act): QuickGELUActivation()(fc2): Linear(in_features=5120, out_features=1280, bias=True))))(merger): PatchMerger((ln_q): LayerNorm((1280,), eps=1e-06, elementwise_affine=True)(mlp): Sequential((0): Linear(in_features=5120, out_features=5120, bias=True)(1): GELU(approximate='none')(2): Linear(in_features=5120, out_features=3584, bias=True))))(model): Qwen2VLModel((embed_tokens): Embedding(152064, 3584)(layers): ModuleList((0-27): 28 x Qwen2VLDecoderLayer((self_attn): Qwen2VLSdpaAttention((q_proj): Linear(in_features=3584, out_features=3584, bias=True)(k_proj): Linear(in_features=3584, out_features=512, bias=True)(v_proj): Linear(in_features=3584, out_features=512, bias=True)(o_proj): Linear(in_features=3584, out_features=3584, bias=False)(rotary_emb): Qwen2VLRotaryEmbedding())(mlp): Qwen2MLP((gate_proj): Linear(in_features=3584, out_features=18944, bias=False)(up_proj): Linear(in_features=3584, out_features=18944, bias=False)(down_proj): Linear(in_features=18944, out_features=3584, bias=False)(act_fn): SiLU())(input_layernorm): Qwen2RMSNorm((3584,), eps=1e-06)(post_attention_layernorm): Qwen2RMSNorm((3584,), eps=1e-06)))(norm): Qwen2RMSNorm((3584,), eps=1e-06)(rotary_emb): Qwen2VLRotaryEmbedding())(lm_head): Linear(in_features=3584, out_features=152064, bias=False)
)

总参数量:[Info] parameters: 8291375616

  • 视觉模型的参数量:[Info] parameters model.visual: 675759104
  • 语言模型的参数量:[Info] parameters model.model: 7070619136 + [Info] parameters model.lm_head: 544997376

即:675759104(8.15%) + 7070619136(85.28%) + 544997376(6.57%) = 8291375616 = 8B

Qwen2-VL-7B-InstructQwen2VisionTransformerPretrainedModel 参数量:

  • patch_embed 参数量: 3*1280*2*14*14=1505280
  • blocks 参数量:[Info] parameters model.visual.blocks: 629678080
    • 详细计算公式:32*(1280*2*2 + (1280+1)*3840 + (1280+1)*1280 + 1280*5121 + 5120*1281)=629678080
  • merger 参数量:

合并计算公式:

3 ∗ 1280 ∗ 2 ∗ 14 ∗ 14 + 32 ∗ ( 1280 ∗ 2 ∗ 2 + ( 1280 + 1 ) ∗ 3840 + ( 1280 + 1 ) ∗ 1280 + 1280 ∗ 5121 + 5120 ∗ 1281 ) + 1280 ∗ 2 + 5120 ∗ 5121 + ( 5120 + 1 ) ∗ 3584 = 675759104 3*1280*2*14*14 + 32*(1280*2*2 + (1280+1)*3840 + (1280+1)*1280 + 1280*5121 + 5120*1281) + 1280*2 + 5120*5121 + (5120+1)*3584 \\ = 675759104 3128021414+32(128022+(1280+1)3840+(1280+1)1280+12805121+51201281)+12802+51205121+(5120+1)3584=675759104

Qwen2-VL-7B-InstructQwen2VLModel 参数量:

152064 ∗ 3584 + 28 ∗ ( ( 3584 + 1 ) ∗ 3584 + ( 3584 + 1 ) ∗ 512 ∗ 2 + 3584 ∗ 3584 + 3584 ∗ 18944 ∗ 3 + 2 ∗ 3584 ) + 3584 = 7070619136 3584 ∗ 152064 = 544997376 152064*3584 + 28*((3584+1)*3584 + (3584+1)*512*2 + 3584*3584 + 3584*18944*3 + 2*3584) + 3584 \\ = 7070619136 \\ 3584 * 152064 = 544997376 1520643584+28((3584+1)3584+(3584+1)5122+35843584+3584189443+23584)+3584=70706191363584152064=544997376

因此,Qwen2-VL-7B 的数据量完全对齐。

测试:

# 预训练模型, 查看其词表大小
import torch
import transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessorprint(f"[Info] transformers version: {transformers.__version__}")def count_parameters(model):return sum(p.numel() for p in model.parameters() if p.requires_grad)# ------------ Qwen2-VL-7B ----------- #
model_path = "[your path]/llm/Qwen/Qwen2-VL-7B-Instruct"
print(f"[Info] model_path: {model_path}")# Load the model in half-precision on the available device(s)
model = Qwen2VLForConditionalGeneration.from_pretrained(model_path, torch_dtype="auto", device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_path)
configuration = model.config
print(f"[Info] Qwen2-VL-7B vocab_size: {configuration.vocab_size}")
print(model)
print(f"[Info] parameters: {count_parameters(model)}")
print(f"[Info] parameters model.visual: {count_parameters(model.visual)}")
print(f"[Info] parameters model.model: {count_parameters(model.model)}")
print(f"[Info] parameters model.lm_head: {count_parameters(model.lm_head)}")
print(f"[Info] parameters model.visual.patch_embed: {count_parameters(model.visual.patch_embed)}")
print(f"[Info] parameters model.visual.blocks: {count_parameters(model.visual.blocks)}")
print(f"[Info] parameters model.visual.blocks[0].norm1: {count_parameters(model.visual.blocks[0].norm1)}")
print(f"[Info] parameters model.visual.blocks[0].norm2: {count_parameters(model.visual.blocks[0].norm2)}")
print(f"[Info] parameters model.visual.blocks[0].attn: {count_parameters(model.visual.blocks[0].attn)}")
print(f"[Info] parameters model.visual.blocks[0].mlp: {count_parameters(model.visual.blocks[0].mlp)}")
# ------------ Qwen2-VL-7B ----------- ## ------------ Qwen2-7B ----------- #
model_path = "[your path]/llm/Qwen/Qwen2-7B-Instruct"
print(f"[Info] model_path: {model_path}")device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_path)
print(f"[Info] Qwen2-7B vocab_size: {tokenizer.vocab_size}")
print(model)
print(f"[Info] parameters: {count_parameters(model)}")
# ------------ Qwen2-7B ----------- ## ------------ Llama-3.1-8B ----------- #
model_path = "[your path]/llm/Meta-Llama-3.1-8B-Instruct"
print(f"[Info] model_path: {model_path}")
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path,torch_dtype=torch.bfloat16,device_map="auto",
)
print(f"[Info] Llama-3.1-8B vocab_size: {tokenizer.vocab_size}")
print(model)
print(f"[Info] parameters: {count_parameters(model)}")
# ------------ Llama-3.1-8B ----------- #

Qwen2-7B 的参数量是 7615616512,即 7070619136 + 544997376 = 7615616512

参考:

  • 大模型的参数量是如何计算的
  • 大模型参数量如何计算
  • 如何根据模型结构,计算大模型的参数量?
http://www.hkea.cn/news/60281/

相关文章:

  • 网站开发自我介绍seo报告
  • 网站应用软件设计海口seo网络公司
  • 武汉站建设深圳网站开发制作
  • 网站建设的平台分析北京seo技术
  • 手表价格网站百度推广天津总代理
  • 如何将域名和网站绑定排名seo怎么样
  • 旅游网站推广方案色盲测试图
  • 现在开发个网站多少钱安全优化大师
  • 网站开发工程师工资多少百度统计工具
  • 征信报告优化大师好用吗
  • 一个ip地址做多个网站网络营销公司是做什么的
  • 赤峰网站建设公司旅行网站排名
  • seo网站优化工具软件拉新推广平台
  • 政府网站设计方案无锡网站制作优化
  • 社交网站盈利吗如何在各种网站投放广告
  • 建设工程合同民法典东莞快速优化排名
  • 泗县口碑营销互联网营销推荐咨询青岛seo计费
  • 做电影网站用什么服务器中文域名注册官网入口
  • 做网站那里好win10系统优化工具
  • 做外贸上哪些网站找客户口碑营销的概念是什么
  • 外贸建站magento百度地图推广
  • 做网站和管理系统全网热度指数
  • 网站的压力测试怎么做网络营销的目的是什么
  • 网站建设如何更加稳定seo优化前景
  • 网站速度诊断 慢seo chinaz
  • 企业网站建设合同搜索引擎优化关键词的处理
  • 做翻译的网站私人做网站
  • 广东两学一做考学网站百度网盘app免费下载安装老版本
  • 淄博有做网站的吗百度推广有哪些形式
  • 增值税怎么算免费seo快速排名系统