Edit model card

#GemmaSprint

gemma ์ฒซ๋ฒˆ์งธ ํŒŒ์ธํŠœ๋‹ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.

์ปคํ”ผ์— ๋Œ€ํ•œ ์ „๋ฐ˜์ ์ธ ์ง€์‹๊ณผ ์ปคํ”ผ ์›๋‘๋ฅผ ์ถ”์ฒœํ•ด์ฃผ๋Š” ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค.

2b ๋ชจ๋ธ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํŒŒ์ธํŠœ๋‹์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์—…๋กœ๋“œํ•œ ๋ชจ๋ธ์€ ๊ธฐ๋ณธ๋ชจ๋ธ์ธ "google/gemma-2b-it"๋กœ ํŒŒ์ธํŠœ๋‹์„ ํ•˜์˜€๊ณ , ์ ฌ๋งˆ ํ•œ๊ตญ์–ด ๋ฒ„์ „์„ ๋งŒ๋“ค์–ด ๋†“์œผ์‹ ๊ฒŒ ์žˆ์–ด์„œ ๊ฑฐ๊ธฐ์„œ ๋” ํ™•์žฅ์„ ์‹œ๋„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

-.gemma ํ•œ๊ตญ์–ด ๋ฒ„์ „ https://huggingface.co/beomi/gemma-ko-2b

  • ํŠœ๋‹ํ›„ ๋Œ€ํ™” : ์•„์ง ์–ด์ƒ‰ํ•œ ๋ถ€๋ถ„์ด ์•„์ง ๋งŽ์€ ๋Š๋‚Œ์ž…๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ์™€ ํŠœ๋‹ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์กฐ์ •ํ•ด์„œ ํ–ฅํ›„ ๋” ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋งŒ๋“ค์–ด ๋ณผ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. image/png

  • ๋ฐ์ดํ„ฐ

: ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜์Œ์— ๊ณ ๋ฏผ์„ ๋งŽ์ด ํ•˜๋‹ค๊ฐ€ ์ธํ„ฐ๋„ท์— ๊ณต์œ ๋˜์–ด ์žˆ๋Š” ์ปคํ”ผ ์ „๋ฐ˜์ ์ธ ์ง€์‹์„ ํ•˜๋‚˜์”ฉ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค. ๊ทธํ›„์— gpt๋กœ ์ ์ ˆํžˆ finetunning ๋ชจ๋ธ์„ ์œ„ํ•œ ๊ตฌ์กฐ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ƒ์„ฑํ•˜๊ฒŒ ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋”ฐ๋กœ gpt api๋ฅผ ์“ฐ์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ์‹œ๊ฐ„์ด ์ œ๋ฒ•์†Œ์š” ๋˜์—ˆ์Šต๋‹ˆ๋‹ค๋งŒ, ๋‚˜๋ฆ„ ๊ดœ์ฐฎ์€ ํ€„๋ฆฌํ‹ฐ์˜ ๋ฐ์ดํ„ฐ๋ผ๊ณ  ์ƒ๊ฐํ•ด์„œ ์ด๋Ÿฐ ๋ฐฉ์‹์œผ๋กœ ์•ฝ 2์ฒœ๊ฐœ ๊ฐ€๋Ÿ‰์˜ ์ปคํ”ผ ์ „๋ฐ˜์ ์ธ ์ง€์‹์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ™•๋ณดํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

image/png

context๋„ ์›๋ž˜๋Š” ์žˆ์—ˆ๋Š”๋ฐ ๊ทธ๋‹ค์ง€ ๋งŽ์ด ์“ฐ์ด์ง€ ์•Š๋Š” ๊ฒƒ๊ฐ™์•„์„œ Instruction๊ณผ response๋กœ ๊ตฌ์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

  • ์ž์›

์ฒ˜์Œ์— kaggle๊ณผ colab์—์„œ ์ง„ํ–‰์„ ํ•˜๋‹ค๊ฐ€ ๊ฐœ์ธ ๋งฅ๋ถํ”„๋กœ๊ฐ€ ๋” ๋น ๋ฅผ๊ฒƒ ๊ฐ™์•„์„œ ์˜ฎ๊ฒผ์Šต๋‹ˆ๋‹ค. ์ด๋ถ„์˜ ์ฝ”๋“œ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ˆ˜์ •์„ ํ•˜์˜€์Šต๋‹ˆ๋‹ค. https://devocean.sk.com/blog/techBoardDetail.do?ID=165703&boardType=techBlog

