gpt、llama大模型模型结构细节探索

参考:

https://github.com/naklecha/llama3-from-scratch(一定要看看)

https://github.com/karpathy/build-nanogpt/blob/master/play.ipynb

视频:

https://www.youtube.com/watch?v=l8pRSuU81PU

https://tiktokenizer.vercel.app/ (可以查看场景大模型的tiktokenizer具体值encode与decode)

可以通过transformers加载模型查看具体结构和权重情况:

cpp 复制代码
from transformers import GPT2LMHeadModel

model_hf = GPT2LMHeadModel.from_pretrained("gpt2") # 124M
sd_hf = model_hf.state_dict()

for k, v in sd_hf.items():
    print(k, v.shape)

可以查看打印每层权重:

cpp 复制代码
sd_hf["transformer.wpe.weight"].view(-1)[:20]

import matplotlib.pyplot as plt
%matplotlib inline

plt.imshow(sd_hf["transformer.wpe.weight"], cmap="gray")
相关推荐
小李子呢02112 小时前
大模型是什么?
大模型·agent
无敌昊哥战神2 小时前
大模型(LLM)推理优化技术全景总结
python·算法·大模型
Fleshy数模2 小时前
基于 LangChain 实现 PDF 文档检索:从加载到向量检索全流程
人工智能·数据挖掘·langchain·大模型
Forrit3 小时前
Agent 回退机制
transformer
Li_yizYa3 小时前
【大模型篇】谈谈对于Function Calling、MCP、Skill的理解
ai·大模型
Ai马猴子3 小时前
迭代升级再塑旗舰标杆,gpt-5.2入驻 DMXAPI,综合智能表现越级强悍
gpt
HSunR3 小时前
神经网络 从函数到transformer学习笔记
神经网络·学习·transformer
沪漂阿龙4 小时前
面试题:Transformer 模型详解——核心创新、编码器解码器结构、位置编码、因果掩码与大模型基础全解析
人工智能·深度学习·transformer
ZGi.ai5 小时前
私有化大模型接入企业系统:SSO+权限+API网关完整方案
java·开发语言·大模型·私有化部署·sso·企业架构
时空无限5 小时前
transformer自注意力机制的核心理解
人工智能·深度学习·transformer