Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- EleutherAI/the_pile_deduplicated
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# Hybrid RetNet
|
| 10 |
+
|
| 11 |
+
This is a hybrid architecture between self-attention based Transformer and [RetNet](https://arxiv.org/abs/2307.08621), where only the 2nd and middle layer is multi-head attention, and otherwise RetNet.
|
| 12 |
+
|
| 13 |
+
This is the model weight accompanying the paper [Cross-Architecture Transfer Learning for Linear-Cost Inference Transformers](https://arxiv.org/abs/2404.02684v1),
|
| 14 |
+
in which new Linear-Cost Inference models (e.g. RetNet) are not trained from scratch but transfer shared weight components from other PTLMs.
|
| 15 |
+
The model's input/output embeddings, MLP weights, Layer Norms, Attention Output Projections ($W_O$) has been transferred from [pythia-1B](https://huggingface.co/EleutherAI/pythia-1b). For more detail, please refer to the paper.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
## Model Details
|
| 19 |
+
|
| 20 |
+
### Model Description
|
| 21 |
+
|
| 22 |
+
- **Developed by:** NucleusAI, Sehyun Choi
|
| 23 |
+
- **Model type:** RetNet & Transformer Hybrid
|
| 24 |
+
|
| 25 |
+
### Model Sources
|
| 26 |
+
|
| 27 |
+
- **Repository:** [lit_llm_train](https://github.com/syncdoth/lit_llm_train)
|
| 28 |
+
- **Paper:** [Cross-Architecture Transfer Learning for Linear-Cost Inference Transformers](https://arxiv.org/abs/2404.02684v1)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
## How to Get Started with the Model
|
| 32 |
+
|
| 33 |
+
Use the code below to get started with the model.
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
import torch
|
| 37 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 38 |
+
|
| 39 |
+
torch.set_default_device("cuda")
|
| 40 |
+
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained("NucleusAI/RetNet-1B-Hybrid-XATL", torch_dtype="auto", trust_remote_code=True)
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained("NucleusAI/RetNet-1B-Hybrid-XATL", trust_remote_code=True) # same as EleutherAI/pythia-1B
|
| 43 |
+
|
| 44 |
+
inputs = tokenizer("Hi there!", return_tensors="pt", return_attention_mask=False)
|
| 45 |
+
|
| 46 |
+
outputs = model.generate(**inputs, max_length=200)
|
| 47 |
+
text = tokenizer.batch_decode(outputs)[0]
|
| 48 |
+
print(text)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Training Data
|
| 52 |
+
|
| 53 |
+
The model has been trained with [pile_dedup](EleutherAI/the_pile_deduplicated) dataset, in favor of comparison with the same sized pythia models.
|