Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐ŸŒ [i18n-KO] Translated llama2.md to Korean #26047

Merged
merged 8 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/ko/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@
title: (๋ฒˆ์—ญ์ค‘) LED
- local: model_doc/llama
title: LLaMA
- local: model_doc/llama2
title: LLaMA2
- local: in_translation
title: (๋ฒˆ์—ญ์ค‘) Longformer
- local: in_translation
Expand Down
129 changes: 129 additions & 0 deletions docs/source/ko/model_doc/llama2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!--Copyright 2023 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

โš ๏ธ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# Llama2 [[llama2]]

## ๊ฐœ์š” [[overview]]

Llama2 ๋ชจ๋ธ์€ Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Ya1smine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing EllenTan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, Thomas Scialom์˜ ๋…ผ๋ฌธ [LLaMA: Open Foundation and Fine-Tuned Chat Models](https://ai.meta.com/research/publications/llama-2-open-foundation-and-fine-tuned-chat-models/)์—์„œ ์ œ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฑ„ํŒ… ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋งž๊ฒŒ ๋ฏธ์„ธ ์กฐ์ •๋œ ์ฒดํฌํฌ์ธํŠธ๋ฅผ ํฌํ•จ๋œ 7B์—์„œ 70B ๋ฒ”์œ„์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง„ ๊ธฐ์ดˆ ์–ธ์–ด ๋ชจ๋ธ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค!

๋…ผ๋ฌธ์˜ ์ดˆ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

*์ด ์—ฐ๊ตฌ์—์„œ ์šฐ๋ฆฌ๋Š” 70์–ต์—์„œ 700์–ต ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ๋ฒ”์œ„์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จ ๋ฐ ๋ฏธ์„ธ ์กฐ์ •๋œ ๋Œ€๊ทœ๋ชจ ์–ธ์–ด ๋ชจ๋ธ(LLMs)์˜ ๋ชจ์Œ์ธ Llama 2๋ฅผ ๊ฐœ๋ฐœ ๋ฐ ๊ณต๊ฐœํ•ฉ๋‹ˆ๋‹ค. Llama 2-Chat๋ผ๊ณ  ๋ถˆ๋ฆฌ๋Š” ๋ฏธ์„ธ ์กฐ์ •๋œ LLMs์€ ๋Œ€ํ™” ์‚ฌ์šฉ ์‚ฌ๋ก€์— ์ตœ์ ํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ๋ชจ๋ธ์€ ํ…Œ์ŠคํŠธํ•œ ๋Œ€๋ถ€๋ถ„์˜ ๋ฒค์น˜๋งˆํฌ์—์„œ ์˜คํ”ˆ ์†Œ์Šค ์ฑ„ํŒ… ๋ชจ๋ธ๋ณด๋‹ค ์„ฑ๋Šฅ์ด ๋›ฐ์–ด๋‚˜๋ฉฐ, ์œ ์šฉ์„ฑ๊ณผ ์•ˆ์ „์„ฑ์— ๋Œ€ํ•œ ์ธ์  ํ‰๊ฐ€๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๋น„๊ณต๊ฐœ ์†Œ์Šค ๋ชจ๋ธ์„ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ๋Š” ์ ์ ˆํ•œ ๋Œ€์•ˆ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” Llama 2-Chat์˜ ๋ฏธ์„ธ ์กฐ์ • ๋ฐ ์•ˆ์ „์„ฑ ํ–ฅ์ƒ์˜ ์ ‘๊ทผ ๋ฐฉ์‹์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์„ค๋ช…์„ ์ œ๊ณตํ•˜์—ฌ ์ปค๋ฎค๋‹ˆํ‹ฐ๊ฐ€ ์šฐ๋ฆฌ์˜ ์ž‘์—…์„ ๊ธฐ๋ฐ˜์œผ๋กœ LLMs์˜ ์ฑ…์ž„์žˆ๋Š” ๊ฐœ๋ฐœ์— ๊ธฐ์—ฌํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.*

[์—ฌ๊ธฐ](https://huggingface.co/models?search=llama2)์—์„œ ๋ชจ๋“  Llama2 ๋ชจ๋ธ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

<Tip warning={true}>

`Llama2` ๋ชจ๋ธ์€ `bfloat16`์„ ์‚ฌ์šฉํ•˜์—ฌ ํ›ˆ๋ จ๋˜์—ˆ์ง€๋งŒ, ์›๋ž˜ ์ถ”๋ก ์€ `float16`์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํ—ˆ๋ธŒ์— ์—…๋กœ๋“œ๋œ ์ฒดํฌํฌ์ธํŠธ๋Š” `torch_dtype = 'float16'`์„ ์‚ฌ์šฉํ•˜๋ฉฐ, ์ด๋Š” `AutoModel` API์— ์˜ํ•ด ์ฒดํฌํฌ์ธํŠธ๋ฅผ `torch.float32`์—์„œ `torch.float16`์œผ๋กœ ์บ์ŠคํŒ…ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์˜จ๋ผ์ธ ๊ฐ€์ค‘์น˜์˜ `dtype`์€ `model = AutoModelForCausalLM.from_pretrained("path", torch_dtype = "auto")`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋ธ์„ ์ดˆ๊ธฐํ™”ํ•  ๋•Œ `torch_dtype="auto"`๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ํ•œ ๋Œ€๋ถ€๋ถ„ ๊ด€๋ จ์ด ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ ์ด์œ ๋Š” ๋ชจ๋ธ์ด ๋จผ์ € ๋‹ค์šด๋กœ๋“œ๋  ๊ฒƒ์ด๊ณ  (์˜จ๋ผ์ธ ์ฒดํฌํฌ์ธํŠธ์˜ `dtype`์„ ์‚ฌ์šฉํ•˜์—ฌ) ๊ทธ๋‹ค์Œ์— ๊ธฐ๋ณธ `dtype`์ธ `torch`๋กœ ์บ์ŠคํŒ…ํ•˜๊ณ (`torch.float32`๊ฐ€ ๋จ), ๋งˆ์ง€๋ง‰์œผ๋กœ ๊ตฌ์„ฑ(configuration)์—์„œ ์ œ๊ณต๋œ `torch_dtype`์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์ด๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๋ชจ๋ธ์„ `float16`์—์„œ ํ›ˆ๋ จํ•˜๋Š” ๊ฒƒ์€ ๊ถŒ์žฅ๋˜์ง€ ์•Š์œผ๋ฉฐ `nan`์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์•Œ๋ ค์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋ชจ๋ธ์€ `bfloat16`์—์„œ ํ›ˆ๋ จ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

</Tip>

๐Ÿฏ ํŒ:

- Llama2 ๋ชจ๋ธ์˜ ๊ฐ€์ค‘์น˜๋Š” [์ด ์–‘์‹](https://ai.meta.com/resources/models-and-libraries/llama-downloads/)์„ ์ž‘์„ฑํ•˜์—ฌ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- ์•„ํ‚คํ…์ฒ˜๋Š” ์ฒ˜์Œ ๋ฒ„์ „์˜ Llama์™€ ๋งค์šฐ ์œ ์‚ฌํ•˜๋ฉฐ, [์ด ๋…ผ๋ฌธ](https://arxiv.org/pdf/2305.13245.pdf)์˜ ๋‚ด์šฉ์— ๋”ฐ๋ผ Grouped Query Attention (GQA)์ด ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
- `config.pretraining_tp`๋ฅผ 1๊ณผ ๋‹ค๋ฅธ ๊ฐ’์œผ๋กœ ์„ค์ •ํ•˜๋ฉด ๋” ์ •ํ™•ํ•˜์ง€๋งŒ ๋Š๋ฆฐ ์„ ํ˜• ๋ ˆ์ด์–ด ๊ณ„์‚ฐ์ด ํ™œ์„ฑํ™”๋˜์–ด ์›๋ณธ ๋กœ์ง“๊ณผ ๋” ์ž˜ ์ผ์น˜ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
- ์›๋ž˜ ๋ชจ๋ธ์€ `pad_id = -1`์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, ์ด๋Š” ํŒจ๋”ฉ ํ† ํฐ์ด ์—†์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋™์ผํ•œ ๋กœ์ง์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์œผ๋ฏ€๋กœ `tokenizer.add_special_tokens({"pad_token":"<pad>"})`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŒจ๋”ฉ ํ† ํฐ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์ด์— ๋”ฐ๋ผ ํ† ํฐ ์ž„๋ฒ ๋”ฉ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ `model.config.pad_token_id`๋ฅผ ์„ค์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋ธ์˜ `embed_tokens` ๋ ˆ์ด์–ด๋Š” `self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.config.padding_idx)`๋กœ ์ดˆ๊ธฐํ™”๋˜์–ด, ํŒจ๋”ฉ ํ† ํฐ ์ธ์ฝ”๋”ฉ์ด 0์„ ์ถœ๋ ฅํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ดˆ๊ธฐํ™” ์‹œ์— ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
- ์–‘์‹์„ ์ž‘์„ฑํ•˜๊ณ  ๋ชจ๋ธ ์ฒดํฌํฌ์ธํŠธ ์ ‘๊ทผ ๊ถŒํ•œ์„ ์–ป์€ ํ›„์—๋Š” ์ด๋ฏธ ๋ณ€ํ™˜๋œ ์ฒดํฌํฌ์ธํŠธ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š๊ณ  ์ž์‹ ์˜ ๋ชจ๋ธ์„ ์ง์ ‘ ๋ณ€ํ™˜ํ•˜๋ ค๋Š” ๊ฒฝ์šฐ, [๋ณ€ํ™˜ ์Šคํฌ๋ฆฝํŠธ](https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py)๋ฅผ ์ž์œ ๋กญ๊ฒŒ ์‚ฌ์šฉํ•˜์„ธ์š”. ์Šคํฌ๋ฆฝํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ˆ์‹œ์˜ ๋ช…๋ น์–ด๋กœ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

```bash
python src/transformers/models/llama/convert_llama_weights_to_hf.py \
--input_dir /path/to/downloaded/llama/weights --model_size 7B --output_dir /output/path
```

- ๋ณ€ํ™˜ ํ›„ ๋ชจ๋ธ๊ณผ ํ† ํฌ๋‚˜์ด์ €๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

```python
from transformers import LlamaForCausalLM, LlamaTokenizer

tokenizer = LlamaTokenizer.from_pretrained("/output/path")
model = LlamaForCausalLM.from_pretrained("/output/path")
```

์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด ๋ชจ๋ธ์„ float16 ์ •๋ฐ€๋„๋กœ ์ „๋ถ€ ํ˜ธ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์„ ๋งŒํผ ์ถฉ๋ถ„ํ•œ CPU RAM์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค (๊ฐ€์žฅ ํฐ ๋ฒ„์ „์ด ์—ฌ๋Ÿฌ ์ฒดํฌํฌ์ธํŠธ๋กœ ์ œ๊ณต๋˜๋”๋ผ๋„ ๊ฐ ์ฒดํฌํฌ์ธํŠธ๋Š” ๋ชจ๋ธ ๊ฐ€์ค‘์น˜์˜ ์ผ๋ถ€๋งŒ์„ ํฌํ•จํ•˜๋ฏ€๋กœ ๋ชจ๋‘ RAM์— ๋กœ๋“œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค). 75B ๋ชจ๋ธ์˜ ๊ฒฝ์šฐ, ์ด 145GB์˜ RAM์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

- LLaMA ํ† ํฌ๋‚˜์ด์ €๋Š” [sentencepiece](https://github.com/google/sentencepiece)๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ BPE ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. sentencepiece์˜ ํŠน์ง• ์ค‘ ํ•˜๋‚˜๋Š” ์‹œํ€€์Šค๋ฅผ ๋””์ฝ”๋”ฉํ•  ๋•Œ ์ฒซ ๋ฒˆ์งธ ํ† ํฐ์ด ๋‹จ์–ด์˜ ์‹œ์ž‘์ด๋ฉด (์˜ˆ: "Banana") ํ† ํฌ๋‚˜์ด์ €๋Š” ๋ฌธ์ž์—ด ์•ž์— ์ ‘๋‘์‚ฌ ๊ณต๊ฐ„์„ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ด ๋ชจ๋ธ์€ [Arthur Zucker](https://huggingface.co/ArthurZ)๊ฐ€ [Lysandre Debut](https://huggingface.co/lysandre)์˜ ๋„์›€์„ ๋ฐ›์•„ ์ œ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค. Hugging Face์—์„œ์˜ ๊ตฌํ˜„ ์ฝ”๋“œ๋Š” [์—ฌ๊ธฐ](https://github.com/EleutherAI/gpt-neox)์˜ GPT-NeoX ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. ์ €์ž์˜ ์›๋ž˜ ์ฝ”๋“œ๋Š” [์—ฌ๊ธฐ](https://github.com/facebookresearch/llama)์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

## ๋ฆฌ์†Œ์Šค [[resources]]

LLaMA2๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋  Hugging Face์˜ ๊ณต์‹ ๋ฐ ์ปค๋ฎค๋‹ˆํ‹ฐ(๐ŸŒŽ๋กœ ํ‘œ์‹œ) ๋ฆฌ์†Œ์Šค ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์— ์ƒˆ๋กœ์šด ๋ฆฌ์†Œ์Šค๋ฅผ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ Pull Request๋ฅผ ์—ด์–ด ์ฃผ์‹œ๋ฉด ๊ฒ€ํ† ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค! ๋ฆฌ์†Œ์Šค๋Š” ๊ธฐ์กด ๋ฆฌ์†Œ์Šค์™€ ์ค‘๋ณต๋˜์ง€ ์•Š๋Š” ์ƒˆ๋กœ์šด ๊ฒƒ์„ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์ด ์ด์ƒ์ ์ž…๋‹ˆ๋‹ค.

- [Llama 2 is here - get it on Hugging Face](https://huggingface.co/blog/llama2), Llama 2์— ๊ด€ํ•œ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ์™€ ๐Ÿค— Transformers ๋ฐ ๐Ÿค— PEFT์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
- [LLaMA 2 - Every Resource you need](https://www.philschmid.de/llama-2), LLaMA 2์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ณ  ๋น ๋ฅด๊ฒŒ ์‹œ์ž‘ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ๊ด€๋ จ ๋ฆฌ์†Œ์Šค์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค.

<PipelineTag pipeline="text-generation"/>

- Google Colab์—์„œ QLoRA์™€ 4-bit ์ •๋ฐ€๋„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Llama 2๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ [๋…ธํŠธ๋ถ](https://colab.research.google.com/drive/1PEQyJO1-f6j0S_XJ8DV50NkpzasXkrzd?usp=sharing)์ž…๋‹ˆ๋‹ค. ๐ŸŒŽ
- "Llama-v2-7b-guanaco" ๋ชจ๋ธ์„ 4-bit QLoRA๋กœ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๊ณ  PDF์—์„œ Q&A ๋ฐ์ดํ„ฐ์…‹์„ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ [๋…ธํŠธ๋ถ](https://colab.research.google.com/drive/134o_cXcMe_lsvl15ZE_4Y75Kstepsntu?usp=sharing)์ž…๋‹ˆ๋‹ค. ๐ŸŒŽ

โš—๏ธ ์ตœ์ ํ™”
- [Llama 2๋ฅผ DPO๋กœ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๊ธฐ](https://huggingface.co/blog/dpo-trl), TRL ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ DPO ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ํŠน์ • ๋ฐ์ดํ„ฐ์…‹์—์„œ Llama 2๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•ˆ๋‚ดํ•˜๋Š” ๊ฐ€์ด๋“œ์ž…๋‹ˆ๋‹ค.
- [ํ™•์žฅ ๊ฐ€์ด๋“œ: Llama 2 ๋ช…๋ น์–ด ์กฐ์ •](https://www.philschmid.de/instruction-tune-llama-2), ์ž…๋ ฅ์—์„œ ๋ช…๋ น์–ด๋ฅผ ์ƒ์„ฑํ•˜๋„๋ก Llama 2๋ฅผ ํ›ˆ๋ จ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ์•ˆ๋‚ดํ•˜๋Š” ๊ฐ€์ด๋“œ๋กœ, ๋ช…๋ น์–ด๋ฅผ ๋”ฐ๋ฅด๋Š” ๋ชจ๋ธ์—์„œ ๋ช…๋ น์–ด๋ฅผ ์ฃผ๋Š” ๋ชจ๋ธ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
- ๊ฐœ์ธ ์ปดํ“จํ„ฐ์—์„œ QLoRA์™€ TRL์„ ์‚ฌ์šฉํ•˜์—ฌ Llama 2 ๋ชจ๋ธ์„ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ [๋…ธํŠธ๋ถ](https://colab.research.google.com/drive/1SYpgFpcmtIUzdE7pxqknrM4ArCASfkFQ?usp=sharing)์ž…๋‹ˆ๋‹ค. ๐ŸŒŽ

โšก๏ธ ์ถ”๋ก 
- AutoGPTQ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ GPTQ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Llama 2 ๋ชจ๋ธ์„ ์–‘์žํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ [๋…ธํŠธ๋ถ](https://colab.research.google.com/drive/1TC56ArKerXUpbgRy5vM3woRsbTEVNq7h?usp=sharing)์ž…๋‹ˆ๋‹ค. ๐ŸŒŽ
- ๋กœ์ปฌ ์ปดํ“จํ„ฐ๋‚˜ Google Colab์—์„œ 4-bit ์–‘์žํ™”๋กœ Llama 2 ์ฑ„ํŒ… ๋ชจ๋ธ์„ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ [๋…ธํŠธ๋ถ](https://colab.research.google.com/drive/1X1z9Q6domMKl2CnEM0QGHNwidLfR4dW2?usp=sharing)์ž…๋‹ˆ๋‹ค. ๐ŸŒŽ

๐Ÿš€ ๋ฐฐํฌ
- [Amazon SageMaker์—์„œ LLaMA 2 (7-70B) ๋ฏธ์„ธ ์กฐ์ •ํ•˜๊ธฐ](https://www.philschmid.de/sagemaker-llama2-qlora), Amazon SageMaker์—์„œ QLoRA ๋ฏธ์„ธ ์กฐ์ • ๋ฐ ๋ฐฐํฌ์— ์ด๋ฅด๊ธฐ๊นŒ์ง€์˜ ์™„์ „ํ•œ ๊ฐ€์ด๋“œ์ž…๋‹ˆ๋‹ค.
- [Amazon SageMaker์—์„œ Llama 2 7B/13B/70B ๋ฐฐํฌํ•˜๊ธฐ](https://www.philschmid.de/sagemaker-llama-llm), ์•ˆ์ „ํ•˜๊ณ  ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด Hugging Face์˜ LLM DLC ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๊ฐ€์ด๋“œ์ž…๋‹ˆ๋‹ค.


## LlamaConfig [[llamaconfig]]

[[autodoc]] LlamaConfig


## LlamaTokenizer [[llamatokenizer]]

[[autodoc]] LlamaTokenizer
- build_inputs_with_special_tokens
- get_special_tokens_mask
- create_token_type_ids_from_sequences
- save_vocabulary

## LlamaTokenizerFast [[llamatokenizerfast]]

[[autodoc]] LlamaTokenizerFast
- build_inputs_with_special_tokens
- get_special_tokens_mask
- create_token_type_ids_from_sequences
- update_post_processor
- save_vocabulary

## LlamaModel [[llamamodel]]

[[autodoc]] LlamaModel
- forward


## LlamaForCausalLM [[llamaforcausallm]]

[[autodoc]] LlamaForCausalLM
- forward

## LlamaForSequenceClassification [[llamaforsequenceclassification]]

[[autodoc]] LlamaForSequenceClassification
- forward