English
File size: 1,984 Bytes
ac5f02d
 
 
 
 
 
 
 
 
 
 
 
 
 
bb32640
ac5f02d
 
 
 
 
 
 
 
 
 
 
0f48bd8
ac5f02d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
license: apache-2.0
datasets:
- EleutherAI/the_pile_deduplicated
language:
- en
---

# Hybrid RetNet

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.

This is the model weight accompanying the paper [Cross-Architecture Transfer Learning for Linear-Cost Inference Transformers](https://arxiv.org/abs/2404.02684v1), 
in which new Linear-Cost Inference models (e.g. RetNet) are not trained from scratch but transfer shared weight components from other PTLMs. 
The model's input/output embeddings, MLP weights, & Layer Norms has been transferred from [pythia-1B](https://huggingface.co/EleutherAI/pythia-1b). For more detail, please refer to the paper.


## Model Details

### Model Description

- **Developed by:** NucleusAI, Sehyun Choi
- **Model type:** RetNet & Transformer Hybrid

### Model Sources

- **Repository:** [RetNet-XATL](https://github.com/syncdoth/RetNet-XATL)
- **Paper:** [Cross-Architecture Transfer Learning for Linear-Cost Inference Transformers](https://arxiv.org/abs/2404.02684v1)


## How to Get Started with the Model

Use the code below to get started with the model.

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

torch.set_default_device("cuda")

model = AutoModelForCausalLM.from_pretrained("NucleusAI/RetNet-1B-Hybrid-XATL", torch_dtype="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("NucleusAI/RetNet-1B-Hybrid-XATL", trust_remote_code=True)  # same as EleutherAI/pythia-1B

inputs = tokenizer("Hi there!", return_tensors="pt", return_attention_mask=False)

outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]
print(text)
```

## Training Data

The model has been trained with [pile_dedup](EleutherAI/the_pile_deduplicated) dataset, in favor of comparison with the same sized pythia models.