๐ฐ๐ท๐ฆ KoLlama2-7b ์ ์ฅ์์ ๋๋ค ๐ฆ๐ฐ๐ท
โ KoLlama2 ์ฒซ๋ฒ์ ์ ๊ณ ๋ ค๋ํ๊ต NLP & AI ์ฐ๊ตฌ์ค๊ณผ HIAI ์ฐ๊ตฌ์๊ฐ ๊ณต๊ฐํ ํ๊ตญ์ด instruction dataset kullm-v2๋ฅผ ์ฌ์ฉํ LoRA ํ์ธํ๋์ ๋๋ค.
KoLlama2 : ํ๊ตญ์ด์ ์ต์ ํ๋ Llama2 ๊ธฐ๋ฐ ์คํ์์ค ์ธ์ด๋ชจ๋ธ
KoLlama2(Korean Large Language Model Meta AI 2)๋ ์์ด ๊ธฐ๋ฐ LLM์ธ Llama2์ ํ๊ตญ์ด ์ฑ๋ฅ์ ํฅ์ํ๊ธฐ ์ํ ์คํ์์ค ํ๋ก์ ํธ์ ๋๋ค.
ํ์์ฑ
GPT3๋ถํฐ Bert, Llama2์ ์ด๋ฅด๊ธฐ๊น์ง ๋๊ท๋ชจ ์ธ์ด๋ชจ๋ธ์ ๋๋ผ์ด ๋ฐ์ ์ ๋ชจ๋ ์ด์ ์ด๋ชฉ์ ๋๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋๊ท๋ชจ ๋ง๋ญ์น๋ฅผ ์ฌ์ ํ์ตํ๋ LLM์ ํน์ฑ์ ํ์ต ๋ฐ์ดํฐ ์ค ๋๋ค์๋ ์์ด๋ก ๊ตฌ์ ๋๋ฉฐ, ํ๊ตญ์ด๋ ๋งค์ฐ ์ ์ ๋น์จ์ ์ฐจ์งํฉ๋๋ค.
GPT3์ ์ฌ์ ํ์ต ๋ฐ์ดํฐ ์ค ํ๊ตญ์ด ๋น์จ: 0.01697%
์ถ์ฒ: https://github.com/openai/gpt-3/blob/master/dataset_statistics/languages_by_word_count.csvLlama2 ๋ชจ๋ธ์ ์ฌ์ ํ์ต ๋ฐ์ดํฐ ์ค ํ๊ตญ์ด ๋น์จ: 0.06%
์ถ์ฒ: 22p Table 10, Llama 2: Open Foundation and Fine-Tuned Chat Models, Hugo Touvron et al, July 18-2023.
์ด ๋น์จ์ ์ ์ธ๊ณ ์ธ๊ตฌ(7.888 billion) ์ค ํ๊ตญ์ด ํ์(81.7M) ๋น์จ(1.035%)๊ณผ ๋น๊ตํด๋ ํฌ๊ฒ ๋ฎ์ ์์น์ ๋๋ค. ์ด๋ ๊ณ ๋ฆฝ์ด๋ผ๋ ํ๊ตญ์ด ํน์ฑ, ์ค๋น๋์ง ์์ ํ๊ตญ์ด ๋ง๋ญ์น ๋ฑ ์ฌ๋ฌ ์์ธ์ ๊ธฐ๋ฐํ ๊ฒ์ด์ง๋ง ๊ฒฐ๊ณผ์ ์ผ๋ก ํ๊ตญ์ด ์ฌ์ฉ์๊ฐ LLM์ ํ๋ถํ ๋ฅ๋ ฅ์ ๊ฒฝํํ๋ ๊ฒ์ ๋งค์ฐ ์ ํํ๊ณ ์์ต๋๋ค.
๊ธฐ์กด ์๋๋ค
ํ๊ตญ์ด๊ธฐ๋ฐ LLM ์ฌ์ ํ์ต
๊ฐ์ฅ ์ข์ ํด๊ฒฐ์ฑ ์ค ํ๋๋ ํ๊ตญ์ด ๋ฐ์ดํฐ๋ก ์ฌ์ ํ์ตํ ์์ฒด ์ธ์ด๋ชจ๋ธ์ ๋ง๋๋ ๊ฒ์ ๋๋ค. ์ด๋ฌํ ์๋๋ ์๋ณธ๋ ฅ์ ๊ฐ์ถ ๋๊ธฐ์ ์ ์ฃผ๋๋ก ์งํ๋๊ณ ์์ต๋๋ค.
- Naver์ HyperCLOVA X : https://clova.ai/hyperclova
- Kakao์ KoGPT : https://github.com/kakaobrain/kogpt
- EleutherAI์ polyglot-ko : https://github.com/EleutherAI/polyglot
์ด๋ฌํ ์ ๊ทผ๋ฒ์ LLM์ ํ๊ตญ์ด ๋ฅ๋ ฅ ๋ถ์กฑ์ ๊ฐ์ฅ ํ์คํ๊ฒ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ค๋ง ๋ฌธ์ ๋ LLM์ ๋ณํ์๋๊ฐ ๋๋ฌด ๋น ๋ฅด๋ค๋ ๋ฐ ์์ต๋๋ค. LLaMA ๋ชจ๋ธ์ด ๊ณต๊ฐ๋ ํ Llama2 ๋ชจ๋ธ์ด ๊ณต๊ฐ๋๊ธฐ๊น์ง ๊ณ ์ 5๊ฐ์ ๋ฐ์ ๊ฑธ๋ฆฌ์ง ์์์ต๋๋ค. ๋งค์ฃผ ์๋ก์ด ๊ธฐ์ ์ด ๋ฐํ๋๋ ํ ์ํฉ์์ ๋ฏธ๋ ๋ฐ์ ๋ฐฉํฅ์ ์ ํํ ์์ธกํ๊ฑฐ๋, ๋งค๋ฒ ์๋ก์ด ๋ณํ์ ๋ง์ถฐ ๋๊ท๋ชจ ์ธ์ด๋ชจ๋ธ์ ํ์ตํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํฉ๋๋ค.
๋ฐ๋ผ์ ์ฐ๋ฆฌ๋ ์์ฒด ์ธ์ด๋ชจ๋ธ์ ํ์ตํ๋ ๊ฒ๊ณผ ๋ณํํ ์ ์๋ ๋ ๊ฐ๋ณ๊ณ ๋น ๋ฅธ ๋ฐฉ๋ฒ์ด ํ์ํฉ๋๋ค.
์ธ๊ตญ์ด๊ธฐ๋ฐ LLM ๋ฏธ์ธ์กฐ์
์ธ๊ตญ์ด๊ธฐ๋ฐ LLM์ ํ๊ตญ์ด๋ก ๋ฏธ์ธ์กฐ์ ํ๋ ๊ฒ์ ์ด ๋ฌธ์ ์ ๋ํ ์ข์ ํด๊ฒฐ ์ฑ ์ ๋๋ค. LLaMa ๋ชจ๋ธ์ ๊ธฐ๋ฐ์ผ๋ก ์๋์ ๊ฐ์ ์๋๋ค์ด ์์์ต๋๋ค.
- KoAlpaca : https://github.com/Beomi/KoAlpaca
- KULLM : https://github.com/nlpai-lab/KULLM
- KoVicuna : https://github.com/melodysdreamj/KoVicuna
- KORani : https://github.com/krafton-ai/KORani
์ด๋ฌํ ์๋๋ค์ ์คํ์์ค LLM์ ๋ํ ๊ด์ฌ์ ๋๋ฆฌ๊ณ ๋ค์ํ ๋ฏธ์ธ์กฐ์ ๋ฐฉ๋ฒ์ ์ดํดํ๋ ๋ฐ ๋์์ ์ฃผ์์ง๋ง ํ๊ณ์ ๋ ๋ช ํํ์ต๋๋ค.
- LLaMA ๋ชจ๋ธ์ ๊ฒฝ์ฐ ์ฌ์ ํ์ต ๋ฐ์ดํฐ์ ํ๊ตญ์ด๊ฐ ์ ์ธ๋์ด Full-Finetuning, LoRA, QLoRA ๋ฑ ์ด๋ค ๋ฐฉ๋ฒ์ผ๋ก๋ ๋ง์กฑ์ค๋ฌ์ด ํ๊ตญ์ด ์ฑ๋ฅ์ ๋ด์ง ๋ชปํ์ต๋๋ค.
- ํต์ผ๋ ํ๊ตญ์ด ํ์ต ํ๊ฐ ๋ฐฉ๋ฒ์ด ์์ด ์ด๋ค ํ์ต ๋ฐฉ๋ฒ์ด ๊ฐ์ฅ ํจ๊ณผ์ ์ธ์ง ํ๋จํ๊ธฐ ์ด๋ ค์ ์ต๋๋ค.
- ๊ฐ ํ๋ก์ ํธ๊ฐ ๊ฐ๋ณ ์ฃผ์ฒด์ ์ํด ์ฐ๋ฐ๋ก ์ ๊ฐ๋์ด ์ค๋ณต๋ ์๋๊ฐ ๋ฐ๋ณต๋์์ต๋๋ค.
KoLlama2 ํ๋ก์ ํธ ์ ์
KoLlama2๋ LLaMA ๋ชจ๋ธ์์ ์ป์ ๊ฒฝํ์ ๋ฐํ์ผ๋ก ์ธ๊ตญ์ด ๊ธฐ๋ฐ LLM์ ํ๊ตญ์ด๋ก ๋ฏธ์ธ์กฐ์ ํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ ์ฐพ๋ ํ๋ก์ ํธ์ ๋๋ค. ์ด๋ฅผ ์ํด ์๋์ ๊ฐ์ ์๋๋ค์ด ํ์ํฉ๋๋ค.
- QLoRA, LoRA, Full-Finetuning ๋ฑ ๋ค์ํ ๋ฐฉ๋ฒ๋ก ์ ์๋ํ์ฌ Llama2์ ํฌํจ๋ 0.01697% ํ๊ตญ์ด ๋ฅ๋ ฅ์ด ์ผ๋ง๋ ํฅ์๋๋์ง ํ์ธ.
- Alpaca, Vicuna ๋ฑ ๋ค์ํ ๋ฐ์ดํฐ์ธํธ๋ฅผ ์ ์ฉํ์ฌ ์ด๋ค ํํ ํ ์ดํฐ์ธํธ๊ฐ ํ๊ตญ์ด ๋ฅ๋ ฅํฅ์์ ๊ฐ์ฅ ํจ๊ณผ์ ์ธ์ง ํ์ธ.
- ๊ฐ๋จํ ํ์ ๋ฒ์ญ๋ถํฐ ์ ์ฐจ ๋์ด๋๋ฅผ ์ฌ๋ฆฌ๋ Curriculum Learning, ๋๊ท๋ชจ ํ๊ตญ์ด ๋ง๋ญ์น๋ก ์ฌ์ ํ์ต Step์ ์ถ๊ฐ ํ์ต, Chinese-LLaMA์์ ์ฌ์ฉํ ์ดํํ์ฅ ๋ฑ ์๋ก์ด ๊ธฐ๋ฒ๋ค ์๋.
- ๊ฐ ๋ฐฉ๋ฒ๋ก ์ ํ๊ฐํ ํฉ๋ฆฌ์ ํ๊ฐ๋ฒ ๊ณ ์.
Benchmarks
์ฐธ๊ณ ์๋ฃ
KoLlama2 : Open source language model based on Llama2 optimized for Korean
KoLlama2 (Korean Large Language Model Meta AI 2) is an open-source project to improve the Korean performance of Llama2, an English-based LLM.
Problem
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.
- Percentage of Korean in GPT3's pretraining data: 0.01697
https://github.com/openai/gpt-3/blob/master/dataset_statistics/languages_by_word_count.csv
- Percentage of Korean in the Llama2 model's pre-training data: 0.06%.
22p Table 10, Llama 2: Open Foundation and Fine-Tuned Chat Models, Hugo Touvron et al, July 18-2023.
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.
Problem Statement
Korean-based LLM Pretrain
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.
- Naver HyperCLOVA X : https://clova.ai/hyperclova
- Kakao KoGPT : https://github.com/kakaobrain/kogpt
- EleutherAI polyglot-ko : https://github.com/EleutherAI/polyglot
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.
Therefore, we need a lighter and faster method that can be used in parallel with learning our own language models.
Fine-tuning a English-based LLM
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.
- KoAlpaca : https://github.com/Beomi/KoAlpaca
- KULLM : https://github.com/nlpai-lab/KULLM
- KoVicuna : https://github.com/melodysdreamj/KoVicuna
- KORani : https://github.com/krafton-ai/KORani
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.
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.
There was no unified method for evaluating Korean language learning, making it difficult to determine which learning method was most effective.
Each project was developed sporadically by individual entities, resulting in redundant attempts.
KoLlama2 Project Suggested
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.
try different methodologies such as QLoRA, LoRA, and Full-Finetuning to see how much the 0.01697% Korean proficiency included in Llama2 improves.
Apply various datasets such as Alpaca and Vicuna to see which type of dataset is most effective for improving Korean proficiency.
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.
devising a reasonable evaluation method to assess each methodology.
Benchmarks
References
Llama 2
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.
This release includes model weights and starting code for pretrained and fine-tuned Llama language models โ ranging from 7B to 70B parameters.
This repository is intended as a minimal example to load Llama 2 models and run inference. For more detailed examples leveraging HuggingFace, see llama-recipes.
Download
โ ๏ธ 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. 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.
In order to download the model weights and tokenizer, please visit the Meta AI website and accept our License.
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.
Pre-requisites: make sure you have wget
and md5sum
installed. Then to run the script: ./download.sh
.
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.
Access on Hugging Face
We are also providing downloads on Hugging Face. 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.
Setup
In a conda env with PyTorch / CUDA available, clone the repo and run in the top-level directory:
pip install -e .
Inference
Different models require different model-parallel (MP) values:
Model | MP |
---|---|
7B | 1 |
13B | 2 |
70B | 8 |
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.
Pretrained Models
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.
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):
torchrun --nproc_per_node 1 example_text_completion.py \
--ckpt_dir llama-2-7b/ \
--tokenizer_path tokenizer.model \
--max_seq_len 128 --max_batch_size 4
Fine-tuned Chat Models
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
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).
You can also deploy additional classifiers for filtering out inputs and outputs that are deemed unsafe. See the llama-recipes repo for an example of how to add a safety checker to the inputs and outputs of your inference code.
Examples using llama-2-7b-chat:
torchrun --nproc_per_node 1 example_chat_completion.py \
--ckpt_dir llama-2-7b-chat/ \
--tokenizer_path tokenizer.model \
--max_seq_len 512 --max_batch_size 4
Llama 2 is a new technology that carries potential risks with use. Testing conducted to date has not โ and could not โ cover all scenarios. In order to help developers address these risks, we have created the Responsible Use Guide. More details can be found in our research paper as well.
Issues
Please report any software โbug,โ or other problems with the models through one of the following means:
- Reporting issues with the model: github.com/facebookresearch/llama
- Reporting risky content generated by the model: developers.facebook.com/llama_output_feedback
- Reporting bugs and security concerns: facebook.com/whitehat/info
Model Card
See MODEL_CARD.md.
License
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.
See the LICENSE file, as well as our accompanying Acceptable Use Policy
References
Original LLaMA
The repo for the original llama release is in the llama_v1
branch.
- Downloads last month
- 901