RichardErkhov
commited on
Commit
โข
2327fb4
1
Parent(s):
7b009fe
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
ko-gemma-2-9b-it - GGUF
|
11 |
+
- Model creator: https://huggingface.co/rtzr/
|
12 |
+
- Original model: https://huggingface.co/rtzr/ko-gemma-2-9b-it/
|
13 |
+
|
14 |
+
|
15 |
+
| Name | Quant method | Size |
|
16 |
+
| ---- | ---- | ---- |
|
17 |
+
| [ko-gemma-2-9b-it.Q2_K.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q2_K.gguf) | Q2_K | 3.54GB |
|
18 |
+
| [ko-gemma-2-9b-it.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.IQ3_XS.gguf) | IQ3_XS | 3.86GB |
|
19 |
+
| [ko-gemma-2-9b-it.IQ3_S.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.IQ3_S.gguf) | IQ3_S | 4.04GB |
|
20 |
+
| [ko-gemma-2-9b-it.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q3_K_S.gguf) | Q3_K_S | 4.04GB |
|
21 |
+
| [ko-gemma-2-9b-it.IQ3_M.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.IQ3_M.gguf) | IQ3_M | 4.19GB |
|
22 |
+
| [ko-gemma-2-9b-it.Q3_K.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q3_K.gguf) | Q3_K | 4.43GB |
|
23 |
+
| [ko-gemma-2-9b-it.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q3_K_M.gguf) | Q3_K_M | 4.43GB |
|
24 |
+
| [ko-gemma-2-9b-it.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q3_K_L.gguf) | Q3_K_L | 4.78GB |
|
25 |
+
| [ko-gemma-2-9b-it.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.IQ4_XS.gguf) | IQ4_XS | 4.86GB |
|
26 |
+
| [ko-gemma-2-9b-it.Q4_0.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q4_0.gguf) | Q4_0 | 5.07GB |
|
27 |
+
| [ko-gemma-2-9b-it.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.IQ4_NL.gguf) | IQ4_NL | 5.1GB |
|
28 |
+
| [ko-gemma-2-9b-it.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q4_K_S.gguf) | Q4_K_S | 5.1GB |
|
29 |
+
| [ko-gemma-2-9b-it.Q4_K.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q4_K.gguf) | Q4_K | 5.37GB |
|
30 |
+
| [ko-gemma-2-9b-it.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q4_K_M.gguf) | Q4_K_M | 5.37GB |
|
31 |
+
| [ko-gemma-2-9b-it.Q4_1.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q4_1.gguf) | Q4_1 | 5.55GB |
|
32 |
+
| [ko-gemma-2-9b-it.Q5_0.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q5_0.gguf) | Q5_0 | 6.04GB |
|
33 |
+
| [ko-gemma-2-9b-it.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q5_K_S.gguf) | Q5_K_S | 6.04GB |
|
34 |
+
| [ko-gemma-2-9b-it.Q5_K.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q5_K.gguf) | Q5_K | 6.19GB |
|
35 |
+
| [ko-gemma-2-9b-it.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q5_K_M.gguf) | Q5_K_M | 6.19GB |
|
36 |
+
| [ko-gemma-2-9b-it.Q5_1.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q5_1.gguf) | Q5_1 | 6.52GB |
|
37 |
+
| [ko-gemma-2-9b-it.Q6_K.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q6_K.gguf) | Q6_K | 7.07GB |
|
38 |
+
| [ko-gemma-2-9b-it.Q8_0.gguf](https://huggingface.co/RichardErkhov/rtzr_-_ko-gemma-2-9b-it-gguf/blob/main/ko-gemma-2-9b-it.Q8_0.gguf) | Q8_0 | 9.15GB |
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
Original model description:
|
44 |
+
---
|
45 |
+
license: gemma
|
46 |
+
library_name: transformers
|
47 |
+
pipeline_tag: text-generation
|
48 |
+
extra_gated_heading: Access Gemma on Hugging Face
|
49 |
+
extra_gated_prompt: >-
|
50 |
+
To access Gemma on Hugging Face, youโre required to review and agree to
|
51 |
+
Googleโs usage license. To do this, please ensure youโre logged in to Hugging
|
52 |
+
Face and click below. Requests are processed immediately.
|
53 |
+
extra_gated_button_content: Acknowledge license
|
54 |
+
tags:
|
55 |
+
- conversational
|
56 |
+
base_model:
|
57 |
+
- google/gemma-2-9b
|
58 |
+
language:
|
59 |
+
- ko
|
60 |
+
---
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
## Model Details
|
65 |
+
|
66 |
+
### Ko-Gemma-2-9B-IT
|
67 |
+
|
68 |
+
**[Ko-Gemma-2-9B-IT](https://huggingface.co/rtzr/ko-gemma-2-9b-it)** is a Korean-language conversational model that is part of the Gemma family of models. It is a text-to-text, decoder-only large language model, available in Korean. We fine-tuned this model on a carefully curated high-quality dataset using Supervised Fine-Tuning (SFT). And we use [Direct Preference Optimization](https://arxiv.org/abs/2305.18290) training specifically for Human Feedback. The datasets include:
|
69 |
+
|
70 |
+
- [Orca-Math](https://huggingface.co/datasets/kuotient/orca-math-korean-dpo-pairs)
|
71 |
+
- [dpo-mix-7k](https://huggingface.co/datasets/argilla/dpo-mix-7k)
|
72 |
+
|
73 |
+
Some of these datasets were partially used and translated for training. In particular, a lot of repetition occurred during the translation process, so preprocessing was performed based on N-gram.
|
74 |
+
|
75 |
+
#### *Inputs and outputs*
|
76 |
+
|
77 |
+
- **Input:** Text string, such as a question, a prompt, or a document to be summarized.
|
78 |
+
- **Output:** Generated Korean-language text in response to the input, such as an answer to a question, or a summary of a document.
|
79 |
+
|
80 |
+
### Google Gemma 2
|
81 |
+
|
82 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
83 |
+
built from the same research and technology used to create the Gemini models.
|
84 |
+
They are text-to-text, decoder-only large language models, available in English,
|
85 |
+
with open weights for both pre-trained variants and instruction-tuned variants.
|
86 |
+
Gemma models are well-suited for a variety of text generation tasks, including
|
87 |
+
question answering, summarization, and reasoning. Their relatively small size
|
88 |
+
makes it possible to deploy them in environments with limited resources such as
|
89 |
+
a laptop, desktop or your own cloud infrastructure, democratizing access to
|
90 |
+
state of the art AI models and helping foster innovation for everyone.
|
91 |
+
|
92 |
+
## Benchmark Scores
|
93 |
+
|
94 |
+
We evaluated it internally using [LogicKor](https://github.com/instructkr/LogicKor) code. While the public LogicKor code is assessed as GPT-4, our internal evaluation was conducted as GPT-4o. Public scores will be added as they are released. The scores below include only 0-shot evaluations.
|
95 |
+
|
96 |
+
| Model | Math | Reasoning | Writing | Coding | Understanding | Grammar | Single ALL | Multi ALL | Overall |
|
97 |
+
|:---------:|:-----:|:------:|:-----:|:-----:|:----:|:-----:|:-----:|:-----:|:----:|
|
98 |
+
| [rtzr/ko-gemma-2-9b-it](https://huggingface.co/rtzr/ko-gemma-2-9b-it) | 8.71 / 8.00 | 9.14 / 8.00 | 9.43 / 9.29 | 9.00 / 9.43 | 9.57 / 9.86 | 7.14 / 5.00 | 8.83 | 8.26 | 8.55 |
|
99 |
+
| [google/gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it) | 8.57 / 7.71 | 8.86 / 7.00 | 9.29 / 9.29 | 9.29 / 9.57 | 8.57 / 8.29 | 6.86 / 3.86 | 8.57 | 7.62 | 8.10 |
|
100 |
+
| [MLP-KTLim/llama-3-Korean-Bllossom-8B](https://huggingface.co/MLP-KTLim/llama-3-Korean-Bllossom-8B) | 6.43 / 5.71 | 6.86 / 5.14 | 9.14 / 8.57 | 8.29 / 8.14 | 8.43 / 9.29 | 5.71 / 5.29 | 7.48 | 7.02 | 7.25 |
|
101 |
+
| [yanolja/EEVE-Korean-Instruct-10.8B-v1.0](https://huggingface.co/yanolja/EEVE-Korean-Instruct-10.8B-v1.0) | 5.57 / 4.29 | 8.14 / 5.14 | 8.29 / 6.29 | 6.43 / 7.86 | 9.29 / 8.57 | 6.57 / 3.71 | 7.38 | 5.98 | 6.68 |
|
102 |
+
| [allganize/Llama-3-Alpha-Ko-8B-Instruct](https://huggingface.co/allganize/Llama-3-Alpha-Ko-8B-Instruct) | 4.57 / 3.00 | 6.86 / 6.43 | 7.43 / 6.71 | 8.43 / 8.43| 7.71 / 8.71 | 6.71 / 4.43 | 6.95 | 6.29 | 6.62 |
|
103 |
+
|
104 |
+
## Usage
|
105 |
+
|
106 |
+
### Install Dependencies
|
107 |
+
|
108 |
+
You must install transformers >= 4.42.3 for gemma2 models.
|
109 |
+
|
110 |
+
```bash
|
111 |
+
pip install transformers==4.42.3 accelerate
|
112 |
+
```
|
113 |
+
|
114 |
+
### Python code with Pipeline
|
115 |
+
|
116 |
+
```python
|
117 |
+
import transformers
|
118 |
+
import torch
|
119 |
+
|
120 |
+
|
121 |
+
model_id = "rtzr/ko-gemma-2-9b-it"
|
122 |
+
|
123 |
+
pipeline = transformers.pipeline(
|
124 |
+
"text-generation",
|
125 |
+
model=model_id,
|
126 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
127 |
+
device_map="auto",
|
128 |
+
)
|
129 |
+
|
130 |
+
pipeline.model.eval()
|
131 |
+
instruction = "์์ธ์ ์ ๋ช
ํ ๊ด๊ด ์ฝ์ค๋ฅผ ๋ง๋ค์ด์ค๋?"
|
132 |
+
|
133 |
+
messages = [
|
134 |
+
{"role": "user", "content": f"{instruction}"}
|
135 |
+
]
|
136 |
+
|
137 |
+
prompt = pipeline.tokenizer.apply_chat_template(
|
138 |
+
messages,
|
139 |
+
tokenize=False,
|
140 |
+
add_generation_prompt=True
|
141 |
+
)
|
142 |
+
|
143 |
+
terminators = [
|
144 |
+
pipeline.tokenizer.eos_token_id,
|
145 |
+
pipeline.tokenizer.convert_tokens_to_ids("<end_of_turn>")
|
146 |
+
]
|
147 |
+
|
148 |
+
outputs = pipeline(
|
149 |
+
prompt,
|
150 |
+
max_new_tokens=2048,
|
151 |
+
eos_token_id=terminators,
|
152 |
+
do_sample=True,
|
153 |
+
temperature=0.6,
|
154 |
+
top_p=0.9,
|
155 |
+
)
|
156 |
+
|
157 |
+
print(outputs[0]["generated_text"][len(prompt):])
|
158 |
+
```
|
159 |
+
|
160 |
+
```markdown
|
161 |
+
์์ธ์ ์ญ์ฌ, ๋ฌธํ, ํ๋์ฑ์ด ์กฐํ๋ฅผ ์ด๋ฃฌ ๋งค๋ ฅ์ ์ธ ๋์์
๋๋ค. ์ฌ๊ธฐ์ ์ฆ๊ธธ ์ ์๋ ๋ค์ํ ๊ด๊ด์ง์ ๋ช
์๋ฅผ ์๊ฐํฉ๋๋ค. ๋ค์์ ์์ธ์ ์ ๋ช
ํ ๊ด๊ด ์ฝ์ค 3๊ฐ์ง์
๋๋ค.
|
162 |
+
|
163 |
+
**1. ์ญ์ฌ์ ๋ฌธํ๋ฅผ ๋๋ฌ์ผ ํ๊ตญ๊ด๊ด์ฝ์ค**
|
164 |
+
|
165 |
+
1. **๊ฒฝ๋ณต๊ถ**: ์กฐ์ ์๋์ ์
์ฅํ ์๊ถ์ ๋ง๋ฝํ ์ ์๋ ๊ณณ์
๋๋ค. ํนํ ๋งค๋
๋ด์ ์ด๋ฆฌ๋ '์ถ์ถ์ฐํ'๋ ๊ฒฝ๋ณต๊ถ์ ์๋ฆ๋ค์์ ๋์ฑ ๋๋ณด์ด๊ฒ ํฉ๋๋ค.
|
166 |
+
2. **๋ถ์ด ํ์ฅ๋ง์**: ๊ณ ํ์ค๋ฌ์ด ํ์ฅ์ด ๋ชจ์ฌ์๋ ๊ณณ์ผ๋ก, ์ ํต ๋ฌธํ ์ฒดํ์ด ๊ฐ๋ฅํฉ๋๋ค. '๋ถ์ด ํ์ฅ๋ง์ ๋ฌธํ์ฒดํ๊ด'์์๋ ํ๋ณต ์ฒดํ๋ถํฐ ์ข
์ด๋งํ, ํ๊ธ ์ฐ๊ธฐ ๋ฑ ๋ค์ํ ํ๋ก๊ทธ๋จ์ด ์ค๋น๋์ด ์์ต๋๋ค.
|
167 |
+
3. **์ธ์ฌ๋**: ์์ , ๋ฏธ์ ๊ด, ํ์๋น์ด ๋ง์ ๊ณณ์
๋๋ค. ํนํ '์ธ์ฌ๋ ๋ฌธํ๊ด'์์๋ ์์ธ์ ์ญ์ฌ์ ๋ฌธํ๋ฅผ ์ดํดํ๋ ๋ฐ ๋์์ด ๋๋ ์ ์๋ฅผ ๋ณผ ์ ์์ต๋๋ค.
|
168 |
+
4. **๊ดํ๋ฌธ** ๋ฐ **๋ช
๋**: ํ๋์ ์ธ ์ผํ๊ณผ ๋ ์คํ ๋์ด ์ฆ๋นํ ๊ณณ์
๋๋ค. ๊ดํ๋ฌธ์ ํนํ ์ ์์ด๋ค์ด ๋ง์ ๊ณณ์ผ๋ก, ์คํธ๋ฆฌํธ ํจ์
์ ๊ด์ฐฐํ๊ฑฐ๋ ๋ฐค๊ฑฐ๋ฆฌ์์ ํ๊ธฐ๋ฅผ ๋๋ ์ ์์ต๋๋ค.
|
169 |
+
|
170 |
+
**2. ๏ฟฝ๏ฟฝ์์ ๋ชจ์ต์ ๋ฐ๋ผ๋ณด๋ ๋ทฐํฌ์ด ์ฝ์ค**
|
171 |
+
|
172 |
+
1. **๋จ์ฐํ์**: ์์ธ์ ์์ง์ ์ธ ๊ฑด๋ฌผ๋ก, ๊ผญ๋๊ธฐ์์ ํผ์ณ์ง๋ 360๋์ ๊ฒฝ์น๊ฐ ์๋๋ค. ํนํ ๋ฐค์ด ๋๋ฉด ์กฐ๋ช
์ด ์ด์ฐ๋ฌ์ ธ ๋์ฑ ์๋ฆ๋ค์์ง๋๋ค.
|
173 |
+
2. **์์ธํ์**: ๋จ์ฐํ์์ ๋น์ทํ ์์น๋ก, ๋์ด๊ฐ ๋ ๋๊ธฐ ๋๋ฌธ์ ๋ ๋์ ์ ๋ง์ ๋ณผ ์ ์์ต๋๋ค. ์์ธํ์ ๋ด๋ถ์๋ ๋ค์ํ ์ ์๊ด๊ณผ ๋ ์คํ ๋๋ ์์ต๋๋ค.
|
174 |
+
3. **๋ถ์
์ฐ**: ์์ธ์ ์ค์ฌ๋ถ์ ์์นํ ์ฐ์ผ๋ก, ์์ธ์ ๊ฒฝ์น๋ฅผ ์กฐ๊ธ ๋ค๋ฅธ ๊ด์ ์์ ๋ณผ ์ ์์ต๋๋ค. ํนํ ๋ถ์
์ฐ ์ ์์ธ ๋ถ์
์ฌ์์๋ ์ข์ ์ ๋ง์ ๋ณผ ์ ์์ต๋๋ค.
|
175 |
+
4. **์์ธ์ฒ**: ๋
น์ง ๊ณต๊ฐ์ผ๋ก, ๋์์ ํผ์กํจ์์ ๋ฒ์ด๋ ์ ์๋ ๊ณณ์
๋๋ค. ๋ํ, ์์ธ์ฒ ๋ด๋ถ์๋ '์์ธ์ฒ ์ํธํ๋ ์ ํธ'๋ผ๋ ๊ณต๊ฐ์ด ์์ด ์์ ๊ณผ ์์ฐ์ ํจ๊ป ์ฒดํํ ์ ์์ต๋๋ค.
|
176 |
+
|
177 |
+
**3. ํ๋ ๋ฌธํ๋ฅผ ๋ง๋๋ ์ฝ์ค**
|
178 |
+
|
179 |
+
1. **์ผ์ฑ๋**: ํ๋ ๋ฏธ์ ๊ด์ด ๋ง์ ๊ณณ์ผ๋ก, '์ผ์ฑ ๋ฏธ์ ๊ด', '์๋ชจ๋ฆฌ์นด๋์ค ๊ฐค๋ฌ๋ฆฌ' ๋ฑ์ด ์์ต๋๋ค. ๋ํ, '์ฝ์์ค'๋ '์ํฌ์นด๋กํฌ์ค' ๋ฑ์ ๋ช
์๋ ๊ฐ๊น์ด ๊ณณ์ ์์ต๋๋ค.
|
180 |
+
2. **์ดํ์**: ์ธ๊ตญ์ธ๋ค์ด ๋ง์ ๊ณณ์ผ๋ก, ๋ค์ํ ์ธ๊ตญ ์์์ ์ฆ๊ธธ ์ ์๋ ๊ณณ์
๋๋ค. ๋ํ, '์ดํ์ ๊ธ๋ก์ปฌ๋ฌธํ์ผํฐ'์์๋ ์ธ๊ณ ๊ฐ๊ตญ์ ๋ฌธํ ์ฒดํ์ด ๊ฐ๋ฅํฉ๋๋ค.
|
181 |
+
3. **ํ๋**: ์ ์์ด๋ค์ ๋ฌธํ๊ฐ ๋์น๋ ๊ณณ์
๋๋ค. 'ํ๋ ๋กค๋งํ'์ ํนํ ๋ง์ ์ฌ๋๋ค์ด ๋ฐฉ๋ฌธํ๋ ๊ณณ์
๋๋ค. ๋ํ, 'ํ๋ ์์ ๊ฑฐ๋ฆฌ'์์๋ ๋
์์ ๋ฌธํ๋ฅผ ๋ง๋ ์ ์์ต๋๋ค.
|
182 |
+
4. **๊ฐ๋จ**: ์์ธ์ ํ๋์ ๋ชจ์ต์ ์ ๋ณด์ฌ์ฃผ๋ ๊ณณ์
๋๋ค. '๊ฐ๋จ์ญ'์ ์ค์ฌ์ผ๋ก ๋ง์ ๊ณ ๊ธ ์ผํ๋ชฐ๊ณผ ๋ ์คํ ๋์ด ์์ต๋๋ค.
|
183 |
+
|
184 |
+
์ด๋ฌํ ์ฝ์ค๋ฅผ ํตํด ์์ธ์ ๋ค์ํ ๋ชจ์ต์ ํ ๋ฒ์ ๋ง๋๋ณผ ์ ์์ ๊ฑฐ์์. ๊ฐ์์ ์ทจํฅ์ ๋ง์ถฐ ์ฝ์ค๋ฅผ ์กฐ์ ํ์๋ฉด ์ข๊ฒ ์ต๋๋ค. ์ฆ๊ฑฐ์ด ์ฌํ ๋์ธ์!
|
185 |
+
```
|
186 |
+
|
187 |
+
### Python code with AutoModel
|
188 |
+
|
189 |
+
```python
|
190 |
+
import os
|
191 |
+
import torch
|
192 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
193 |
+
|
194 |
+
|
195 |
+
model_id = "rtzr/ko-gemma-2-9b-it"
|
196 |
+
|
197 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
198 |
+
model = AutoModelForCausalLM.from_pretrained(
|
199 |
+
model_id,
|
200 |
+
torch_dtype=torch.bfloat16,
|
201 |
+
device_map="auto",
|
202 |
+
)
|
203 |
+
|
204 |
+
model.eval()
|
205 |
+
instruction = "์์ธ์ ์ ๋ช
ํ ๊ด๊ด ์ฝ์ค๋ฅผ ๋ง๋ค์ด์ค๋?"
|
206 |
+
|
207 |
+
messages = [
|
208 |
+
{"role": "user", "content": f"{instruction}"}
|
209 |
+
]
|
210 |
+
|
211 |
+
input_ids = tokenizer.apply_chat_template(
|
212 |
+
messages,
|
213 |
+
add_generation_prompt=True,
|
214 |
+
return_tensors="pt"
|
215 |
+
).to(model.device)
|
216 |
+
|
217 |
+
terminators = [
|
218 |
+
tokenizer.eos_token_id,
|
219 |
+
tokenizer.convert_tokens_to_ids("<end_of_turn>")
|
220 |
+
]
|
221 |
+
|
222 |
+
outputs = model.generate(
|
223 |
+
input_ids,
|
224 |
+
max_new_tokens=2048,
|
225 |
+
eos_token_id=terminators,
|
226 |
+
do_sample=True,
|
227 |
+
temperature=0.6,
|
228 |
+
top_p=0.9,
|
229 |
+
)
|
230 |
+
|
231 |
+
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
|
232 |
+
```
|
233 |
+
|
234 |
+
```markdown
|
235 |
+
์์ธ ๊ด๊ด ์ฝ์ค๋ฅผ ์ ์ํด๋๋ฆด๊ฒ์. ํ๋ฃจ ์ข
์ผ ์ฆ๊ฒ๊ฒ ์ฌํํ ์ ์๋ ๋ฃจํธ๋ก ๊ตฌ์ฑํ์ต๋๋ค.
|
236 |
+
|
237 |
+
### 1. ์์ธ์ญ์ฌ๊ด ๋ฐ ๋ถ์ดํ์ฅ๋ง์(์ค์ )
|
238 |
+
|
239 |
+
- ์์ธ์ญ์ฌ๊ด: ์์ธ์ ์ญ์ฌ์ ๋ฌธํ๋ฅผ ์ฒดํํ ์ ์๋ ๊ณณ์
๋๋ค. ๋ค์ํ ์ ์๋ฌผ๊ณผ ์์ค์ ์๋ฅผ ํตํด ์์ธ์ ๋ณํ๋ฅผ ์ดํด๋ณผ ์ ์์ต๋๋ค.
|
240 |
+
- ๋ถ์ดํ์ฅ๋ง์: ์์ธ์ ํ์ฅ์ ๋ณด์กดํ๊ณ ๊ด๋ฆฌํ๋ ๊ณณ์
๋๋ค. ์กฐ์ ์๋์ ๋ถ์๊ธฐ๋ฅผ ๋๋ ์ ์์ผ๋ฉฐ, ํ์ฅ์์ ๋ฌธํ ์ฝํ
์ธ ๋ ์ ๊ณตํ๋ ๊ณณ๋ ๋ง์ต๋๋ค.
|
241 |
+
|
242 |
+
### 2. ๋ถ์
์ฐ ์
์ฅ๊ณผ ๋ถ์
์ฐ ๋ฑ์ฐ(์ค์ )
|
243 |
+
|
244 |
+
- ๋ถ์
์ฐ์ ์์ธ์ ๋ถ์ชฝ์ ์์นํ ์ฐ์ผ๋ก, ์์ธ ํ๋ณตํ์์๋ ์์ฐ์ ๋ง๋ ์ ์๋ ๊ณณ์
๋๋ค. ๋ถ์
์ฐ ์
๊ตฌ์์ ๋ฑ์ฐ์ ์์ํ์ฌ, ๋ถ์
์ฐ ์ ์๊น์ง ์ฌ๋ผ๊ฐ๋ฉด ์์ธ์ ์ ๊ฒฝ์ ๋ณผ ์ ์์ต๋๋ค.
|
245 |
+
|
246 |
+
### 3. ์ข
๋ก ๋ช
๋ ์ผํ๊ณผ ๋ง์ง ํฌ์ด(๋ฎ)
|
247 |
+
|
248 |
+
- ๋ช
๋: ๋ค์ํ ์ผํ๋ชฐ๊ณผ ๋งค์ฅ์ด ์๋ ๊ณณ์
๋๋ค. ๋ช
๋ ์ผํํ์ด, ๋ฏธ์คํฐํธ์์คํฐ, ๋ฏธ์คํฐ๋ฆฌ๋ง์ผ ๋ฑ์ ๋ฐฉ๋ฌธํด๋ณด์ธ์.
|
249 |
+
- ๋ง์ง ํฌ์ด: ๋ช
๋์๋ ๋ค์ํ ์ง์ญ ์์์ ๋จน์ ์ ์๋ ๊ณณ์ด ๋ง์ต๋๋ค. ๋ก๋ณถ์ด, ์๋, ๋ญ๊ฐ์ ๋ฑ์ ๋ง๋ณผ ์ ์๋ ๊ณณ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
|
250 |
+
|
251 |
+
### 4. ์์ธ์๋ฆฝ๋ฏธ์ ๊ด๊ณผ ๋์๊ถ(์คํ)
|
252 |
+
|
253 |
+
- ์์ธ์๋ฆฝ๋ฏธ์ ๊ด: ํ๋๋ฏธ์ ์ ์ ์ํ๋ ๊ณณ์
๋๋ค. ํน๋ณ์ ์ด ์ด๋ฆฐ๋ค๋ฉด ๋ฐฉ๋ฌธํด ๋ณผ ์ ์์ต๋๋ค.
|
254 |
+
- ๋์๊ถ: ์กฐ์ ์๋์ ๊ถ๊ถ์
๋๋ค. ํนํ ๋ด์๋ ๋ฒ๊ฝ์ด ์๋ฆ๋ต๊ฒ ๋ง๋ฐํฉ๋๋ค.
|
255 |
+
|
256 |
+
### 5. ๋จ์ฐํ์์ ๋จ์ฐ๊ณต์ ์ฐ์ฑ
(์คํ)
|
257 |
+
|
258 |
+
- ๋จ์ฐํ์: ๋จ์ฐ์ ์๋ ๊ด๋๋์
๋๋ค. ๋จ์ฐํ์์ ์ฌ๋ผ๊ฐ๋ฉด ์์ธ์ 360๋ ์ ๊ฒฝ์ ๋ณผ ์ ์์ต๋๋ค.
|
259 |
+
- ๋จ์ฐ๊ณต์: ๋จ์ฐ์ ์๋ ๊ณต์์
๋๋ค. ๋ค์ํ ํ
๋ง ๊ณต์๊ณผ ์กฐ๊ฒฝ์ด ์ ๋ ๊ณณ์
๋๋ค. ๋จ์ฐ๊ณต์์ ์ฐ์ฑ
ํ๋ฉฐ ํด์์ ์ทจํ ์ ์์ต๋๋ค.
|
260 |
+
|
261 |
+
### 6. ๋ช
๋ ๋๋ ์ดํ์์์์ ์ ๋
์์ฌ์ ๏ฟฝ๏ฟฝ๏ฟฝํ ํ๋(์ ๋
)
|
262 |
+
|
263 |
+
- ๋ช
๋: ๋ค์ํ ์ ํต์ ์ธ ํ๊ตญ ์์์ ๋จน์ ์ ์๋ ๊ณณ์
๋๋ค. ๋ํ, ๋ช
๋์ ๋ฐค์๋ ํ๊ธฐ์ฐจ๊ฒ ํ๋ฐํ ๋ฌธํ ์ํ์ ํ ์ ์๋ ๊ณณ์
๋๋ค.
|
264 |
+
- ์ดํ์: ์ธ๊ตญ์ธ ๊ด๊ด๊ฐ๋ค์ด ๋ง์ด ์ฐพ๋ ๊ณณ์ผ๋ก, ๋ค์ํ ์ธ๊ณ ์์์ ๋จน์ ์ ์์ผ๋ฉฐ, ํด๋ฝ์ด๋ ๋ฐ๊ฐ ๋ง์ ๋ฌธํ์ ํ๋์ด ๊ฐ๋ฅํ ๊ณณ์
๋๋ค.
|
265 |
+
|
266 |
+
์ด ์ฝ์ค๋ ํ๋ฃจ ์ข
์ผ ํ๋ฐํ๊ฒ ์ฌํ์ ํ ์ ์๋๋ก ๊ณํํ์ต๋๋ค. ๊ฐ ์ง์ญ์ ๋ฐ๋ผ ์ด๋ ์๊ฐ์ ๊ณ ๋ คํ์๊ณ , ๊ฐ์ฅ ์๊ฐ๊ณผ ์ ์ ์ผ์ ๋ฑ์ ๋ฏธ๋ฆฌ ํ์ธํ์๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ฆ๊ฑฐ์ด ์ฌํ ๋์ธ์!
|
267 |
+
```
|
268 |
+
|
269 |
+
### Quantized Versions through bitsandbytes
|
270 |
+
|
271 |
+
- *Using 8-bit precision*
|
272 |
+
- *Using 4-bit precision*
|
273 |
+
|
274 |
+
```python
|
275 |
+
# pip install bitsandbytes
|
276 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
277 |
+
|
278 |
+
|
279 |
+
model_id = "rtzr/ko-gemma-2-9b-it"
|
280 |
+
quantization_config_8bit = BitsAndBytesConfig(load_in_8bit=True)
|
281 |
+
# quantization_config_4bit = BitsAndBytesConfig(load_in_4bit=True)
|
282 |
+
|
283 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
284 |
+
model = AutoModelForCausalLM.from_pretrained(
|
285 |
+
model_id,
|
286 |
+
torch_dtype=torch.bfloat16,
|
287 |
+
device_map="auto",
|
288 |
+
quantization_config=quantization_config_8bit,
|
289 |
+
# quantization_config=quantization_config_4bit,
|
290 |
+
low_cpu_mem_usage=True,
|
291 |
+
)
|
292 |
+
|
293 |
+
model.eval()
|
294 |
+
instruction = "์์ธ์ ์ ๋ช
ํ ๊ด๊ด ์ฝ์ค๋ฅผ ๋ง๋ค์ด์ค๋?"
|
295 |
+
|
296 |
+
messages = [
|
297 |
+
{"role": "user", "content": f"{instruction}"}
|
298 |
+
]
|
299 |
+
|
300 |
+
input_ids = tokenizer.apply_chat_template(
|
301 |
+
messages,
|
302 |
+
add_generation_prompt=True,
|
303 |
+
return_tensors="pt"
|
304 |
+
).to(model.device)
|
305 |
+
|
306 |
+
terminators = [
|
307 |
+
tokenizer.eos_token_id,
|
308 |
+
tokenizer.convert_tokens_to_ids("<end_of_turn>")
|
309 |
+
]
|
310 |
+
|
311 |
+
outputs = model.generate(
|
312 |
+
input_ids,
|
313 |
+
max_new_tokens=2048,
|
314 |
+
eos_token_id=terminators,
|
315 |
+
do_sample=True,
|
316 |
+
temperature=0.6,
|
317 |
+
top_p=0.9,
|
318 |
+
)
|
319 |
+
|
320 |
+
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
|
321 |
+
```
|
322 |
+
|
323 |
+
### VLLM Usage
|
324 |
+
|
325 |
+
When we use `vllm==0.5.1`, the gemma2 model cannot be loaded yet and the following [issue](https://github.com/vllm-project/vllm/issues/6237) occurs. So it is recommended to use `vllm/vllm-openai:latest` docker or [`vllm==0.5.0.post1`](https://github.com/vllm-project/vllm/releases/tag/v0.5.0.post1).
|
326 |
+
|
327 |
+
```bash
|
328 |
+
#!/bin/bash
|
329 |
+
|
330 |
+
VLLM_ATTENTION_BACKEND=FLASHINFER
|
331 |
+
MODEL_NAME="rtzr/ko-gemma-2-9b-it"
|
332 |
+
|
333 |
+
MODEL_PATH="YOUR_PATH/${MODEL_NAME}"
|
334 |
+
docker run --rm --gpus all \
|
335 |
+
-p 8000:8000 \
|
336 |
+
--shm-size=12gb --ulimit memlock=-1 --ulimit stack=67108864 \
|
337 |
+
-e VLLM_ATTENTION_BACKEND=${VLLM_ATTENTION_BACKEND} \
|
338 |
+
-v $MODEL_PATH:/vllm-workspace/${MODEL_NAME} \
|
339 |
+
vllm/vllm-openai:latest \
|
340 |
+
--model ${MODEL_NAME} --dtype auto \
|
341 |
+
--gpu-memory-utilization 0.8
|
342 |
+
```
|
343 |
+
|
344 |
+
## License
|
345 |
+
|
346 |
+
Gemma 2 License: <https://ai.google.dev/gemma/terms>
|
347 |
+
|
348 |
+
## Citation
|
349 |
+
|
350 |
+
```none
|
351 |
+
@article{RTZR,
|
352 |
+
title={ko-gemma-2-9b-it},
|
353 |
+
author={Return Zero Team},
|
354 |
+
year={2024},
|
355 |
+
url={https://huggingface.co/rtzr/ko-gemma-2-9b-it}
|
356 |
+
}
|
357 |
+
```
|
358 |
+
|
359 |
+
```none
|
360 |
+
@article{gemma_2024,
|
361 |
+
title={Gemma},
|
362 |
+
url={https://www.kaggle.com/m/3301},
|
363 |
+
DOI={10.34740/KAGGLE/M/3301},
|
364 |
+
publisher={Kaggle},
|
365 |
+
author={Gemma Team},
|
366 |
+
year={2024}
|
367 |
+
}
|
368 |
+
```
|
369 |
+
|
370 |
+
|