初始化项目,由ModelHub XC社区提供模型
Model: aicinema69/gpt2-growing Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
125
README.md
Normal file
125
README.md
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
---
|
||||||
|
library_name: transformers
|
||||||
|
base_model:
|
||||||
|
- openai-community/gpt2
|
||||||
|
---
|
||||||
|
# Growing LLM Model Card
|
||||||
|
|
||||||
|
## Model Description
|
||||||
|
|
||||||
|
The **Growing LLM** is a GPT-2 based language model that implements neural plasticity-inspired dynamic growth during training. This model starts with a pre-trained GPT-2 (124M parameters) and dynamically adds new transformer blocks while freezing the original parameters, allowing the model to acquire new knowledge without catastrophic forgetting.
|
||||||
|
|
||||||
|
### Key Features
|
||||||
|
|
||||||
|
- **Dynamic Growth**: Adds new transformer blocks during training
|
||||||
|
- **Knowledge Preservation**: Freezes original parameters to retain pre-trained knowledge
|
||||||
|
- **Flexible Triggers**: Supports fixed schedule and plateau detection growth triggers
|
||||||
|
- **Regularization Options**: Supports Knowledge Distillation and Elastic Weight Consolidation (EWC)
|
||||||
|
- **Comprehensive Metrics**: Tracks training, validation, growth events, and scaling analysis
|
||||||
|
|
||||||
|
## Training Details
|
||||||
|
|
||||||
|
### Training Data
|
||||||
|
- Dataset: WikiText-2-raw-v1
|
||||||
|
- Max sequence length: 128 tokens
|
||||||
|
|
||||||
|
### Training Configuration
|
||||||
|
- Base model: GPT-2 (124M parameters)
|
||||||
|
- Learning rate: 5e-5
|
||||||
|
- Batch size: 8
|
||||||
|
- Optimizer: AdamW with weight decay 0.01
|
||||||
|
- Max steps: 2000
|
||||||
|
- Growth frequency: Every 500 steps
|
||||||
|
- Maximum growth events: 3
|
||||||
|
|
||||||
|
### Growth Mechanism
|
||||||
|
1. **Fixed Schedule**: Grow every N training steps
|
||||||
|
2. **Plateau Detection**: Grow when validation loss shows no improvement for Y steps
|
||||||
|
|
||||||
|
### Regularization (Optional)
|
||||||
|
- **Knowledge Distillation**: Uses teacher-student architecture with temperature scaling
|
||||||
|
- **Elastic Weight Consolidation (EWC)**: Penalizes changes to important parameters
|
||||||
|
|
||||||
|
## Model Architecture
|
||||||
|
|
||||||
|
- Base: GPT-2 (12 layers, 12 heads, 768 hidden dim)
|
||||||
|
- Growth: Added 3 new transformer blocks (one per growth event)
|
||||||
|
- Final: 15 layers, 145.7M total parameters
|
||||||
|
|
||||||
|
## Training Results
|
||||||
|
|
||||||
|
### Summary Metrics
|
||||||
|
| Metric | Initial | Final |
|
||||||
|
|--------|---------|-------|
|
||||||
|
| Training Loss | 7.16 | 1.95 |
|
||||||
|
| Validation Loss | 6.99 | 2.03 |
|
||||||
|
| Validation Perplexity | ~1000 | 7.58 |
|
||||||
|
| Total Parameters | 124.4M | 145.7M |
|
||||||
|
|
||||||
|
### Training Time
|
||||||
|
- Total time: ~60 minutes (3596 seconds)
|
||||||
|
- Best validation loss: 2.00
|
||||||
|
- Best validation perplexity: 7.42
|
||||||
|
|
||||||
|
### Growth Events
|
||||||
|
| Growth # | Step | Layers | Parameters Added | Val Loss Delta |
|
||||||
|
|---------|------|--------|-----------------|----------------|
|
||||||
|
| 1 | 500 | 12 → 13 | +7.1M | +0.00003 |
|
||||||
|
| 2 | 1000 | 13 → 14 | +7.1M | +0.00002 |
|
||||||
|
| 3 | 1500 | 14 → 15 | +7.1M | +0.000001 |
|
||||||
|
|
||||||
|
|
||||||
|
### RESULTS SUMMARY
|
||||||
|
|
||||||
|
| Model | Perplexity | Loss |
|
||||||
|
|-------|------------|------|
|
||||||
|
| Base GPT-2 | 56.39 | 4.0323 |
|
||||||
|
| Growing LLM | 33.39 | 3.5082 |
|
||||||
|
|
||||||
|
Perplexity improvement: 40.8%
|
||||||
|
|
||||||
|
**Key Observation**: The validation loss delta after each growth event is minimal (~0.00003), demonstrating successful knowledge retention. The model continues to learn new capabilities without catastrophic forgetting.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```python
|
||||||
|
from transformers import GPT2LMHeadModel, AutoTokenizer
|
||||||
|
|
||||||
|
# Load model and tokenizer
|
||||||
|
model = GPT2LMHeadModel.from_pretrained("aicinema69/gpt2-growing")
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained("aicinema69/gpt2-growing")
|
||||||
|
|
||||||
|
# Generate text
|
||||||
|
input_text = "Once upon a time"
|
||||||
|
inputs = tokenizer(input_text, return_tensors="pt")
|
||||||
|
outputs = model.generate(**inputs, max_new_tokens=50)
|
||||||
|
print(tokenizer.decode(outputs[0]))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
- Growth events may cause temporary performance dips that recover with continued training
|
||||||
|
- Requires sufficient training data to benefit from additional parameters
|
||||||
|
- More parameters = higher memory and compute requirements
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This model is based on GPT-2 which has the [OpenAI GPT-2 License](https://github.com/openai/gpt-2/blob/master/LICENSE).
|
||||||
|
|
||||||
|
## Citation
|
||||||
|
|
||||||
|
If you use this model in your research, please cite:
|
||||||
|
|
||||||
|
```bibtex
|
||||||
|
@misc{growing_llm,
|
||||||
|
author = {Satyam Singh},
|
||||||
|
title = {Growing LLM: Dynamic Model Growth for Continual Learning},
|
||||||
|
year = {2026},
|
||||||
|
publisher = {HuggingFace},
|
||||||
|
howpublished = {\url{https://huggingface.co/aicinema69/gpt2-growing}}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
For questions or issues, please open a GitHub issue or contact the model author.
|
||||||
41
config.json
Normal file
41
config.json
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"activation_function": "gelu_new",
|
||||||
|
"add_cross_attention": false,
|
||||||
|
"architectures": [
|
||||||
|
"GPT2LMHeadModel"
|
||||||
|
],
|
||||||
|
"attn_pdrop": 0.1,
|
||||||
|
"bos_token_id": 50256,
|
||||||
|
"dtype": "float32",
|
||||||
|
"embd_pdrop": 0.1,
|
||||||
|
"eos_token_id": 50256,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"layer_norm_epsilon": 1e-05,
|
||||||
|
"model_type": "gpt2",
|
||||||
|
"n_ctx": 1024,
|
||||||
|
"n_embd": 768,
|
||||||
|
"n_head": 12,
|
||||||
|
"n_inner": null,
|
||||||
|
"n_layer": 12,
|
||||||
|
"n_positions": 1024,
|
||||||
|
"pad_token_id": null,
|
||||||
|
"reorder_and_upcast_attn": false,
|
||||||
|
"resid_pdrop": 0.1,
|
||||||
|
"scale_attn_by_inverse_layer_idx": false,
|
||||||
|
"scale_attn_weights": true,
|
||||||
|
"summary_activation": null,
|
||||||
|
"summary_first_dropout": 0.1,
|
||||||
|
"summary_proj_to_labels": true,
|
||||||
|
"summary_type": "cls_index",
|
||||||
|
"summary_use_proj": true,
|
||||||
|
"task_specific_params": {
|
||||||
|
"text-generation": {
|
||||||
|
"do_sample": true,
|
||||||
|
"max_length": 50
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tie_word_embeddings": true,
|
||||||
|
"transformers_version": "5.2.0",
|
||||||
|
"use_cache": true,
|
||||||
|
"vocab_size": 50257
|
||||||
|
}
|
||||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"_from_model_config": true,
|
||||||
|
"bos_token_id": 50256,
|
||||||
|
"eos_token_id": 50256,
|
||||||
|
"transformers_version": "5.2.0"
|
||||||
|
}
|
||||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:c7d00560d8910fbed77ffad4065dee5011c41ba401b1064e749c498ba9e20373
|
||||||
|
size 497774208
|
||||||
250306
tokenizer.json
Normal file
250306
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
12
tokenizer_config.json
Normal file
12
tokenizer_config.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"add_prefix_space": false,
|
||||||
|
"backend": "tokenizers",
|
||||||
|
"bos_token": "<|endoftext|>",
|
||||||
|
"eos_token": "<|endoftext|>",
|
||||||
|
"errors": "replace",
|
||||||
|
"is_local": false,
|
||||||
|
"model_max_length": 1024,
|
||||||
|
"pad_token": "<|endoftext|>",
|
||||||
|
"tokenizer_class": "GPT2Tokenizer",
|
||||||
|
"unk_token": "<|endoftext|>"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user