KU-HIAI/Ko-Gemma

34

26 commits

updated Feb 27, 2024

See the code

README

Ko-Gemma

Huggingface Huggingface

logo

Ko-Gemma: Korean Gemma ๐Ÿ‡ฐ๐Ÿ‡ท๐Ÿค–

| ํ•œ๊ตญ์–ด | English |

What's New

  • February 2024: [๐Ÿš€ Model Release ๐Ÿš€] We are excited to announce the release of our initial models for the Korean language processing community! Check them out:

Ko-Gemma

  • Gemma๋Š” Gemini ๋ชจ๋ธ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ ๋™์ผํ•œ ์—ฐ๊ตฌ์™€ ๊ธฐ์ˆ ๋กœ ๊ตฌ์ถ•๋œ ๊ฒฝ๋Ÿ‰ํ™”๋œ ์ตœ์‹  ๋Œ€๊ทœ๋ชจ ์–ธ์–ด๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.
  • Ko-Gemma๋Š” Google์˜ Gemma์— ์˜ํ•ด ๊ฐœ๋ฐœ๋œ ํ•œ๊ตญ์–ด ๋Œ€๊ทœ๋ชจ ์–ธ์–ด ๋ชจ๋ธ๋กœ, ๊ณ ๋ ค๋Œ€ํ•™๊ต NLP & AI LAB์™€ HIAI ์—ฐ๊ตฌ์†Œ๊ฐ€ ํ˜‘๋ ฅํ•˜์—ฌ KULLM ๋ฐ์ดํ„ฐ์…‹ ๋ฐ ์ˆ˜์ œ์ž‘ํ•œ ๋ฐ์ดํ„ฐ์…‹์„ ํ™œ์šฉํ•˜์—ฌ ํ•œ๊ตญ์–ด ์„ฑ๋Šฅ์„ ๋”์šฑ ํ–ฅ์ƒ์‹œํ‚จ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค.
  • Ko-Gemma v1์€ chat_template๋งŒ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•™์Šต๋˜์—ˆ์œผ๋ฏ€๋กœ, tokenizer.chat_template์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ƒ์„ฑ ๋˜๋Š” ํ‰๊ฐ€ ์ž‘์—…์—์„œ๋Š” ์„ฑ๋Šฅ์ด ํฌ๊ฒŒ ๋‚ฎ์•„์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์•ž์œผ๋กœ ์šฐ๋ฆฌ๋Š” ํ•œ๊ตญ์–ด ๋ฐ์ดํ„ฐ๋กœ ์‚ฌํ›„ ํ•™์Šต ๋ชจ๋ธ, ๋‹ค์–‘ํ•œ ํ•œ๊ตญ์–ด ์ง€์‹œ์–ด ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ ํŠœ๋‹๋œ ๋ชจ๋ธ, ํ•œ๊ตญ์–ด์— ๋” ์ตœ์ ํ™”๋œ ์ „์ด ๋ชจ๋ธ์„ ์ถœ์‹œํ•  ๊ณ„ํš์ž…๋‹ˆ๋‹ค.

Quick start

from transformers import AutoTokenizer, pipeline
import torch

model_and_tokenizer_path = "nlpai-lab/ko-gemma-7b-v1"

tokenizer = AutoTokenizer.from_pretrained(model_and_tokenizer_path)
pipeline = pipeline(
    "text-generation",
    model=model_and_tokenizer_path,
    tokenizer=tokenizer,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device="cuda",
)

