Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
---
|
4 |
+
# GeLinear
|
5 |
+
|
6 |
+
GeLinear is the implementation of [LoLCATs](https://arxiv.org/pdf/2410.10254), but with Gemma 2 model.
|
7 |
+
Unlike the original LoLCATs approach that linearizes all attention layers, I focuses on linearizing only the global attention layer, while retaining Gemma 2’s built-in Sliding Window Attention (SWA) for local context (since the time complexity for this already scaled linearly with sequence length).
|
8 |
+
|
9 |
+
To run the model:
|
10 |
+
```python
|
11 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
12 |
+
model = AutoModelForCausalLM.from_pretrained("jacksonkek/GeLinear",trust_remote_code=True,torch_dtype=torch.bfloat16,device_map="sequential")
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained("jacksonkek/GeLinear")
|
14 |
+
|
15 |
+
x = "tell me a joke"
|
16 |
+
input_text = [{"role":"user","content":x}]
|
17 |
+
input_ids = tokenizer.apply_chat_template(input_text, add_generation_prompt=True,return_tensors="pt").to("cuda")
|
18 |
+
text_streamer = TextStreamer(tokenizer)
|
19 |
+
_ = model.generate(input_ids, streamer = text_streamer, do_sample=False,max_new_tokens = 8192)
|
20 |
+
|
21 |
+
```
|