GeneZC commited on
Commit
b231352
1 Parent(s): a2196dd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +64 -0
README.md CHANGED
@@ -1,3 +1,67 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - FreedomIntelligence/phoenix-sft-data-v1
5
+ language:
6
+ - en
7
+ - zh
8
+ library_name: transformers
9
  ---
10
+
11
+ ## MiniMA-3B
12
+
13
+ 📑 [arXiv]() | 🤗 [HuggingFace](https://huggingface.co/GeneZC/MiniChat-3B) | 🤖 [ModelScope]()
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 could even competing with several 7B chat models.
20
+
21
+ <img src="./teaser_b.jpg" alt="teaser_b" width="700" />
22
+
23
+ The following is an example code snippet to use MiniChat-3B:
24
+
25
+ ```python
26
+ import torch
27
+
28
+ from transformers import AutoModelForCausalLM, AutoTokenizer
29
+
30
+ from conversation import get_default_conv_template
31
+
32
+ # MiniChat
33
+ tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniChat-3B", use_fast=False)
34
+ # GPU.
35
+ model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
36
+ # CPU.
37
+ # model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()
38
+
39
+ conv = get_default_conv_template("minichat")
40
+
41
+ question = "Implement a program to find the common elements in two arrays without using any extra data structures."
42
+ conv.append_message(conv.roles[0], question)
43
+ conv.append_message(conv.roles[1], None)
44
+ prompt = conv.get_prompt()
45
+ input_ids = tokenizer([prompt]).input_ids
46
+ output_ids = model.generate(
47
+ torch.as_tensor(input_ids).cuda(),
48
+ do_sample=True,
49
+ temperature=0.7,
50
+ max_new_tokens=1024,
51
+ )
52
+ output_ids = output_ids[0][len(input_ids[0]):]
53
+ output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
54
+ # 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"
55
+ # Multiturn conversation could be realized by continuously appending questions to `conv`.
56
+ ```
57
+
58
+ ## Bibtex
59
+
60
+ ```bibtex
61
+ @article{zhang2023law,
62
+ title={Towards the Law of Capacity Gap in Distilling Language Models},
63
+ author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
64
+ year={2023},
65
+ url={}
66
+ }
67
+ ```