tokenizer = AutoTokenizer.from_pretrained(model_and_tokenizer_path)
messages = [
    {"role": "user", 
     "content": "์ด์ˆœ์‹  ์žฅ๊ตฐ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) # Don't use `pipeline.tokenizer`
print(prompt) # <bos><start_of_turn>user\n์ด์ˆœ์‹  ์žฅ๊ตฐ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”.<end_of_turn>\n<start_of_turn>model\n

outputs = pipeline(
    prompt,
    max_new_tokens=4096,
    add_special_tokens=True
)
print(outputs[0]["generated_text"][len(prompt):]) # '์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์กฐ์„  ์‹œ๋Œ€์˜ ๋Œ€ํ‘œ์ ์ธ ๊ตฐ์‚ฌ ์ง€๋„์ž์ด์ž ์ „๋žต๊ฐ€์ž…๋‹ˆ๋‹ค. ๊ทธ๋Š” ์กฐ์„  ์‹œ๋Œ€์˜ ์ˆ˜๋„์ธ ํ•œ์–‘์—์„œ ํƒœ์–ด๋‚ฌ์œผ๋ฉฐ, ์กฐ์„  ์‹œ๋Œ€ ๊ตฐ๋Œ€์—์„œ ๋‹ค์–‘ํ•œ ์ง€๋„์ž๋กœ ํ™œ๋™ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์˜ ๊ฐ€์žฅ ์ฃผ๋ชฉํ•  ๋งŒํ•œ ์—…์  ์ค‘ ํ•˜๋‚˜๋Š” 1592๋…„๋ถ€ํ„ฐ 1598๋…„๊นŒ์ง€ ์ผ๋ณธ์ด ์กฐ์„ ์„ ์นจ๊ณตํ•œ ์ผ๋ณธ ์ „์Ÿ์—์„œ์˜ ํ™œ๋™์ž…๋‹ˆ๋‹ค. ์ด ์ „์Ÿ์—์„œ ์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋žต์ ์ธ ์ง€๋„์ž๋กœ ํ™œ๋™ํ•˜๋ฉฐ ์ผ๋ณธ์˜ ์นจ๋žต์— ์ €ํ•ญํ•˜๋Š” ๋ฐ ํฐ ์—ญํ• ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์ „ํˆฌ์—์„œ์˜ ์šฉ๊ธฐ์™€ ์ „์ˆ ์  ์ง€์„ฑ์œผ๋กœ ์œ ๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Š” ์ „ํˆฌ์—์„œ ์ „์ˆ ์ ์ธ ์‚ฌ๊ณ ๋ฅผ ๋ฐœํœ˜ํ•˜๊ณ  ์ ์˜ ์•ฝ์ ์„ ๊ณต๊ฒฉํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์œ ๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ๊ทธ๋Š” ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋ ฅ์„ ๊ณ ์ทจํ•˜๊ณ  ์ „ํˆฌ์—์„œ ์Šน๋ฆฌํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ์—ฐ์„ค๊ณผ ๊ฒฉ๋ ค์˜ ๋ง์„ ์ „ํ•˜๋Š” ๊ฒƒ์œผ๋กœ๋„ ์œ ๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์ „์Ÿ์ด ๋๋‚œ ํ›„์—๋„ ์กฐ์„  ๊ตฐ๋Œ€์—์„œ ๊ณ„์† ํ™œ๋™ํ•˜๋ฉฐ ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ง€๋„์ž๋กœ ํ™œ๋™ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Š” ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋ ฅ์„ ์œ ์ง€ํ•˜๊ณ  ์กฐ์„ ์˜ ์•ˆ๋ณด๋ฅผ ์ง€ํ‚ค๋Š” ๋ฐ ํฐ ์—ญํ• ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์กฐ์„  ์‹œ๋Œ€์˜ ๋Œ€ํ‘œ์ ์ธ ๊ตฐ์‚ฌ ์ง€๋„์ž์ด์ž ์ „๋žต๊ฐ€๋กœ ๊ธฐ์–ต๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ์˜ ์šฉ๊ธฐ์™€ ์ „์ˆ ์  ์ง€์„ฑ, ๊ทธ๋ฆฌ๊ณ  ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋ ฅ์„ ์œ ์ง€ํ•˜๋Š” ๋ฐ ๊ธฐ์—ฌํ•œ ๊ณต๋กœ๋Š” ๊ทธ๋ฅผ ์ „์„ค์ ์ธ ์ธ๋ฌผ๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.'

KoBEST์— ๋Œ€ํ•œ LLM ์ถ”๋ก  ๊ฒฐ๊ณผ

ํ•œ๊ตญ์–ด ๊ท ํ˜• ํ‰๊ฐ€ ์ž‘์—…(KoBEST: Korean Balanced Evaluation of Significant Task, M.Jang et. al)์— ๋Œ€ํ•ด 5-shot์œผ๋กœ ํ‰๊ฐ€๋œ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.

ModelWIC AccWIC F1Sentineg AccSentineg F1Hellaswag AccHellaswag F1COPA AccBoolQ AccBoolQ F1Avg F1Avg F1 (Excl. Sentineg, WIC)
google/gemma-2b-it0.5280.5200.6550.6310.350.3470.420.5260.5250.5360.510
google/gemma-7b-it0.5080.5060.7360.7220.3520.3490.420.5440.5430.5730.545
nlpai-lab/ko-gemma-2b-v10.5210.4200.5870.5170.3540.3500.4560.5950.5940.5060.532
nlpai-lab/ko-gemma-7b-v10.5630.5420.7880.7800.390.3880.4880.6390.6380.6290.608

License

License Copyright 2024 DeepMind Technologies Limited

This code is 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.

KU-HIAI/Ko-Gemma

34

26 commits

updated Feb 27, 2024

See the code

README

Ko-Gemma

Huggingface Huggingface

logo

Ko-Gemma: Korean Gemma ๐Ÿ‡ฐ๐Ÿ‡ท๐Ÿค–

| ํ•œ๊ตญ์–ด | English |

What's New

  • February 2024: [๐Ÿš€ Model Release ๐Ÿš€] We are excited to announce the release of our initial models for the Korean language processing community! Check them out:

Ko-Gemma

  • Gemma๋Š” Gemini ๋ชจ๋ธ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ ๋™์ผํ•œ ์—ฐ๊ตฌ์™€ ๊ธฐ์ˆ ๋กœ ๊ตฌ์ถ•๋œ ๊ฒฝ๋Ÿ‰ํ™”๋œ ์ตœ์‹  ๋Œ€๊ทœ๋ชจ ์–ธ์–ด๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.
  • Ko-Gemma๋Š” Google์˜ Gemma์— ์˜ํ•ด ๊ฐœ๋ฐœ๋œ ํ•œ๊ตญ์–ด ๋Œ€๊ทœ๋ชจ ์–ธ์–ด ๋ชจ๋ธ๋กœ, ๊ณ ๋ ค๋Œ€ํ•™๊ต NLP & AI LAB์™€ HIAI ์—ฐ๊ตฌ์†Œ๊ฐ€ ํ˜‘๋ ฅํ•˜์—ฌ KULLM ๋ฐ์ดํ„ฐ์…‹ ๋ฐ ์ˆ˜์ œ์ž‘ํ•œ ๋ฐ์ดํ„ฐ์…‹์„ ํ™œ์šฉํ•˜์—ฌ ํ•œ๊ตญ์–ด ์„ฑ๋Šฅ์„ ๋”์šฑ ํ–ฅ์ƒ์‹œํ‚จ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค.
  • Ko-Gemma v1์€ chat_template๋งŒ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•™์Šต๋˜์—ˆ์œผ๋ฏ€๋กœ, tokenizer.chat_template์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ƒ์„ฑ ๋˜๋Š” ํ‰๊ฐ€ ์ž‘์—…์—์„œ๋Š” ์„ฑ๋Šฅ์ด ํฌ๊ฒŒ ๋‚ฎ์•„์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์•ž์œผ๋กœ ์šฐ๋ฆฌ๋Š” ํ•œ๊ตญ์–ด ๋ฐ์ดํ„ฐ๋กœ ์‚ฌํ›„ ํ•™์Šต ๋ชจ๋ธ, ๋‹ค์–‘ํ•œ ํ•œ๊ตญ์–ด ์ง€์‹œ์–ด ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ ํŠœ๋‹๋œ ๋ชจ๋ธ, ํ•œ๊ตญ์–ด์— ๋” ์ตœ์ ํ™”๋œ ์ „์ด ๋ชจ๋ธ์„ ์ถœ์‹œํ•  ๊ณ„ํš์ž…๋‹ˆ๋‹ค.

Quick start

from transformers import AutoTokenizer, pipeline
import torch

model_and_tokenizer_path = "nlpai-lab/ko-gemma-7b-v1"

tokenizer = AutoTokenizer.from_pretrained(model_and_tokenizer_path)
pipeline = pipeline(
    "text-generation",
    model=model_and_tokenizer_path,
    tokenizer=tokenizer,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device="cuda",
)

tokenizer = AutoTokenizer.from_pretrained(model_and_tokenizer_path)
messages = [
    {"role": "user", 
     "content": "์ด์ˆœ์‹  ์žฅ๊ตฐ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) # Don't use `pipeline.tokenizer`
print(prompt) # <bos><start_of_turn>user\n์ด์ˆœ์‹  ์žฅ๊ตฐ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”.<end_of_turn>\n<start_of_turn>model\n

outputs = pipeline(
    prompt,
    max_new_tokens=4096,
    add_special_tokens=True
)
print(outputs[0]["generated_text"][len(prompt):]) # '์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์กฐ์„  ์‹œ๋Œ€์˜ ๋Œ€ํ‘œ์ ์ธ ๊ตฐ์‚ฌ ์ง€๋„์ž์ด์ž ์ „๋žต๊ฐ€์ž…๋‹ˆ๋‹ค. ๊ทธ๋Š” ์กฐ์„  ์‹œ๋Œ€์˜ ์ˆ˜๋„์ธ ํ•œ์–‘์—์„œ ํƒœ์–ด๋‚ฌ์œผ๋ฉฐ, ์กฐ์„  ์‹œ๋Œ€ ๊ตฐ๋Œ€์—์„œ ๋‹ค์–‘ํ•œ ์ง€๋„์ž๋กœ ํ™œ๋™ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์˜ ๊ฐ€์žฅ ์ฃผ๋ชฉํ•  ๋งŒํ•œ ์—…์  ์ค‘ ํ•˜๋‚˜๋Š” 1592๋…„๋ถ€ํ„ฐ 1598๋…„๊นŒ์ง€ ์ผ๋ณธ์ด ์กฐ์„ ์„ ์นจ๊ณตํ•œ ์ผ๋ณธ ์ „์Ÿ์—์„œ์˜ ํ™œ๋™์ž…๋‹ˆ๋‹ค. ์ด ์ „์Ÿ์—์„œ ์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋žต์ ์ธ ์ง€๋„์ž๋กœ ํ™œ๋™ํ•˜๋ฉฐ ์ผ๋ณธ์˜ ์นจ๋žต์— ์ €ํ•ญํ•˜๋Š” ๋ฐ ํฐ ์—ญํ• ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์ „ํˆฌ์—์„œ์˜ ์šฉ๊ธฐ์™€ ์ „์ˆ ์  ์ง€์„ฑ์œผ๋กœ ์œ ๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Š” ์ „ํˆฌ์—์„œ ์ „์ˆ ์ ์ธ ์‚ฌ๊ณ ๋ฅผ ๋ฐœํœ˜ํ•˜๊ณ  ์ ์˜ ์•ฝ์ ์„ ๊ณต๊ฒฉํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์œ ๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ๊ทธ๋Š” ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋ ฅ์„ ๊ณ ์ทจํ•˜๊ณ  ์ „ํˆฌ์—์„œ ์Šน๋ฆฌํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ์—ฐ์„ค๊ณผ ๊ฒฉ๋ ค์˜ ๋ง์„ ์ „ํ•˜๋Š” ๊ฒƒ์œผ๋กœ๋„ ์œ ๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์ „์Ÿ์ด ๋๋‚œ ํ›„์—๋„ ์กฐ์„  ๊ตฐ๋Œ€์—์„œ ๊ณ„์† ํ™œ๋™ํ•˜๋ฉฐ ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ง€๋„์ž๋กœ ํ™œ๋™ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Š” ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋ ฅ์„ ์œ ์ง€ํ•˜๊ณ  ์กฐ์„ ์˜ ์•ˆ๋ณด๋ฅผ ์ง€ํ‚ค๋Š” ๋ฐ ํฐ ์—ญํ• ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์ด์ˆœ์‹  ์žฅ๊ตฐ์€ ์กฐ์„  ์‹œ๋Œ€์˜ ๋Œ€ํ‘œ์ ์ธ ๊ตฐ์‚ฌ ์ง€๋„์ž์ด์ž ์ „๋žต๊ฐ€๋กœ ๊ธฐ์–ต๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ์˜ ์šฉ๊ธฐ์™€ ์ „์ˆ ์  ์ง€์„ฑ, ๊ทธ๋ฆฌ๊ณ  ์กฐ์„  ๊ตฐ๋Œ€์˜ ์ „๋ ฅ์„ ์œ ์ง€ํ•˜๋Š” ๋ฐ ๊ธฐ์—ฌํ•œ ๊ณต๋กœ๋Š” ๊ทธ๋ฅผ ์ „์„ค์ ์ธ ์ธ๋ฌผ๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.'

KoBEST์— ๋Œ€ํ•œ LLM ์ถ”๋ก  ๊ฒฐ๊ณผ

ํ•œ๊ตญ์–ด ๊ท ํ˜• ํ‰๊ฐ€ ์ž‘์—…(KoBEST: Korean Balanced Evaluation of Significant Task, M.Jang et. al)์— ๋Œ€ํ•ด 5-shot์œผ๋กœ ํ‰๊ฐ€๋œ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.

ModelWIC AccWIC F1Sentineg AccSentineg F1Hellaswag AccHellaswag F1COPA AccBoolQ AccBoolQ F1Avg F1Avg F1 (Excl. Sentineg, WIC)
google/gemma-2b-it0.5280.5200.6550.6310.350.3470.420.5260.5250.5360.510
google/gemma-7b-it0.5080.5060.7360.7220.3520.3490.420.5440.5430.5730.545
nlpai-lab/ko-gemma-2b-v10.5210.4200.5870.5170.3540.3500.4560.5950.5940.5060.532
nlpai-lab/ko-gemma-7b-v10.5630.5420.7880.7800.390.3880.4880.6390.6380.6290.608

License

License Copyright 2024 DeepMind Technologies Limited

This code is 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.