Update README.md
Browse files
README.md
CHANGED
@@ -10,4 +10,50 @@ language:
|
|
10 |
library_name: transformers
|
11 |
---
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
library_name: transformers
|
11 |
---
|
12 |
|
13 |
+
## MiniMA-3B
|
14 |
+
|
15 |
+
📑 [arXiv]() | 🤗 [HuggingFace](https://huggingface.co/GeneZC/MiniMA-3B) | 🤖 [ModelScope]()
|
16 |
+
|
17 |
+
A language model distilled from an adapted version of LLaMA2-7B following "Towards the Law of Capacity Gap in Distilling Language Models".
|
18 |
+
|
19 |
+
Establishing a new compute-performance pareto frontier.
|
20 |
+
|
21 |
+
<img src="./teaser_a.jpg" alt="teaser_a" width="400" />
|
22 |
+
|
23 |
+
The following is an example code snippet to use MiniMA-3B:
|
24 |
+
|
25 |
+
```python
|
26 |
+
import torch
|
27 |
+
|
28 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
29 |
+
|
30 |
+
# MiniMA
|
31 |
+
tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniMA-3B", use_fast=False)
|
32 |
+
# GPU.
|
33 |
+
model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
|
34 |
+
# CPU.
|
35 |
+
# model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()
|
36 |
+
|
37 |
+
prompt = "Question: Sherrie tells the truth. Vernell says Sherrie tells the truth. Alexis says Vernell lies. Michaela says Alexis tells the truth. Elanor says Michaela tells the truth. Does Elanor tell the truth?\nAnswer: No\n\nQuestion: Kristian lies. Sherrie says Kristian lies. Delbert says Sherrie lies. Jerry says Delbert tells the truth. Shalonda says Jerry tells the truth. Does Shalonda tell the truth?\nAnswer: No\n\nQuestion: Vina tells the truth. Helene says Vina lies. Kandi says Helene tells the truth. Jamey says Kandi lies. Ka says Jamey lies. Does Ka tell the truth?\nAnswer: No\n\nQuestion: Christie tells the truth. Ka says Christie tells the truth. Delbert says Ka lies. Leda says Delbert tells the truth. Lorine says Leda tells the truth. Does Lorine tell the truth?\nAnswer:"
|
38 |
+
input_ids = tokenizer([prompt]).input_ids
|
39 |
+
output_ids = model.generate(
|
40 |
+
torch.as_tensor(input_ids).cuda(),
|
41 |
+
do_sample=True,
|
42 |
+
temperature=0.7,
|
43 |
+
max_new_tokens=1024,
|
44 |
+
)
|
45 |
+
output_ids = output_ids[0][len(input_ids[0]):]
|
46 |
+
output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
|
47 |
+
# output: "No"
|
48 |
+
```
|
49 |
+
|
50 |
+
## Bibtex
|
51 |
+
|
52 |
+
```bibtex
|
53 |
+
@article{zhang2023law,
|
54 |
+
title={Towards the Law of Capacity Gap in Distilling Language Models},
|
55 |
+
author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
|
56 |
+
year={2023},
|
57 |
+
url={}
|
58 |
+
}
|
59 |
+
```
|