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")
相关推荐
Hcoco_me4 分钟前
大模型面试题39:KV Cache 完全指南
人工智能·深度学习·自然语言处理·transformer·word2vec
斯外戈的小白19 分钟前
【NLP】Transformer在pytorch 的实现+情感分析案例+生成式任务案例
pytorch·自然语言处理·transformer
万俟淋曦38 分钟前
【论文速递】2025年第51周(Dec-14-20)(Robotics/Embodied AI/LLM)
人工智能·深度学习·机器人·大模型·论文·robotics·具身智能
WWZZ202543 分钟前
SLAM进阶——数据集
人工智能·计算机视觉·机器人·大模型·slam·具身智能
vibag1 小时前
RAG项目实践
python·语言模型·langchain·大模型
万俟淋曦1 小时前
【论文速递】2025年第49周(Nov-30-Dec-06)(Robotics/Embodied AI/LLM)
人工智能·深度学习·机器学习·机器人·大模型·论文·具身智能
哈哈你是真的厉害1 小时前
Windows系统通过wsl Ubuntu24.04本地安装OpenJiuwen Studio的完整安装教程
人工智能·华为·ai·大模型·agent·智能体·openjiuwen
百***24372 小时前
Gemini 3.0 Pro 对决 GPT-5.2:编程场景深度横评与选型指南
gpt
谁怕平生太急10 小时前
Mobile GUI Agent相关学习资料整理
人工智能·大模型
大猪宝宝学AI13 小时前
【AI Infra】BF-PP:广度优先流水线并行
人工智能·性能优化·大模型·模型训练