拆分transformer.py为独立模块

按Transformer架构组件拆分:
- utils.py: 激活函数和掩码工具
- layers.py: 基础层(Linear, LayerNorm)
- attention.py: 多头注意力机制
- feedforward.py: 前馈网络
- block.py: Transformer编码器块
- model.py: SimpleTransformer模型
- inference.py: 推理引擎
- 删除旧的transformer.py文件
This commit is contained in:
2026-07-17 11:23:11 +08:00
parent c57a9bf9e6
commit 7856f5bf4c
10 changed files with 509 additions and 439 deletions
+9 -1
View File
@@ -4,7 +4,15 @@ A minimal Transformer implementation using NumPy with **KV Cache** support for e
## Files
- `transformer.py` - Core Transformer model implementation with KV Cache
- `transformer/` - Transformer model package (按架构组件拆分)
- `__init__.py` - 包初始化,导出所有组件
- `utils.py` - 激活函数和掩码工具
- `layers.py` - 基础层(Linear, LayerNorm)
- `attention.py` - 多头注意力机制
- `feedforward.py` - 前馈网络
- `block.py` - Transformer编码器块
- `model.py` - SimpleTransformer模型
- `inference.py` - 推理引擎
- `example.py` - Usage examples (training & inference)
## Usage