์—ฌ๊ธฐ์„œ ๋งฅ๋ถ์—์„œ ํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ํ•˜๋‚˜ ์žˆ๋Š”๋ฐ ํŠธ๋žœ์Šคํฌ๋จธ๊ฐ€ 4.38.2๊ฐ€ ๋งฅ๋ถ์—์„œ ์•ˆ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ 4.38.1๋กœ ๋‹ค์šดํ•ด์„œ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. https://www.singleye.net/2024/04/%E5%9C%A8-apple-silicon-m3-max-%E4%B8%8A%E5%AF%B9-llama2-%E8%BF%9B%E8%A1%8C%E5%BE%AE%E8%B0%83/#4-qlora-4-bit-%E9%87%8F%E5%8C%96%E9%85%8D%E7%BD%AE-m3-%E8%B7%B3%E8%BF%87

๋งฅ๋ถํ”„๋กœ m3 ๊ธฐ์ค€์œผ๋กœ ํ•ด์„œ 2์ฒœ๊ฐœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•œ๋ฒˆํ• ๋•Œ 3์‹œ๊ฐ„ ์ •๋„ ์†Œ์š”๋๋˜ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. gpu๋„ ๊ฐ™์ด ๋Œ๋ ค์„œ ๊ทธ๋Ÿฐ์ง€ ๊ทธ๋‚˜๋งˆ ๋น ๋ฅด๊ฒŒ ์ง„ํ–‰ ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

macbook gpu ์ž์› ์‚ฌ์šฉ์€ ์•„๋ž˜์˜ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. https://velog.io/@es_seong/Mac

  • ํŒŒ์ธํŠœ๋‹

ํŒŒ์ธํŠœ๋‹์€ ์•„๋ž˜์™€ ๊ฐ™์€ ์„ค์ •์œผ๋กœ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋งฅ์ด๋ผ์„œ ์–‘์žํ™”๊ฐ€ ์•ˆ๋˜์„œ cpu๋กœ ์ง„ํ–‰์„ ํ•˜๊ฒŒ ๋” ํ•˜์˜€๊ณ ,

LoRA ์„ค์ •

lora_config = LoraConfig( r=6, lora_alpha=8, lora_dropout=0.05, target_modules=["q_proj", "o_proj", "k_proj", "v_proj", "gate_proj", "up_proj", "down_proj"], task_type="CAUSAL_LM", )

๋ชจ๋ธ ์„ค์ •

