e-mon commited on
Commit
3a75d6d
1 Parent(s): 4afd4ca

Add README

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. LICENCE.txt +125 -0
  3. README.md +138 -0
  4. key_visual.png +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ key_visual.png filter=lfs diff=lfs merge=lfs -text
LICENCE.txt ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LLAMA 2 COMMUNITY LICENSE AGREEMENT
2
+ Llama 2 Version Release Date: July 18, 2023
3
+
4
+ "Agreement" means the terms and conditions for use, reproduction, distribution and
5
+ modification of the Llama Materials set forth herein.
6
+
7
+ "Documentation" means the specifications, manuals and documentation
8
+ accompanying Llama 2 distributed by Meta at ai.meta.com/resources/models-and-
9
+ libraries/llama-downloads/.
10
+
11
+ "Licensee" or "you" means you, or your employer or any other person or entity (if
12
+ you are entering into this Agreement on such person or entity's behalf), of the age
13
+ required under applicable laws, rules or regulations to provide legal consent and that
14
+ has legal authority to bind your employer or such other person or entity if you are
15
+ entering in this Agreement on their behalf.
16
+
17
+ "Llama 2" means the foundational large language models and software and
18
+ algorithms, including machine-learning model code, trained model weights,
19
+ inference-enabling code, training-enabling code, fine-tuning enabling code and other
20
+ elements of the foregoing distributed by Meta at ai.meta.com/resources/models-and-
21
+ libraries/llama-downloads/.
22
+
23
+ "Llama Materials" means, collectively, Meta's proprietary Llama 2 and
24
+ Documentation (and any portion thereof) made available under this Agreement.
25
+
26
+ "Meta" or "we" means Meta Platforms Ireland Limited (if you are located in or, if you
27
+ are an entity, your principal place of business is in the EEA or Switzerland) and Meta
28
+ Platforms, Inc. (if you are located outside of the EEA or Switzerland).
29
+
30
+ By clicking "I Accept" below or by using or distributing any portion or element of the
31
+ Llama Materials, you agree to be bound by this Agreement.
32
+
33
+ 1. License Rights and Redistribution.
34
+
35
+ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-
36
+ transferable and royalty-free limited license under Meta's intellectual property or
37
+ other rights owned by Meta embodied in the Llama Materials to use, reproduce,
38
+ distribute, copy, create derivative works of, and make modifications to the Llama
39
+ Materials.
40
+
41
+ b. Redistribution and Use.
42
+
43
+ i. If you distribute or make the Llama Materials, or any derivative works
44
+ thereof, available to a third party, you shall provide a copy of this Agreement to such
45
+ third party.
46
+ ii. If you receive Llama Materials, or any derivative works thereof, from
47
+ a Licensee as part of an integrated end user product, then Section 2 of this
48
+ Agreement will not apply to you.
49
+
50
+ iii. You must retain in all copies of the Llama Materials that you
51
+ distribute the following attribution notice within a "Notice" text file distributed as a
52
+ part of such copies: "Llama 2 is licensed under the LLAMA 2 Community License,
53
+ Copyright (c) Meta Platforms, Inc. All Rights Reserved."
54
+
55
+ iv. Your use of the Llama Materials must comply with applicable laws
56
+ and regulations (including trade compliance laws and regulations) and adhere to the
57
+ Acceptable Use Policy for the Llama Materials (available at
58
+ https://ai.meta.com/llama/use-policy), which is hereby incorporated by reference into
59
+ this Agreement.
60
+
61
+ v. You will not use the Llama Materials or any output or results of the
62
+ Llama Materials to improve any other large language model (excluding Llama 2 or
63
+ derivative works thereof).
64
+
65
+ 2. Additional Commercial Terms. If, on the Llama 2 version release date, the
66
+ monthly active users of the products or services made available by or for Licensee,
67
+ or Licensee's affiliates, is greater than 700 million monthly active users in the
68
+ preceding calendar month, you must request a license from Meta, which Meta may
69
+ grant to you in its sole discretion, and you are not authorized to exercise any of the
70
+ rights under this Agreement unless or until Meta otherwise expressly grants you
71
+ such rights.
72
+
73
+ 3. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE
74
+ LLAMA MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE
75
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
76
+ EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY
77
+ WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR
78
+ FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE
79
+ FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING
80
+ THE LLAMA MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR
81
+ USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND RESULTS.
82
+
83
+ 4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE
84
+ LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT,
85
+ NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS
86
+ AGREEMENT, FOR ANY LOST PROFITS OR ANY INDIRECT, SPECIAL,
87
+ CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN
88
+ IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF
89
+ ANY OF THE FOREGOING.
90
+
91
+ 5. Intellectual Property.
92
+
93
+ a. No trademark licenses are granted under this Agreement, and in
94
+ connection with the Llama Materials, neither Meta nor Licensee may use any name
95
+ or mark owned by or associated with the other or any of its affiliates, except as
96
+ required for reasonable and customary use in describing and redistributing the
97
+ Llama Materials.
98
+
99
+ b. Subject to Meta's ownership of Llama Materials and derivatives made by or
100
+ for Meta, with respect to any derivative works and modifications of the Llama
101
+ Materials that are made by you, as between you and Meta, you are and will be the
102
+ owner of such derivative works and modifications.
103
+
104
+ c. If you institute litigation or other proceedings against Meta or any entity
105
+ (including a cross-claim or counterclaim in a lawsuit) alleging that the Llama
106
+ Materials or Llama 2 outputs or results, or any portion of any of the foregoing,
107
+ constitutes infringement of intellectual property or other rights owned or licensable
108
+ by you, then any licenses granted to you under this Agreement shall terminate as of
109
+ the date such litigation or claim is filed or instituted. You will indemnify and hold
110
+ harmless Meta from and against any claim by any third party arising out of or related
111
+ to your use or distribution of the Llama Materials.
112
+
113
+ 6. Term and Termination. The term of this Agreement will commence upon your
114
+ acceptance of this Agreement or access to the Llama Materials and will continue in
115
+ full force and effect until terminated in accordance with the terms and conditions
116
+ herein. Meta may terminate this Agreement if you are in breach of any term or
117
+ condition of this Agreement. Upon termination of this Agreement, you shall delete
118
+ and cease use of the Llama Materials. Sections 3, 4 and 7 shall survive the
119
+ termination of this Agreement.
120
+
121
+ 7. Governing Law and Jurisdiction. This Agreement will be governed and
122
+ construed under the laws of the State of California without regard to choice of law
123
+ principles, and the UN Convention on Contracts for the International Sale of Goods
124
+ does not apply to this Agreement. The courts of California shall have exclusive
125
+ jurisdiction of any dispute arising out of this Agreement.
README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ language:
4
+ - ja
5
+ - en
6
+ ---
7
+
8
+ ## ELYZA-japanese-CodeLlama-7b
9
+
10
+ ![ELYZA-Japanese-CodeLlama](./key_visual.png)
11
+
12
+
13
+ ### Model Description
14
+ **ELYZA-japanese-CodeLlama-7b** は、 [Code Llama](https://ai.meta.com/research/publications/code-llama-open-foundation-models-for-code/)をベースとして日本語能力を拡張するために追加事前学習を行ったモデルです。
15
+ 詳細は [Blog記事](https://zenn.dev/elyza/articles/fcbf103e0a05b1) を参照してください。
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 = "エラトステネスの篩についてサンプルコードを示し、解説してください。"
27
+
28
+ model_name = "elyza/ELYZA-japanese-CodeLlama-7b-instruct"
29
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
30
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto")
31
+
32
+ if torch.cuda.is_available():
33
+ model = model.to("cuda")
34
+
35
+ prompt = "{bos_token}{b_inst} {system}{prompt} {e_inst} ".format(
36
+ bos_token=tokenizer.bos_token,
37
+ b_inst=B_INST,
38
+ system=f"{B_SYS}{DEFAULT_SYSTEM_PROMPT}{E_SYS}",
39
+ prompt=text,
40
+ e_inst=E_INST,
41
+ )
42
+
43
+
44
+ with torch.no_grad():
45
+ token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
46
+
47
+ output_ids = model.generate(
48
+ token_ids.to(model.device),
49
+ max_new_tokens=768,
50
+ pad_token_id=tokenizer.pad_token_id,
51
+ eos_token_id=tokenizer.eos_token_id,
52
+ )
53
+ output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1) :], skip_special_tokens=True)
54
+ print(output)
55
+ """
56
+ エラトステネスの篩は、素数を探すアルゴリズムの一つです。
57
+
58
+ 以下にそのサンプルコードを示します。
59
+
60
+ ```python
61
+ def eratosthenes_sieve(n):
62
+ sieve = [True] * (n + 1)
63
+ sieve[0] = sieve[1] = False
64
+ for i in range(2, int(n ** 0.5) + 1):
65
+ if sieve[i]:
66
+ for j in range(i * i, n + 1, i):
67
+ sieve[j] = False
68
+ return [i for i in range(n + 1) if sieve[i]]
69
+ ```
70
+
71
+ このコードは、エラトステネスの篩を用いて、n以下のすべての素数を求める関数です。
72
+
73
+ エラトステネスの篩は、以下のようなアルゴリズムで動作します。
74
+
75
+ 1. 2以外のすべての数を素数として扱う
76
+ 2. 2以外の数のうち、2の倍数をすべて除外する
77
+ 3. 3以外の数のうち、3の倍数をすべて除外する
78
+ 4. 5以外の数のうち、5の倍数をすべて除外する
79
+ 5. 7以外の数のうち、7の倍数をすべて除外する
80
+ 6. …
81
+
82
+ このアルゴリズムでは、2の倍数、3の倍数、5の倍数、7の倍数…というように、素数の倍数を除外していきます。
83
+
84
+ このアルゴリズムは、素数の倍数は必ず素数の倍数の倍数となるという性質を利用しているため、非常に効率的です。
85
+ """
86
+ ```
87
+
88
+ ### ELYZA-japanese-CodeLlama-7b Models
89
+
90
+ | Model Name | Vocab Size | #Params |
91
+ |:---------------------------------------------|:----------:|:-------:|
92
+ |[elyza/ELYZA-japanese-CodeLlama-7b](https://huggingface.co/elyza/ELYZA-japanese-CodeLlama-7b)| 32016 | 6.27B |
93
+ |[elyza/ELYZA-japanese-CodeLlama-7b-instruct](https://huggingface.co/elyza/ELYZA-japanese-CodeLlama-7b-instruct)| 32016 | 6.27B |
94
+
95
+ ### Developers
96
+ 以下アルファベット順
97
+
98
+ - [Akira Sasaki](https://huggingface.co/akirasasaki)
99
+ - [Masato Hirakawa](https://huggingface.co/m-hirakawa)
100
+ - [Shintaro Horie](https://huggingface.co/e-mon)
101
+ - [Tomoaki Nakamura](https://huggingface.co/tyoyo)
102
+
103
+ ### Licence
104
+
105
+ Llama 2 is licensed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.
106
+
107
+ ### How to Cite
108
+
109
+ ```tex
110
+ @misc{elyzacodellama2023,
111
+ title={ELYZA-japanese-CodeLlama-7b},
112
+ url={https://huggingface.co/elyza/ELYZA-japanese-CodeLlama-7b},
113
+ author={Akira Sasaki and Masato Hirakawa and Shintaro Horie and Tomoaki Nakamura},
114
+ year={2023},
115
+ }
116
+ ```
117
+
118
+ ### Citations
119
+
120
+ ```tex
121
+ @misc{rozière2023code,
122
+ title={Code Llama: Open Foundation Models for Code},
123
+ author={Baptiste Rozière and Jonas Gehring and Fabian Gloeckle and Sten Sootla and Itai Gat and Xiaoqing Ellen Tan and Yossi Adi and Jingyu Liu and Tal Remez and Jérémy Rapin and Artyom Kozhevnikov and Ivan Evtimov and Joanna Bitton and Manish Bhatt and Cristian Canton Ferrer and Aaron Grattafiori and Wenhan Xiong and Alexandre Défossez and Jade Copet and Faisal Azhar and Hugo Touvron and Louis Martin and Nicolas Usunier and Thomas Scialom and Gabriel Synnaeve},
124
+ year={2023},
125
+ eprint={2308.12950},
126
+ archivePrefix={arXiv},
127
+ primaryClass={cs.CL}
128
+ }
129
+
130
+ @misc{touvron2023llama,
131
+ title={Llama 2: Open Foundation and Fine-Tuned Chat Models},
132
+ 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},
133
+ year={2023},
134
+ eprint={2307.09288},
135
+ archivePrefix={arXiv},
136
+ primaryClass={cs.CL}
137
+ }
138
+ ```
key_visual.png ADDED

Git LFS Details

  • SHA256: c9d40b4a5a484dbc5506a702e01e2c1a4284343b9dfb15fc022fbe3b84f090d9
  • Pointer size: 132 Bytes
  • Size of remote file: 1.57 MB