Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- nlpai-lab/kullm-v2
|
4 |
+
language:
|
5 |
+
- ko
|
6 |
+
- en
|
7 |
+
---
|
8 |
+
|
9 |
+
<br/>
|
10 |
+
|
11 |
+
# ๐ฐ๐ท๐ฆ KoLlama2-7b ์ ์ฅ์์
๋๋ค ๐ฆ๐ฐ๐ท
|
12 |
+
|
13 |
+
โ
KoLlama2 ์ฒซ๋ฒ์ ์ ๊ณ ๋ ค๋ํ๊ต NLP & AI ์ฐ๊ตฌ์ค๊ณผ HIAI ์ฐ๊ตฌ์๊ฐ ๊ณต๊ฐํ ํ๊ตญ์ด instruction dataset kullm-v2๋ฅผ ์ฌ์ฉํ LoRA ํ์ธํ๋์
๋๋ค.
|
14 |
+
|
15 |
+
|
16 |
+
<br/>
|
17 |
+
|
18 |
+
[Read English](#kollama2--open-source-language-model-based-on-llama2-optimized-for-korean)
|
19 |
+
|
20 |
+
# KoLlama2 : ํ๊ตญ์ด์ ์ต์ ํ๋ Llama2 ๊ธฐ๋ฐ ์คํ์์ค ์ธ์ด๋ชจ๋ธ
|
21 |
+
|
22 |
+
KoLlama2(Korean Large Language Model Meta AI 2)๋ ์์ด ๊ธฐ๋ฐ LLM์ธ Llama2์ ํ๊ตญ์ด ์ฑ๋ฅ์ ํฅ์ํ๊ธฐ ์ํ ์คํ์์ค ํ๋ก์ ํธ์
๋๋ค.
|
23 |
+
|
24 |
+
<br/>
|
25 |
+
|
26 |
+
## ํ์์ฑ
|
27 |
+
|
28 |
+
GPT3๋ถํฐ Bert, Llama2์ ์ด๋ฅด๊ธฐ๊น์ง ๋๊ท๋ชจ ์ธ์ด๋ชจ๋ธ์ ๋๋ผ์ด ๋ฐ์ ์ ๋ชจ๋ ์ด์ ์ด๋ชฉ์ ๋๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋๊ท๋ชจ ๋ง๋ญ์น๋ฅผ ์ฌ์ ํ์ตํ๋ LLM์ ํน์ฑ์ ํ์ต ๋ฐ์ดํฐ ์ค ๋๋ค์๋ ์์ด๋ก ๊ตฌ์ ๋๋ฉฐ, ํ๊ตญ์ด๋ ๋งค์ฐ ์ ์ ๋น์จ์ ์ฐจ์งํฉ๋๋ค.
|
29 |
+
|
30 |
+
- GPT3์ ์ฌ์ ํ์ต ๋ฐ์ดํฐ ์ค ํ๊ตญ์ด ๋น์จ: 0.01697%
|
31 |
+
<p align="center" style="color:gray">
|
32 |
+
<img style="margin:20px 0 10px 0" src="https://github.com/psymon-dev/KoLlama2/assets/91517542/b50b9283-fb54-46b6-bc84-00bd363601c8" alt="image" width=482 />
|
33 |
+
<br/>์ถ์ฒ: https://github.com/openai/gpt-3/blob/master/dataset_statistics/languages_by_word_count.csv
|
34 |
+
</p>
|
35 |
+
|
36 |
+
- Llama2 ๋ชจ๋ธ์ ์ฌ์ ํ์ต ๋ฐ์ดํฐ ์ค ํ๊ตญ์ด ๋น์จ: 0.06%
|
37 |
+
<p align="center" style="color:gray">
|
38 |
+
<img style="margin:20px 0 10px 0" src="https://github.com/psymon-dev/KoLlama2/assets/91517542/79b72fee-3517-4a7e-a0a5-fda4c8f2a7ca" alt="image" width=482 />
|
39 |
+
<br/>์ถ์ฒ: 22p Table 10, Llama 2: Open Foundation and Fine-Tuned Chat Models, Hugo Touvron et al, July 18-2023.
|
40 |
+
</p>
|
41 |
+
|
42 |
+
์ด ๋น์จ์ ์ ์ธ๊ณ ์ธ๊ตฌ(7.888 billion) ์ค ํ๊ตญ์ด ํ์(81.7M) ๋น์จ(1.035%)๊ณผ ๋น๊ตํด๋ ํฌ๊ฒ ๋ฎ์ ์์น์
๋๋ค. ์ด๋ ๊ณ ๋ฆฝ์ด๋ผ๋ ํ๊ตญ์ด ํน์ฑ, ์ค๋น๋์ง ์์ ํ๊ตญ์ด ๋ง๋ญ์น ๋ฑ ์ฌ๋ฌ ์์ธ์ ๊ธฐ๋ฐํ ๊ฒ์ด์ง๋ง ๊ฒฐ๊ณผ์ ์ผ๋ก ํ๊ตญ์ด ์ฌ์ฉ์๊ฐ LLM์ ํ๋ถํ ๋ฅ๋ ฅ์ ๊ฒฝํํ๋ ๊ฒ์ ๋งค์ฐ ์ ํํ๊ณ ์์ต๋๋ค.
|
43 |
+
|
44 |
+
<br/>
|
45 |
+
|
46 |
+
## ๊ธฐ์กด ์๋๋ค
|
47 |
+
### ํ๊ตญ์ด๊ธฐ๋ฐ LLM ์ฌ์ ํ์ต
|
48 |
+
๊ฐ์ฅ ์ข์ ํด๊ฒฐ์ฑ
์ค ํ๋๋ ํ๊ตญ์ด ๋ฐ์ดํฐ๋ก ์ฌ์ ํ์ตํ ์์ฒด ์ธ์ด๋ชจ๋ธ์ ๋ง๋๋ ๊ฒ์
๋๋ค. ์ด๋ฌํ ์๋๋ ์๋ณธ๋ ฅ์ ๊ฐ์ถ ๋๊ธฐ์
์ ์ฃผ๋๋ก ์งํ๋๊ณ ์์ต๋๋ค.
|
49 |
+
|
50 |
+
* Naver์ HyperCLOVA X : https://clova.ai/hyperclova
|
51 |
+
* Kakao์ KoGPT : https://github.com/kakaobrain/kogpt
|
52 |
+
* EleutherAI์ polyglot-ko : https://github.com/EleutherAI/polyglot
|
53 |
+
|
54 |
+
์ด๋ฌํ ์ ๊ทผ๋ฒ์ LLM์ ํ๊ตญ์ด ๋ฅ๋ ฅ ๋ถ์กฑ์ ๊ฐ์ฅ ํ์คํ๊ฒ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ค๋ง ๋ฌธ์ ๋ LLM์ ๋ณํ์๋๊ฐ ๋๋ฌด ๋น ๋ฅด๋ค๋ ๋ฐ ์์ต๋๋ค. LLaMA ๋ชจ๋ธ์ด ๊ณต๊ฐ๋ ํ Llama2 ๋ชจ๋ธ์ด ๊ณต๊ฐ๋๊ธฐ๊น์ง ๊ณ ์ 5๊ฐ์ ๋ฐ์ ๊ฑธ๋ฆฌ์ง ์์์ต๋๋ค. ๋งค์ฃผ ์๋ก์ด ๊ธฐ์ ์ด ๋ฐํ๋๋ ํ ์ํฉ์์ ๋ฏธ๋ ๋ฐ์ ๋ฐฉํฅ์ ์ ํํ ์์ธกํ๊ฑฐ๋, ๋งค๋ฒ ์๋ก์ด ๋ณํ์ ๋ง์ถฐ ๋๊ท๋ชจ ์ธ์ด๋ชจ๋ธ์ ํ์ตํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํฉ๋๋ค.
|
55 |
+
|
56 |
+
๋ฐ๋ผ์ ์ฐ๋ฆฌ๋ ์์ฒด ์ธ์ด๋ชจ๋ธ์ ํ์ตํ๋ ๊ฒ๊ณผ ๋ณํํ ์ ์๋ ๋ ๊ฐ๋ณ๊ณ ๋น ๋ฅธ ๋ฐฉ๋ฒ์ด ํ์ํฉ๋๋ค.
|
57 |
+
|
58 |
+
### ์ธ๊ตญ์ด๊ธฐ๋ฐ LLM ๋ฏธ์ธ์กฐ์
|
59 |
+
์ธ๊ตญ์ด๊ธฐ๋ฐ LLM์ ํ๊ตญ์ด๋ก ๋ฏธ์ธ์กฐ์ ํ๋ ๊ฒ์ ์ด ๋ฌธ์ ์ ๋ํ ์ข์ ํด๊ฒฐ ์ฑ
์
๋๋ค. LLaMa ๋ชจ๋ธ์ ๊ธฐ๋ฐ์ผ๋ก ์๋์ ๊ฐ์ ์๋๋ค์ด ์์์ต๋๋ค.
|
60 |
+
|
61 |
+
* KoAlpaca : https://github.com/Beomi/KoAlpaca
|
62 |
+
* KULLM : https://github.com/nlpai-lab/KULLM
|
63 |
+
* KoVicuna : https://github.com/melodysdreamj/KoVicuna
|
64 |
+
* KORani : https://github.com/krafton-ai/KORani
|
65 |
+
|
66 |
+
์ด๋ฌํ ์๋๋ค์ ์คํ์์ค LLM์ ๋ํ ๊ด์ฌ์ ๋๋ฆฌ๊ณ ๋ค์ํ ๋ฏธ์ธ์กฐ์ ๋ฐฉ๋ฒ์ ์ดํดํ๋ ๋ฐ ๋์์ ์ฃผ์์ง๋ง ํ๊ณ์ ๋ ๋ช
ํํ์ต๋๋ค.
|
67 |
+
|
68 |
+
1. LLaMA ๋ชจ๋ธ์ ๊ฒฝ์ฐ ์ฌ์ ํ์ต ๋ฐ์ดํฐ์ ํ๊ตญ์ด๊ฐ ์ ์ธ๋์ด Full-Finetuning, LoRA, QLoRA ๋ฑ ์ด๋ค ๋ฐฉ๋ฒ์ผ๋ก๋ ๋ง์กฑ์ค๋ฌ์ด ํ๊ตญ์ด ์ฑ๋ฅ์ ๋ด์ง ๋ชปํ์ต๋๋ค.
|
69 |
+
2. ํต์ผ๋ ํ๊ตญ์ด ํ์ต ํ๊ฐ ๋ฐฉ๋ฒ์ด ์์ด ์ด๋ค ํ์ต ๋ฐฉ๋ฒ์ด ๊ฐ์ฅ ํจ๊ณผ์ ์ธ์ง ํ๋จํ๊ธฐ ์ด๋ ค์ ์ต๋๋ค.
|
70 |
+
3. ๊ฐ ํ๋ก์ ํธ๊ฐ ๊ฐ๋ณ ์ฃผ์ฒด์ ์ํด ์ฐ๋ฐ๋ก ์ ๊ฐ๋์ด ์ค๋ณต๋ ์๋๊ฐ ๋ฐ๋ณต๋์์ต๋๋ค.
|
71 |
+
|
72 |
+
## KoLlama2 ํ๋ก์ ํธ ์ ์
|
73 |
+
KoLlama2๋ LLaMA ๋ชจ๋ธ์์ ์ป์ ๊ฒฝํ์ ๋ฐํ์ผ๋ก ์ธ๊ตญ์ด ๊ธฐ๋ฐ LLM์ ํ๊ตญ์ด๋ก ๋ฏธ์ธ์กฐ์ ํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ ์ฐพ๋ ํ๋ก์ ํธ์
๋๋ค. ์ด๋ฅผ ์ํด ์๋์ ๊ฐ์ ์๋๋ค์ด ํ์ํฉ๋๋ค.
|
74 |
+
|
75 |
+
1. QLoRA, LoRA, Full-Finetuning ๋ฑ ๋ค์ํ ๋ฐฉ๋ฒ๋ก ์ ์๋ํ์ฌ Llama2์ ํฌํจ๋ 0.01697% ํ๊ตญ์ด ๋ฅ๋ ฅ์ด ์ผ๋ง๋ ํฅ์๋๋์ง ํ์ธ.
|
76 |
+
2. Alpaca, Vicuna ๋ฑ ๋ค์ํ ๋ฐ์ดํฐ์ธํธ๋ฅผ ์ ์ฉํ์ฌ ์ด๋ค ํํ ํ
์ดํฐ์ธํธ๊ฐ ํ๊ตญ์ด ๋ฅ๋ ฅํฅ์์ ๊ฐ์ฅ ํจ๊ณผ์ ์ธ์ง ํ์ธ.
|
77 |
+
3. ๊ฐ๋จํ ํ์ ๋ฒ์ญ๋ถํฐ ์ ์ฐจ ๋์ด๋๋ฅผ ์ฌ๋ฆฌ๋ Curriculum Learning, ๋๊ท๋ชจ ํ๊ตญ์ด ๋ง๋ญ์น๋ก ์ฌ์ ํ์ต Step์ ์ถ๊ฐ ํ์ต, Chinese-LLaMA์์ ์ฌ์ฉํ ์ด๏ฟฝ๏ฟฝํ์ฅ ๋ฑ ์๋ก์ด ๊ธฐ๋ฒ๋ค ์๋.
|
78 |
+
4. ๊ฐ ๋ฐฉ๋ฒ๋ก ์ ํ๊ฐํ ํฉ๋ฆฌ์ ํ๊ฐ๋ฒ ๊ณ ์.
|
79 |
+
|
80 |
+
## Benchmarks
|
81 |
+
|
82 |
+
## ์ฐธ๊ณ ์๋ฃ
|
83 |
+
|
84 |
+
|
85 |
+
<br/>
|
86 |
+
|
87 |
+
---
|
88 |
+
|
89 |
+
# KoLlama2 : Open source language model based on Llama2 optimized for Korean
|
90 |
+
KoLlama2 (Korean Large Language Model Meta AI 2) is an open-source project to improve the Korean performance of Llama2, an English-based LLM.
|
91 |
+
|
92 |
+
|
93 |
+
## Problem
|
94 |
+
|
95 |
+
From GPT3 to Bert to Llama2, the amazing advances in large-scale language models have captured everyone's attention. However, due to the nature of LLMs pre-training on large corpora, the vast majority of training data is spoken in English, with Korean representing a very small percentage.
|
96 |
+
|
97 |
+
- Percentage of Korean in GPT3's pretraining data: 0.01697
|
98 |
+
|
99 |
+
<p align="center" style="color:gray">
|
100 |
+
<img style="margin:20px 0 10px 0" src="https://github.com/psymon-dev/KoLlama2/assets/91517542/b50b9283-fb54-46b6-bc84-00bd363601c8" alt="image" width=482 />
|
101 |
+
<br/>https://github.com/openai/gpt-3/blob/master/dataset_statistics/languages_by_word_count.csv
|
102 |
+
</p>
|
103 |
+
|
104 |
+
- Percentage of Korean in the Llama2 model's pre-training data: 0.06%.
|
105 |
+
|
106 |
+
<p align="center" style="color:gray">
|
107 |
+
<img style="margin:20px 0 10px 0" src="https://github.com/psymon-dev/KoLlama2/assets/91517542/79b72fee-3517-4a7e-a0a5-fda4c8f2a7ca" alt="image" width=482 />
|
108 |
+
<br/>22p Table 10, Llama 2: Open Foundation and Fine-Tuned Chat Models, Hugo Touvron et al, July 18-2023.
|
109 |
+
</p>
|
110 |
+
|
111 |
+
This percentage is significantly lower than the percentage of Korean speakers (81.7M) in the world's population (7.888 billion) (1.035%). This is based on a number of factors, including the isolated nature of Korean, an unprepared Korean corpus, and more, but the end result is that Korean speakers are severely limited in experiencing the richness of LLM.
|
112 |
+
|
113 |
+
## Problem Statement
|
114 |
+
### Korean-based LLM Pretrain
|
115 |
+
|
116 |
+
One of the best solutions is to create your own language model, pre-trained with Korean data. This is being done by large, well-funded companies.
|
117 |
+
|
118 |
+
* Naver HyperCLOVA X : https://clova.ai/hyperclova
|
119 |
+
* Kakao KoGPT : https://github.com/kakaobrain/kogpt
|
120 |
+
* EleutherAI polyglot-ko : https://github.com/EleutherAI/polyglot
|
121 |
+
|
122 |
+
This approach would most certainly address the LLM's lack of Korean language skills. The problem is that the LLM is changing so fast. It took only five months between the release of the LLaMA model and the release of the Llama2 model. With new technologies being released every week, it's impossible to accurately predict future developments, or to train a large language model to adapt to each new change.
|
123 |
+
|
124 |
+
Therefore, we need a lighter and faster method that can be used in parallel with learning our own language models.
|
125 |
+
|
126 |
+
### Fine-tuning a English-based LLM
|
127 |
+
Fine-tuning a foreign language-based LLM into Korean is a good solution to this problem. The following attempts have been made based on the LLaMa model.
|
128 |
+
|
129 |
+
|
130 |
+
* KoAlpaca : https://github.com/Beomi/KoAlpaca
|
131 |
+
* KULLM : https://github.com/nlpai-lab/KULLM
|
132 |
+
* KoVicuna : https://github.com/melodysdreamj/KoVicuna
|
133 |
+
* KORani : https://github.com/krafton-ai/KORani
|
134 |
+
|
135 |
+
While these attempts have increased interest in open source LLMs and helped me understand the various ways to fine-tune them, the limitations are clear.
|
136 |
+
|
137 |
+
1. For the LLaMA model, Korean was excluded from the pre-training data, so no method, including Full-Finetuning, LoRA, and QLoRA, could produce satisfactory Korean performance.
|
138 |
+
|
139 |
+
2. There was no unified method for evaluating Korean language learning, making it difficult to determine which learning method was most effective.
|
140 |
+
|
141 |
+
3. Each project was developed sporadically by individual entities, resulting in redundant attempts.
|
142 |
+
|
143 |
+
## KoLlama2 Project Suggested
|
144 |
+
KoLlama2 is a project to find the best way to fine-tune a English-based LLM into Korean based on the experience gained from the LLaMA model. To achieve this, the following attempts are required.
|
145 |
+
|
146 |
+
1. try different methodologies such as QLoRA, LoRA, and Full-Finetuning to see how much the 0.01697% Korean proficiency included in Llama2 improves.
|
147 |
+
|
148 |
+
2. Apply various datasets such as Alpaca and Vicuna to see which type of dataset is most effective for improving Korean proficiency.
|
149 |
+
|
150 |
+
3. try new techniques such as curriculum learning that gradually increases the difficulty from simple English to Korean translation, additional pre-learning steps with a large Korean corpus, and vocabulary expansion used in Chinese-LLaMA.
|
151 |
+
|
152 |
+
4. devising a reasonable evaluation method to assess each methodology.
|
153 |
+
|
154 |
+
## Benchmarks
|
155 |
+
|
156 |
+
## References
|
157 |
+
|
158 |
+
# Llama 2
|
159 |
+
|
160 |
+
We are unlocking the power of large language models. Our latest version of Llama is now accessible to individuals, creators, researchers and businesses of all sizes so that they can experiment, innovate and scale their ideas responsibly.
|
161 |
+
|
162 |
+
This release includes model weights and starting code for pretrained and fine-tuned Llama language models โ ranging from 7B to 70B parameters.
|
163 |
+
|
164 |
+
This repository is intended as a minimal example to load [Llama 2](https://ai.meta.com/research/publications/llama-2-open-foundation-and-fine-tuned-chat-models/) models and run inference. For more detailed examples leveraging HuggingFace, see [llama-recipes](https://github.com/facebookresearch/llama-recipes/).
|
165 |
+
|
166 |
+
## Download
|
167 |
+
|
168 |
+
โ ๏ธ **7/18: We're aware of people encountering a number of download issues today. Anyone still encountering issues should remove all local files, re-clone the repository, and [request a new download link](https://ai.meta.com/resources/models-and-libraries/llama-downloads/). It's critical to do all of these in case you have local corrupt files. When you receive the email, copy *only* the link text - it should begin with https://download.llamameta.net and not with https://l.facebook.com, which will give errors.**
|
169 |
+
|
170 |
+
|
171 |
+
|
172 |
+
In order to download the model weights and tokenizer, please visit the [Meta AI website](https://ai.meta.com/resources/models-and-libraries/llama-downloads/) and accept our License.
|
173 |
+
|
174 |
+
Once your request is approved, you will receive a signed URL over email. Then run the download.sh script, passing the URL provided when prompted to start the download. Make sure that you copy the URL text itself, **do not use the 'Copy link address' option** when you right click the URL. If the copied URL text starts with: https://download.llamameta.net, you copied it correctly. If the copied URL text starts with: https://l.facebook.com, you copied it the wrong way.
|
175 |
+
|
176 |
+
Pre-requisites: make sure you have `wget` and `md5sum` installed. Then to run the script: `./download.sh`.
|
177 |
+
|
178 |
+
Keep in mind that the links expire after 24 hours and a certain amount of downloads. If you start seeing errors such as `403: Forbidden`, you can always re-request a link.
|
179 |
+
|
180 |
+
### Access on Hugging Face
|
181 |
+
|
182 |
+
We are also providing downloads on [Hugging Face](https://huggingface.co/meta-llama). You must first request a download from the Meta AI website using the same email address as your Hugging Face account. After doing so, you can request access to any of the models on Hugging Face and within 1-2 days your account will be granted access to all versions.
|
183 |
+
|
184 |
+
## Setup
|
185 |
+
|
186 |
+
In a conda env with PyTorch / CUDA available, clone the repo and run in the top-level directory:
|
187 |
+
|
188 |
+
```
|
189 |
+
pip install -e .
|
190 |
+
```
|
191 |
+
|
192 |
+
## Inference
|
193 |
+
|
194 |
+
Different models require different model-parallel (MP) values:
|
195 |
+
|
196 |
+
| Model | MP |
|
197 |
+
|--------|----|
|
198 |
+
| 7B | 1 |
|
199 |
+
| 13B | 2 |
|
200 |
+
| 70B | 8 |
|
201 |
+
|
202 |
+
All models support sequence length up to 4096 tokens, but we pre-allocate the cache according to `max_seq_len` and `max_batch_size` values. So set those according to your hardware.
|
203 |
+
|
204 |
+
### Pretrained Models
|
205 |
+
|
206 |
+
These models are not finetuned for chat or Q&A. They should be prompted so that the expected answer is the natural continuation of the prompt.
|
207 |
+
|
208 |
+
See `example_text_completion.py` for some examples. To illustrate, see command below to run it with the llama-2-7b model (`nproc_per_node` needs to be set to the `MP` value):
|
209 |
+
|
210 |
+
```
|
211 |
+
torchrun --nproc_per_node 1 example_text_completion.py \
|
212 |
+
--ckpt_dir llama-2-7b/ \
|
213 |
+
--tokenizer_path tokenizer.model \
|
214 |
+
--max_seq_len 128 --max_batch_size 4
|
215 |
+
```
|
216 |
+
|
217 |
+
### Fine-tuned Chat Models
|
218 |
+
|
219 |
+
The fine-tuned models were trained for dialogue applications. To get the expected features and performance for them, a specific formatting defined in [`chat_completion`](https://github.com/facebookresearch/llama/blob/main/llama/generation.py#L212)
|
220 |
+
needs to be followed, including the `INST` and `<<SYS>>` tags, `BOS` and `EOS` tokens, and the whitespaces and breaklines in between (we recommend calling `strip()` on inputs to avoid double-spaces).
|
221 |
+
|
222 |
+
You can also deploy additional classifiers for filtering out inputs and outputs that are deemed unsafe. See the llama-recipes repo for [an example](https://github.com/facebookresearch/llama-recipes/blob/main/inference/inference.py) of how to add a safety checker to the inputs and outputs of your inference code.
|
223 |
+
|
224 |
+
Examples using llama-2-7b-chat:
|
225 |
+
|
226 |
+
```
|
227 |
+
torchrun --nproc_per_node 1 example_chat_completion.py \
|
228 |
+
--ckpt_dir llama-2-7b-chat/ \
|
229 |
+
--tokenizer_path tokenizer.model \
|
230 |
+
--max_seq_len 512 --max_batch_size 4
|
231 |
+
```
|
232 |
+
|
233 |
+
Llama 2 is a new technology that carries potential risks with use. Testing conducted to date has not โ and could not โ cover all scenarios.
|
234 |
+
In order to help developers address these risks, we have created the [Responsible Use Guide](Responsible-Use-Guide.pdf). More details can be found in our research paper as well.
|
235 |
+
|
236 |
+
## Issues
|
237 |
+
|
238 |
+
Please report any software โbug,โ or other problems with the models through one of the following means:
|
239 |
+
- Reporting issues with the model: [github.com/facebookresearch/llama](http://github.com/facebookresearch/llama)
|
240 |
+
- Reporting risky content generated by the model: [developers.facebook.com/llama_output_feedback](http://developers.facebook.com/llama_output_feedback)
|
241 |
+
- Reporting bugs and security concerns: [facebook.com/whitehat/info](http://facebook.com/whitehat/info)
|
242 |
+
|
243 |
+
## Model Card
|
244 |
+
See [MODEL_CARD.md](MODEL_CARD.md).
|
245 |
+
|
246 |
+
## License
|
247 |
+
|
248 |
+
Our model and weights are licensed for both researchers and commercial entities, upholding the principles of openness. Our mission is to empower individuals, and industry through this opportunity, while fostering an environment of discovery and ethical AI advancements.
|
249 |
+
|
250 |
+
See the [LICENSE](LICENSE) file, as well as our accompanying [Acceptable Use Policy](USE_POLICY.md)
|
251 |
+
|
252 |
+
## References
|
253 |
+
|
254 |
+
1. [Research Paper](https://ai.meta.com/research/publications/llama-2-open-foundation-and-fine-tuned-chat-models/)
|
255 |
+
2. [Llama 2 technical overview](https://ai.meta.com/resources/models-and-libraries/llama)
|
256 |
+
3. [Open Innovation AI Research Community](https://ai.meta.com/llama/open-innovation-ai-research-community/)
|
257 |
+
|
258 |
+
## Original LLaMA
|
259 |
+
The repo for the original llama release is in the [`llama_v1`](https://github.com/facebookresearch/llama/tree/llama_v1) branch.
|