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
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
extra_gated_heading: Access Gemma on Hugging Face
|
| 6 |
+
extra_gated_prompt: >-
|
| 7 |
+
To access Gemma on Hugging Face, you’re required to review and agree to
|
| 8 |
+
Google’s usage license. To do this, please ensure you’re logged in to Hugging
|
| 9 |
+
Face and click below. Requests are processed immediately.
|
| 10 |
+
extra_gated_button_content: Acknowledge license
|
| 11 |
+
tags:
|
| 12 |
+
- conversational
|
| 13 |
+
base_model:
|
| 14 |
+
- rtzr/ko-gemma-2-9b-it
|
| 15 |
+
language:
|
| 16 |
+
- ko
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
#KIST-robot-intelligence/ko-gemma-2-9b-it-GGUF
|
| 20 |
+
This is quantized version of [rtzr/ko-gemma-2-9b-it](https://huggingface.co/rtzr/ko-gemma-2-9b-it) created using llama.cpp
|
| 21 |
+
|
| 22 |
+
# Model Description
|
| 23 |
+
|
| 24 |
+
### Ko-Gemma-2-9B-IT
|
| 25 |
+
|
| 26 |
+
**[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:
|
| 27 |
+
|
| 28 |
+
- [Orca-Math](https://huggingface.co/datasets/kuotient/orca-math-korean-dpo-pairs)
|
| 29 |
+
- [dpo-mix-7k](https://huggingface.co/datasets/argilla/dpo-mix-7k)
|
| 30 |
+
|
| 31 |
+
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.
|
| 32 |
+
|
| 33 |
+
#### *Inputs and outputs*
|
| 34 |
+
|
| 35 |
+
- **Input:** Text string, such as a question, a prompt, or a document to be summarized.
|
| 36 |
+
- **Output:** Generated Korean-language text in response to the input, such as an answer to a question, or a summary of a document.
|
| 37 |
+
|
| 38 |
+
### Google Gemma 2
|
| 39 |
+
|
| 40 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
| 41 |
+
built from the same research and technology used to create the Gemini models.
|
| 42 |
+
They are text-to-text, decoder-only large language models, available in English,
|
| 43 |
+
with open weights for both pre-trained variants and instruction-tuned variants.
|
| 44 |
+
Gemma models are well-suited for a variety of text generation tasks, including
|
| 45 |
+
question answering, summarization, and reasoning. Their relatively small size
|
| 46 |
+
makes it possible to deploy them in environments with limited resources such as
|
| 47 |
+
a laptop, desktop or your own cloud infrastructure, democratizing access to
|
| 48 |
+
state of the art AI models and helping foster innovation for everyone.
|
| 49 |
+
|
| 50 |
+
## Benchmark Scores
|
| 51 |
+
|
| 52 |
+
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.
|
| 53 |
+
|
| 54 |
+
| Model | Math | Reasoning | Writing | Coding | Understanding | Grammar | Single ALL | Multi ALL | Overall |
|
| 55 |
+
|:---------:|:-----:|:------:|:-----:|:-----:|:----:|:-----:|:-----:|:-----:|:----:|
|
| 56 |
+
| [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 |
|
| 57 |
+
| [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 |
|
| 58 |
+
| [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 |
|
| 59 |
+
| [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 |
|
| 60 |
+
| [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 |
|
| 61 |
+
|
| 62 |
+
## Usage
|
| 63 |
+
|
| 64 |
+
### Install Dependencies
|
| 65 |
+
|
| 66 |
+
You must install transformers >= 4.42.3 for gemma2 models.
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
pip install transformers==4.42.3 accelerate
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
### Python code with Pipeline
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
import transformers
|
| 76 |
+
import torch
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
model_id = "rtzr/ko-gemma-2-9b-it"
|
| 80 |
+
|
| 81 |
+
pipeline = transformers.pipeline(
|
| 82 |
+
"text-generation",
|
| 83 |
+
model=model_id,
|
| 84 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
| 85 |
+
device_map="auto",
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
pipeline.model.eval()
|
| 89 |
+
instruction = "서울의 유명한 관광 코스를 만들어줄래?"
|
| 90 |
+
|
| 91 |
+
messages = [
|
| 92 |
+
{"role": "user", "content": f"{instruction}"}
|
| 93 |
+
]
|
| 94 |
+
|
| 95 |
+
prompt = pipeline.tokenizer.apply_chat_template(
|
| 96 |
+
messages,
|
| 97 |
+
tokenize=False,
|
| 98 |
+
add_generation_prompt=True
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
terminators = [
|
| 102 |
+
pipeline.tokenizer.eos_token_id,
|
| 103 |
+
pipeline.tokenizer.convert_tokens_to_ids("<end_of_turn>")
|
| 104 |
+
]
|
| 105 |
+
|
| 106 |
+
outputs = pipeline(
|
| 107 |
+
prompt,
|
| 108 |
+
max_new_tokens=2048,
|
| 109 |
+
eos_token_id=terminators,
|
| 110 |
+
do_sample=True,
|
| 111 |
+
temperature=0.6,
|
| 112 |
+
top_p=0.9,
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
print(outputs[0]["generated_text"][len(prompt):])
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
```markdown
|
| 119 |
+
서울은 역사, 문화, 현대성이 조화를 이룬 매력적인 도시입니다. 여기서 즐길 수 있는 다양한 관광지와 명소를 소개합니다. 다음은 서울의 유명한 관광 코스 3가지입니다.
|
| 120 |
+
|
| 121 |
+
**1. 역사와 문화를 둘러싼 한국관광코스**
|
| 122 |
+
|
| 123 |
+
1. **경복궁**: 조선 시대의 웅장한 왕궁을 만끽할 수 있는 곳입니다. 특히 매년 봄에 열리는 '춘추연회'는 경복궁의 아름다움을 더욱 돋보이게 합니다.
|
| 124 |
+
2. **북촌 한옥마을**: 고풍스러운 한옥이 모여있는 곳으로, 전통 문화 체험이 가능합니다. '북촌 한옥마을 문화체험관'에서는 한복 체험부터 종이만화, 한글 쓰기 등 다양한 프로그램이 준비되어 있습니다.
|
| 125 |
+
3. **인사동**: 서점, 미술관, 한식당이 많은 곳입니다. 특히 '인사동 문화관'에서는 서울의 역사와 문화를 이해하는 데 도움이 되는 전시를 볼 수 있습니다.
|
| 126 |
+
4. **광화문** 및 **명동**: 현대적인 쇼핑과 레스토랑이 즐비한 곳입니다. 광화문은 특히 젊은이들이 많은 곳으로, 스트리트 패션을 관찰하거나 밤거리에서 활기를 느낄 수 있습니다.
|
| 127 |
+
|
| 128 |
+
**2. 도시의 모습을 바라보는 뷰투어 코스**
|
| 129 |
+
|
| 130 |
+
1. **남산타워**: 서울의 상징적인 건물로, 꼭대기에서 펼쳐지는 360도의 경치가 압니다. 특히 밤이 되면 조명이 어우러져 더욱 아름다워집니다.
|
| 131 |
+
2. **서울타워**: 남산타워와 비슷한 위치로, 높이가 더 높기 때문에 더 넓은 전망을 볼 수 있습니다. 서울타워 내부에는 다양한 전시관과 레스토랑도 있습니다.
|
| 132 |
+
3. **북악산**: 서울의 중심부에 위치한 산으로, 서울의 경치를 조금 다른 관점에서 볼 수 있습니다. 특히 북악산 정상인 북악사에서도 좋은 전망을 볼 수 있습니다.
|
| 133 |
+
4. **서울숲**: 녹지 공간으로, 도시의 혼잡함에서 벗어날 수 있는 곳입니다. 또한, 서울숲 내부에는 '서울숲 아트프레젠트'라는 공간이 있어 예술과 자연을 함께 체험할 수 있습니다.
|
| 134 |
+
|
| 135 |
+
**3. 현대 문화를 만나는 코스**
|
| 136 |
+
|
| 137 |
+
1. **삼성동**: 현대 미술관이 많은 곳으로, '삼성 미술관', '아모리카나스 갤러리' 등이 있습니다. 또한, '코엑스'나 '아포카로포스' 등의 명소도 가까운 곳에 있습니다.
|
| 138 |
+
2. **이태원**: 외국인들이 많은 곳으로, 다양한 외국 음식을 즐길 수 있는 곳입니다. 또한, '이태원 글로컬문화센터'에서는 세계 각국의 문화 체험이 가능합니다.
|
| 139 |
+
3. **홍대**: 젊은이들의 문화가 넘치는 곳입니다. '홍대 롤링홀'은 특히 많은 사람들이 방문하는 곳입니다. 또한, '홍대 서점거리'에서는 독서와 문화를 만날 수 있습니다.
|
| 140 |
+
4. **강남**: 서울의 현대적 모습을 잘 보여주는 곳입니다. '강남역'을 중심으로 많은 고급 쇼핑몰과 레스토랑이 있습니다.
|
| 141 |
+
|
| 142 |
+
이러한 코스를 통해 서울의 다양한 모습을 한 번에 만나볼 수 있을 거예요. 각자의 취향에 맞춰 코스를 조절하시면 좋겠습니다. 즐거운 여행 되세요!
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
### Python code with AutoModel
|
| 146 |
+
|
| 147 |
+
```python
|
| 148 |
+
import os
|
| 149 |
+
import torch
|
| 150 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
model_id = "rtzr/ko-gemma-2-9b-it"
|
| 154 |
+
|
| 155 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 156 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 157 |
+
model_id,
|
| 158 |
+
torch_dtype=torch.bfloat16,
|
| 159 |
+
device_map="auto",
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
model.eval()
|
| 163 |
+
instruction = "서울의 유명한 관광 코스를 만들어줄래?"
|
| 164 |
+
|
| 165 |
+
messages = [
|
| 166 |
+
{"role": "user", "content": f"{instruction}"}
|
| 167 |
+
]
|
| 168 |
+
|
| 169 |
+
input_ids = tokenizer.apply_chat_template(
|
| 170 |
+
messages,
|
| 171 |
+
add_generation_prompt=True,
|
| 172 |
+
return_tensors="pt"
|
| 173 |
+
).to(model.device)
|
| 174 |
+
|
| 175 |
+
terminators = [
|
| 176 |
+
tokenizer.eos_token_id,
|
| 177 |
+
tokenizer.convert_tokens_to_ids("<end_of_turn>")
|
| 178 |
+
]
|
| 179 |
+
|
| 180 |
+
outputs = model.generate(
|
| 181 |
+
input_ids,
|
| 182 |
+
max_new_tokens=2048,
|
| 183 |
+
eos_token_id=terminators,
|
| 184 |
+
do_sample=True,
|
| 185 |
+
temperature=0.6,
|
| 186 |
+
top_p=0.9,
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
```markdown
|
| 193 |
+
서울 관광 코스를 제안해드릴게요. 하루 종일 즐겁게 여행할 수 있는 루트로 구성했습니다.
|
| 194 |
+
|
| 195 |
+
### 1. 서울역사관 및 북촌한옥마을(오전)
|
| 196 |
+
|
| 197 |
+
- 서울역사관: 서울의 역사와 문화를 체험할 수 있는 곳입니다. 다양한 전시물과 상설전시를 통해 서울의 변화를 살펴볼 수 있습니다.
|
| 198 |
+
- 북촌한옥마을: 서울의 한옥을 보존하고 관리하는 곳입니다. 조선 시대의 분위기를 느낄 수 있으며, 한옥에서 문화 콘텐츠도 제공하는 곳도 많습니다.
|
| 199 |
+
|
| 200 |
+
### 2. 북악산 입장과 북악산 등산(오전)
|
| 201 |
+
|
| 202 |
+
- 북악산은 서울의 북쪽에 위치한 산으로, 서울 한복판에서도 자연을 만날 수 있는 곳입니다. 북���산 입구에서 등산을 시작하여, 북악산 정상까지 올라가면 서울의 전경을 볼 수 있습니다.
|
| 203 |
+
|
| 204 |
+
### 3. 종로 명동 쇼핑과 맛집 투어(낮)
|
| 205 |
+
|
| 206 |
+
- 명동: 다양한 쇼핑몰과 매장이 있는 곳입니다. 명동 쇼핑타운, 미스터트위스터, 미스터리마켓 등을 방문해보세요.
|
| 207 |
+
- 맛집 투어: 명동에는 다양한 지역 음식을 먹을 수 있는 곳이 많습니다. 떡볶이, 순대, 닭강정 등을 맛볼 수 있는 곳을 추천드립니다.
|
| 208 |
+
|
| 209 |
+
### 4. 서울시립미술관과 덕수궁(오후)
|
| 210 |
+
|
| 211 |
+
- 서울시립미술관: 현대미술을 전시하는 곳입니다. 특별전이 열린다면 방문해 볼 수 있습니다.
|
| 212 |
+
- 덕수궁: 조선시대의 궁궐입니다. 특히 봄에는 벚꽃이 아름답게 만발합니다.
|
| 213 |
+
|
| 214 |
+
### 5. 남산타워와 남산공원 산책(오후)
|
| 215 |
+
|
| 216 |
+
- 남산타워: 남산에 있는 관람대입니다. 남산타워에 올라가면 서울의 360도 전경을 볼 수 있습니다.
|
| 217 |
+
- 남산공원: 남산에 있는 공원입니다. 다양한 테마 공원과 조경이 잘 된 곳입니다. 남산공원을 산책하며 휴식을 취할 수 있습니다.
|
| 218 |
+
|
| 219 |
+
### 6. 명동 또는 이태원에서의 저녁 식사와 문화 활동(저녁)
|
| 220 |
+
|
| 221 |
+
- 명동: 다양한 전통적인 한국 음식을 먹을 수 있는 곳입니다. 또한, 명동은 밤에도 활기차게 활발한 문화 생활을 할 수 있는 곳입니다.
|
| 222 |
+
- 이태원: 외국인 관광객들이 많이 찾는 곳으로, 다양한 세계 음식을 먹을 수 있으며, 클럽이나 바가 많은 문화적 활동이 가능한 곳입니다.
|
| 223 |
+
|
| 224 |
+
이 코스는 하루 종일 활발하게 여행을 할 수 있도록 계획했습니다. 각 지역에 따라 이동 시간을 고려하시고, 개장 시간과 전시 일정 등을 미리 확인하시는 것이 좋습니다. 즐거운 여행 되세요!
|
| 225 |
+
```
|
| 226 |
+
|
| 227 |
+
### Quantized Versions through bitsandbytes
|
| 228 |
+
|
| 229 |
+
- *Using 8-bit precision*
|
| 230 |
+
- *Using 4-bit precision*
|
| 231 |
+
|
| 232 |
+
```python
|
| 233 |
+
# pip install bitsandbytes
|
| 234 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
model_id = "rtzr/ko-gemma-2-9b-it"
|
| 238 |
+
quantization_config_8bit = BitsAndBytesConfig(load_in_8bit=True)
|
| 239 |
+
# quantization_config_4bit = BitsAndBytesConfig(load_in_4bit=True)
|
| 240 |
+
|
| 241 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 242 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 243 |
+
model_id,
|
| 244 |
+
torch_dtype=torch.bfloat16,
|
| 245 |
+
device_map="auto",
|
| 246 |
+
quantization_config=quantization_config_8bit,
|
| 247 |
+
# quantization_config=quantization_config_4bit,
|
| 248 |
+
low_cpu_mem_usage=True,
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
model.eval()
|
| 252 |
+
instruction = "서울의 유명한 관광 코스를 만들어줄래?"
|
| 253 |
+
|
| 254 |
+
messages = [
|
| 255 |
+
{"role": "user", "content": f"{instruction}"}
|
| 256 |
+
]
|
| 257 |
+
|
| 258 |
+
input_ids = tokenizer.apply_chat_template(
|
| 259 |
+
messages,
|
| 260 |
+
add_generation_prompt=True,
|
| 261 |
+
return_tensors="pt"
|
| 262 |
+
).to(model.device)
|
| 263 |
+
|
| 264 |
+
terminators = [
|
| 265 |
+
tokenizer.eos_token_id,
|
| 266 |
+
tokenizer.convert_tokens_to_ids("<end_of_turn>")
|
| 267 |
+
]
|
| 268 |
+
|
| 269 |
+
outputs = model.generate(
|
| 270 |
+
input_ids,
|
| 271 |
+
max_new_tokens=2048,
|
| 272 |
+
eos_token_id=terminators,
|
| 273 |
+
do_sample=True,
|
| 274 |
+
temperature=0.6,
|
| 275 |
+
top_p=0.9,
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
### VLLM Usage
|
| 282 |
+
|
| 283 |
+
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).
|
| 284 |
+
|
| 285 |
+
```bash
|
| 286 |
+
#!/bin/bash
|
| 287 |
+
|
| 288 |
+
VLLM_ATTENTION_BACKEND=FLASHINFER
|
| 289 |
+
MODEL_NAME="rtzr/ko-gemma-2-9b-it"
|
| 290 |
+
|
| 291 |
+
MODEL_PATH="YOUR_PATH/${MODEL_NAME}"
|
| 292 |
+
docker run --rm --gpus all \
|
| 293 |
+
-p 8000:8000 \
|
| 294 |
+
--shm-size=12gb --ulimit memlock=-1 --ulimit stack=67108864 \
|
| 295 |
+
-e VLLM_ATTENTION_BACKEND=${VLLM_ATTENTION_BACKEND} \
|
| 296 |
+
-v $MODEL_PATH:/vllm-workspace/${MODEL_NAME} \
|
| 297 |
+
vllm/vllm-openai:latest \
|
| 298 |
+
--model ${MODEL_NAME} --dtype auto \
|
| 299 |
+
--gpu-memory-utilization 0.8
|
| 300 |
+
```
|
| 301 |
+
|
| 302 |
+
## License
|
| 303 |
+
|
| 304 |
+
Gemma 2 License: <https://ai.google.dev/gemma/terms>
|
| 305 |
+
|
| 306 |
+
## Model Citation
|
| 307 |
+
|
| 308 |
+
```none
|
| 309 |
+
@article{RTZR,
|
| 310 |
+
title={ko-gemma-2-9b-it},
|
| 311 |
+
author={Return Zero Team},
|
| 312 |
+
year={2024},
|
| 313 |
+
url={https://huggingface.co/rtzr/ko-gemma-2-9b-it}
|
| 314 |
+
}
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
```none
|
| 318 |
+
@article{gemma_2024,
|
| 319 |
+
title={Gemma},
|
| 320 |
+
url={https://www.kaggle.com/m/3301},
|
| 321 |
+
DOI={10.34740/KAGGLE/M/3301},
|
| 322 |
+
publisher={Kaggle},
|
| 323 |
+
author={Gemma Team},
|
| 324 |
+
year={2024}
|
| 325 |
+
}
|
| 326 |
+
```
|