trainer = SFTTrainer( model=model, train_dataset=train_data, max_seq_length=512, args=TrainingArguments( output_dir="outputs", max_steps=3000, per_device_train_batch_size=1, gradient_accumulation_steps=4, optim="adamw_torch", warmup_steps=0.03, learning_rate=2e-4, fp16=False, logging_steps=100, push_to_hub=False, report_to='none', use_mps_device=False
), peft_config=lora_config, formatting_func=generate_prompt, # ์ƒˆ๋กœ์šด ํฌ๋งทํŒ… ํ•จ์ˆ˜ ์ ์šฉ )

์•„๋ž˜์˜ ์„ค์ •๋“ค์„ ์ž ์‹œ ์‚ดํŽด๋ณด์ž๋ฉด

r=6 : r์€ ๋žญํฌ(rank)๋ฅผ ์˜๋ฏธํ•˜๋ฉฐ, LoRA์—์„œ ํ•™์Šตํ•˜๋Š” ์ €์ฐจ์› ํ–‰๋ ฌ์˜ ์ฐจ์›์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋ชจ๋ธ ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ํšจ์œจ์  ํ‘œํ˜„์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋ฉฐ, ์ž‘์€ r ๊ฐ’์€ ์ ์€ ํ•™์Šต ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ r ๊ฐ’์ด ๋†’์„์ˆ˜๋ก ๋” ๋งŽ์€ ํ•™์Šต ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋˜์–ด ์„ฑ๋Šฅ์ด ํ–ฅ์ƒ๋  ์ˆ˜ ์žˆ์ง€๋งŒ, ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ๋Š˜์–ด๋‚ฉ๋‹ˆ๋‹ค.

lora_alpha=8 : lora_alpha๋Š” LoRA์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ•™์Šต๋ฅ ์„ ์กฐ์ •ํ•˜๋Š” ์Šค์ผ€์ผ๋ง ํŒฉํ„ฐ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ์ €์ฐจ์› ํ–‰๋ ฌ์—์„œ ๋‚˜์˜จ ์ถœ๋ ฅ์„ ์กฐ์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•˜๋ฉฐ, ํ•™์Šต๋ฅ ์˜ ํฌ๊ธฐ๋ฅผ ๊ฒฐ์ •์ง“๋Š” ์ค‘์š”ํ•œ ์š”์†Œ์ž…๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ๋” ํฐ ๊ฐ’์€ ํ•™์Šต ์†๋„๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ์ง€๋งŒ, ๋„ˆ๋ฌด ํฌ๋ฉด ๊ณผ์ ํ•ฉ ์œ„ํ—˜์ด ์žˆ์Šต๋‹ˆ๋‹ค.

lora_dropout=0.05 : lora_dropout์€ ๋“œ๋กญ์•„์›ƒ ๋น„์œจ์„ ์„ค์ •ํ•˜๋ฉฐ, ๋ชจ๋ธ ํ•™์Šต ์‹œ ๊ณผ์ ํ•ฉ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด ์ผ๋ถ€ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ฌด์ž‘์œ„๋กœ ์ œ๊ฑฐํ•˜๋Š” ๋น„์œจ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” 5%์˜ ๋“œ๋กญ์•„์›ƒ์ด ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

target_modules=["q_proj", "o_proj", "k_proj", "v_proj", "gate_proj", "up_proj", "down_proj"] : target_modules๋Š” LoRA๊ฐ€ ์ ์šฉ๋˜๋Š” ๋ชจ๋“ˆ๋“ค์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” q_proj, k_proj, v_proj ๋“ฑ ์ฃผ๋กœ Transformer ๊ธฐ๋ฐ˜ ๋ชจ๋ธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ฟผ๋ฆฌ, ํ‚ค, ๋ฐธ๋ฅ˜ ํ”„๋กœ์ ์…˜ ๋ชจ๋“ˆ์— LoRA๊ฐ€ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ชจ๋“ˆ์€ ์ฃผ๋กœ ์–ดํ…์…˜ ๋งค์ปค๋‹ˆ์ฆ˜์—์„œ ์ค‘์š”ํ•œ ์—ญํ• ์„ ํ•˜๋ฉฐ, ์ด ๋ชจ๋“ˆ๋“ค๋งŒ ํ•™์Šตํ•จ์œผ๋กœ์จ ํ•™์Šต ํšจ์œจ์„ฑ์„ ๋†’์ž…๋‹ˆ๋‹ค.

task_type="CAUSAL_LM" : task_type์€ ์ˆ˜ํ–‰ํ•˜๋ ค๋Š” ์ž‘์—…์˜ ์œ ํ˜•์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” **Causal Language Modeling(CAUSAL_LM)**์„ ์˜๋ฏธํ•˜๋ฉฐ, ๋ชจ๋ธ์ด ๋ฌธ๋งฅ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋‹ค์Œ ๋‹จ์–ด๋ฅผ ์˜ˆ์ธกํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ•™์Šต๋ฉ๋‹ˆ๋‹ค.

  • ์„ฑ๋Šฅ

perflexity ์ธก์ •๊ฒฐ๊ณผ 874

  • ์ฐธ๊ณ ํ•œ ๋‚ด์šฉ๋“ค

-.์บ๊ธ€์—์„œ TPU๋กœ ํŒŒ์ธํŠœ๋‹ https://www.kaggle.com/code/alirezaebrahimi/gemma-2-tpu-fine-tuning

-.์ปคํ”ผ ๊ด€๋ จ๋œ ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค(์›๋‘์˜ ๋ง›์„ ์ ์ˆ˜๋กœ ๋‚˜ํƒ€๋ƒ„, ๋ฐ์ดํ„ฐ๋Š” ์ด๊ฒƒ์œผ๋กœ ํ•˜์ง€ ์•Š์Œ.) https://github.com/ddthang86/Coffee-data-analysis/blob/main/Arabica/df_arabica_clean.csv

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Unable to determine this model's library. Check the docs .

Model tree for joeykims/BEANs

Base model

google/gemma-2b-it
Finetuned
(48)
this model

Dataset used to train joeykims/BEANs