readme
Browse files- README.md +79 -0
- assets/leaderboard.png +0 -0
README.md
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- zh
|
5 |
+
library_name: transformers
|
6 |
+
tags:
|
7 |
+
- Long Context
|
8 |
+
- chatglm
|
9 |
+
- llama
|
10 |
+
datasets:
|
11 |
+
- THUDM/LongAlign-10k
|
12 |
+
- THUDM/LongBench
|
13 |
+
---
|
14 |
+
# LongAlign-7B-64k
|
15 |
+
|
16 |
+
<p align="center">
|
17 |
+
🤗 <a href="https://huggingface.co/datasets/THUDM/LongAlign-10k" target="_blank">[LongAlign Dataset] </a> • 💻 <a href="https://github.com/THUDM/LongAlign" target="_blank">[Github Repo]</a> • 📃 <a href="https://arxiv.org/" target="_blank">[LongAlign Paper]</a>
|
18 |
+
</p>
|
19 |
+
|
20 |
+
**LongAlign** is the first full recipe for LLM alignment on long context. We propose the **LongAlign-10k** dataset, containing 10,000 long instruction data of 8k-64k in length. We investigate on trianing strategies, namely **packing (with loss weighting) and sorted batching**, which are all implemented in our code. For real-world long context evaluation, we introduce **Chat-LongBench** that evaluate the instruction-following capability on queries of 10k-100k length.
|
21 |
+
|
22 |
+
## All Models
|
23 |
+
|
24 |
+
We open-sourced the following list of models:
|
25 |
+
|
26 |
+
|Model|Huggingface Repo|Description|
|
27 |
+
|---|---|---|
|
28 |
+
|**LongAlign-6B-64k-base**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/LongAlign-6B-64k-base) | **ChatGLM3-6B** with an extended 64k context window |
|
29 |
+
|**LongAlign-6B-64k**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/LongAlign-6B-64k) | Chat model by LongAlign training on LongAlign-6B-64k-base|
|
30 |
+
|**LongAlign-7B-64k-base**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/LongAlign-7B-64k-base) | **Llama-2-7B** with an extended 64k context window |
|
31 |
+
|**LongAlign-7B-64k**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/LongAlign-7B-64k) | Chat model by LongAlign training on LongAlign-7B-64k-base|
|
32 |
+
|**LongAlign-13B-64k-base**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/LongAlign-13B-64k-base) | **Llama-2-13B** with an extended 64k context window |
|
33 |
+
|**LongAlign-13B-64k**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/LongAlign-13B-64k) | Chat model by LongAlign training on LongAlign-13B-64k-base|
|
34 |
+
|**ChatGLM3-6B-128k**| [🤗 Huggingface Repo](https://huggingface.co/THUDM/chatglm3-6b-128k) | **ChatGLM3-6B** with a 128k context window|
|
35 |
+
|
36 |
+
![](assets/leaderboard.png)
|
37 |
+
|
38 |
+
## Model usage
|
39 |
+
Chat prompt template for LongAlign-6B-64k:
|
40 |
+
```text
|
41 |
+
[Round 1]
|
42 |
+
|
43 |
+
问:Hi!
|
44 |
+
|
45 |
+
答:Hello! What can I assist you today?
|
46 |
+
|
47 |
+
[Round 2]
|
48 |
+
|
49 |
+
问:What should I do if I can't sleep at night?
|
50 |
+
|
51 |
+
答:
|
52 |
+
```
|
53 |
+
Chat prompt template for LongAlign-7B-64k and LongAlign-13B-64k:
|
54 |
+
```text
|
55 |
+
[INST]Hi![/INST]Hello! What can I assist you today?
|
56 |
+
|
57 |
+
[INST]What should I do if I can't sleep at night?[/INST]
|
58 |
+
```
|
59 |
+
ChatGLM3-6B-128k uses the same prompt template as [ChatGLM3-6B](https://huggingface.co/THUDM/chatglm3-6b).
|
60 |
+
|
61 |
+
A simple demo for deployment of the model:
|
62 |
+
```python
|
63 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
64 |
+
import torch
|
65 |
+
tokenizer = AutoTokenizer.from_pretrained("THUDM/LongAlign-6B-64k", trust_remote_code=True)
|
66 |
+
model = AutoModelForCausalLM.from_pretrained("THUDM/LongAlign-6B-64k", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
|
67 |
+
model = model.eval()
|
68 |
+
query = open("assets/paper.txt").read() + "\n\nPlease summarize the paper."
|
69 |
+
response, history = model.chat(tokenizer, query, history=[], max_new_tokens=512, temperature=1)
|
70 |
+
print(response)
|
71 |
+
```
|
72 |
+
|
73 |
+
## Citation
|
74 |
+
|
75 |
+
If you find our work useful, please consider citing LongAlign:
|
76 |
+
|
77 |
+
```
|
78 |
+
|
79 |
+
```
|
assets/leaderboard.png
ADDED