GeneZC commited on
Commit
c69c613
1 Parent(s): b40afb9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -0
README.md CHANGED
@@ -1,3 +1,69 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ - zh
6
+ library_name: transformers
7
+ widget:
8
+ - text: "<s> [|User|] Hi 👋 </s>[|Assistant|]"
9
  ---
10
+
11
+ ## MiniChat-1.5-3B
12
+
13
+ 📑 [arXiv](https://arxiv.org/abs/2311.07052) | 👻 [GitHub](https://github.com/GeneZC/MiniMA) | 🤗 [HuggingFace-MiniMA](https://huggingface.co/GeneZC/MiniMA-3B) | 🤗 [HuggingFace-MiniChat](https://huggingface.co/GeneZC/MiniChat-3B) | 🤖 [ModelScope-MiniMA](https://modelscope.cn/models/GeneZC/MiniMA-3B) | 🤖 [ModelScope-MiniChat](https://modelscope.cn/models/GeneZC/MiniChat-3B)
14
+
15
+ ❗ Must comply with LICENSE of LLaMA2 since it is derived from LLaMA2.
16
+
17
+ A language model distilled and finetuned from an adapted version of LLaMA2-7B following "Towards the Law of Capacity Gap in Distilling Language Models".
18
+
19
+ Outperforming a wide range of 3B competitors in GPT4 evaluation and even competing with several 7B chat models.
20
+
21
+ **Updates from MiniChat-3B**: 1) better data mixture; 2) use of [NEFTune](https://arxiv.org/abs/2310.05914); 3) use of [DPO](https://arxiv.org/abs/2305.18290)
22
+
23
+ <img src="./teaser_b.jpg" alt="teaser_b" width="687" />
24
+
25
+ The following is an example code snippet to use MiniChat-3B:
26
+
27
+ ```python
28
+ import torch
29
+
30
+ from transformers import AutoModelForCausalLM, AutoTokenizer
31
+
32
+ from conversation import get_default_conv_template
33
+
34
+ # MiniChat
35
+ tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniChat-3B", use_fast=False)
36
+ # GPU.
37
+ model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
38
+ # CPU.
39
+ # model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()
40
+
41
+ conv = get_default_conv_template("minichat")
42
+
43
+ question = "Implement a program to find the common elements in two arrays without using any extra data structures."
44
+ conv.append_message(conv.roles[0], question)
45
+ conv.append_message(conv.roles[1], None)
46
+ prompt = conv.get_prompt()
47
+ input_ids = tokenizer([prompt]).input_ids
48
+ output_ids = model.generate(
49
+ torch.as_tensor(input_ids).cuda(),
50
+ do_sample=True,
51
+ temperature=0.7,
52
+ max_new_tokens=1024,
53
+ )
54
+ output_ids = output_ids[0][len(input_ids[0]):]
55
+ output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
56
+ # output: "def common_elements(arr1, arr2):\n if len(arr1) == 0:\n return []\n if len(arr2) == 0:\n return arr1\n\n common_elements = []\n for element in arr1:\n if element in arr2:\n common_elements.append(element)\n\n return common_elements"
57
+ # Multiturn conversation could be realized by continuously appending questions to `conv`.
58
+ ```
59
+
60
+ ## Bibtex
61
+
62
+ ```bibtex
63
+ @article{zhang2023law,
64
+ title={Towards the Law of Capacity Gap in Distilling Language Models},
65
+ author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
66
+ year={2023},
67
+ url={https://arxiv.org/abs/2311.07052}
68
+ }
69
+ ```