m-hirakawa commited on
Commit
16677a7
1 Parent(s): 29fbbf3

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +104 -0
README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ language:
4
+ - ja
5
+ - en
6
+ ---
7
+
8
+ ## ELYZA-japanese-Llama-2-13b-fast-instruct
9
+
10
+ ![ELYZA-Japanese-Llama2-image](./key_visual.png)
11
+
12
+
13
+ ### Model Description
14
+ **ELYZA-japanese-Llama-2-13b** は、 Llama 2をベースとして日本語能力を拡張するために追加事前学習を行ったモデルです。
15
+ 詳細は [Blog記事](https://editor.note.com/notes/n5d42686b60b7) を参照してください。
16
+
17
+ ### Usage
18
+
19
+ ```python
20
+ import torch
21
+ from transformers import AutoModelForCausalLM, AutoTokenizer
22
+
23
+ B_INST, E_INST = "[INST]", "[/INST]"
24
+ B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
25
+ DEFAULT_SYSTEM_PROMPT = "あなたは誠実で優秀な日本人のアシスタントです。"
26
+ text = "仕事の熱意を取り戻すためのアイデアを5つ挙げてください。"
27
+
28
+ model_name = "elyza/ELYZA-japanese-Llama-2-13b-fast-instruct"
29
+
30
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
31
+ model = AutoModelForCausalLM.from_pretrained(
32
+ model_name,
33
+ torch_dtype=torch.bfloat16,
34
+ use_cache=True,
35
+ device_map="auto",
36
+ low_cpu_mem_usage=True,
37
+ )
38
+ model.eval()
39
+
40
+ prompt = "{bos_token}{b_inst} {system}{prompt} {e_inst} ".format(
41
+ bos_token=tokenizer.bos_token,
42
+ b_inst=B_INST,
43
+ system=f"{B_SYS}{DEFAULT_SYSTEM_PROMPT}{E_SYS}",
44
+ prompt=text,
45
+ e_inst=E_INST,
46
+ )
47
+ token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
48
+
49
+ with torch.no_grad():
50
+ output_ids = model.generate(
51
+ token_ids.to(model.device),
52
+ max_new_tokens=256,
53
+ pad_token_id=tokenizer.pad_token_id,
54
+ eos_token_id=tokenizer.eos_token_id,
55
+ )
56
+ output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1) :], skip_special_tokens=True)
57
+ print(output)
58
+ ```
59
+
60
+ ### ELYZA-japanese-Llama-2-13b Models
61
+
62
+ | Model Name | Vocab Size | #Params |
63
+ |:---------------------------------------------|:----------:|:-------:|
64
+ |[elyza/ELYZA-japanese-Llama-2-13b](https://huggingface.co/elyza/ELYZA-japanese-Llama-2-13b)| 32000 | 13.02B |
65
+ |[elyza/ELYZA-japanese-Llama-2-13b-instruct](https://huggingface.co/elyza/ELYZA-japanese-Llama-2-13b-instruct)| 32000 | 13.02B |
66
+ |[elyza/ELYZA-japanese-Llama-2-13b-fast](https://huggingface.co/elyza/ELYZA-japanese-Llama-2-13b-fast)| 44581 | 13.14B |
67
+ |[elyza/ELYZA-japanese-Llama-2-13b-fast-instruct](https://huggingface.co/elyza/ELYZA-japanese-Llama-2-13b-fast-instruct)| 44581 | 13.14B |
68
+
69
+ ### Developers
70
+
71
+ - [Akira Sasaki](https://huggingface.co/akirasasaki)
72
+ - [Masato Hirakawa](https://huggingface.co/m-hirakawa)
73
+ - [Shintaro Horie](https://huggingface.co/e-mon)
74
+ - [Tomoaki Nakamura](https://huggingface.co/tyoyo)
75
+ - [Sam Passaglia](https://huggingface.co/passaglia)
76
+ - [Daisuke Oba](https://huggingface.co/daisuk30ba) (intern)
77
+
78
+ ### Licence
79
+
80
+ Llama 2 is licensed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.
81
+
82
+ ### How to Cite
83
+
84
+ ```tex
85
+ @misc{elyzallama2023,
86
+ title={ELYZA-japanese-Llama-2-13b},
87
+ url={https://huggingface.co/elyza/ELYZA-japanese-Llama-2-13b},
88
+ author={Akira Sasaki and Masato Hirakawa and Shintaro Horie and Tomoaki Nakamura and Sam Passaglia and Daisuke Oba},
89
+ year={2023},
90
+ }
91
+ ```
92
+
93
+ ### Citations
94
+
95
+ ```tex
96
+ @misc{touvron2023llama,
97
+ title={Llama 2: Open Foundation and Fine-Tuned Chat Models},
98
+ author={Hugo Touvron and Louis Martin and Kevin Stone and Peter Albert and Amjad Almahairi and Yasmine Babaei and Nikolay Bashlykov and Soumya Batra and Prajjwal Bhargava and Shruti Bhosale and Dan Bikel and Lukas Blecher and Cristian Canton Ferrer and Moya Chen and Guillem Cucurull and David Esiobu and Jude Fernandes and Jeremy Fu and Wenyin Fu and Brian Fuller and Cynthia Gao and Vedanuj Goswami and Naman Goyal and Anthony Hartshorn and Saghar Hosseini and Rui Hou and Hakan Inan and Marcin Kardas and Viktor Kerkez and Madian Khabsa and Isabel Kloumann and Artem Korenev and Punit Singh Koura and Marie-Anne Lachaux and Thibaut Lavril and Jenya Lee and Diana Liskovich and Yinghai Lu and Yuning Mao and Xavier Martinet and Todor Mihaylov and Pushkar Mishra and Igor Molybog and Yixin Nie and Andrew Poulton and Jeremy Reizenstein and Rashi Rungta and Kalyan Saladi and Alan Schelten and Ruan Silva and Eric Michael Smith and Ranjan Subramanian and Xiaoqing Ellen Tan and Binh Tang and Ross Taylor and Adina Williams and Jian Xiang Kuan and Puxin Xu and Zheng Yan and Iliyan Zarov and Yuchen Zhang and Angela Fan and Melanie Kambadur and Sharan Narang and Aurelien Rodriguez and Robert Stojnic and Sergey Edunov and Thomas Scialom},
99
+ year={2023},
100
+ eprint={2307.09288},
101
+ archivePrefix={arXiv},
102
+ primaryClass={cs.CL}
103
+ }
104
+ ```