从零手搓中文大模型|Day04|模型参数配置和训练启动
今天我们来深入研究一下模型的配置。在基于 litgpt 框架进行大语言模型训练时,配置文件是连接数据、架构与训练逻辑的核心枢纽。
1. 训练配置文件概览
litgpt 使用的配置文件格式为 YAML,与 transformers 库的配置方式略有不同。其仓库中提供了一些预训练所用的 YAML 配置文件样例,主要用于需要自定义模型架构的场景。此外,litgpt 也内置了一些 Hugging Face 上的现成模型,可以直接拿来使用,但在从头训练或微调特定任务时,自定义配置更为常见。
以下是本次定义的一个完整配置文件,涵盖了模型架构、训练策略、数据加载及优化器设置等关键部分。
# The name of the model to pretrain. Choose from names in ``litgpt.config``.
model_name: microstories
# A ``litgpt.Config`` object to define the model architecture.
model_config:
name: microstories
hf_config: {}
scale_embeddings: false
block_size: 512
padded_vocab_size: 65024
vocab_size: 64798
n_layer: 6
n_head: 6
n_query_groups: 6
n_embd: 512
head_size: 48
rotary_percentage: 1.0
parallel_residual: false
bias: false
norm_class_name: RMSNorm
mlp_class_name: LLaMAMLP
intermediate_size: 768
# Directory in which to save checkpoints and logs.


