Instructions to use quantumaikr/KoreanLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use quantumaikr/KoreanLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="quantumaikr/KoreanLM")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("quantumaikr/KoreanLM") model = AutoModelForCausalLM.from_pretrained("quantumaikr/KoreanLM") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use quantumaikr/KoreanLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "quantumaikr/KoreanLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "quantumaikr/KoreanLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/quantumaikr/KoreanLM
- SGLang
How to use quantumaikr/KoreanLM with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "quantumaikr/KoreanLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "quantumaikr/KoreanLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "quantumaikr/KoreanLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "quantumaikr/KoreanLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use quantumaikr/KoreanLM with Docker Model Runner:
docker model run hf.co/quantumaikr/KoreanLM
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("quantumaikr/KoreanLM")
model = AutoModelForCausalLM.from_pretrained("quantumaikr/KoreanLM")
KoreanLM: ํ๊ตญ์ด ์ธ์ด๋ชจ๋ธ ํ๋ก์ ํธ
KoreanLM์ ํ๊ตญ์ด ์ธ์ด๋ชจ๋ธ์ ๊ฐ๋ฐํ๊ธฐ ์ํ ์คํ์์ค ํ๋ก์ ํธ์ ๋๋ค. ํ์ฌ ๋๋ถ๋ถ์ ์ธ์ด๋ชจ๋ธ๋ค์ ์์ด์ ์ด์ ์ ๋ง์ถ๊ณ ์์ด, ํ๊ตญ์ด์ ๋ํ ํ์ต์ด ์๋์ ์ผ๋ก ๋ถ์กฑํ๊ณ ํ ํฐํ ๊ณผ์ ์์ ๋นํจ์จ์ ์ธ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ํ๊ตญ์ด์ ์ต์ ํ๋ ์ธ์ด๋ชจ๋ธ์ ์ ๊ณตํ๊ธฐ ์ํด KoreanLM ํ๋ก์ ํธ๋ฅผ ์์ํ๊ฒ ๋์์ต๋๋ค.
ํ๋ก์ ํธ ๋ชฉํ
ํ๊ตญ์ด์ ํนํ๋ ์ธ์ด๋ชจ๋ธ ๊ฐ๋ฐ: ํ๊ตญ์ด์ ๋ฌธ๋ฒ, ์ดํ, ๋ฌธํ์ ํน์ฑ์ ๋ฐ์ํ์ฌ ํ๊ตญ์ด๋ฅผ ๋ ์ ํํ๊ฒ ์ดํดํ๊ณ ์์ฑํ ์ ์๋ ์ธ์ด๋ชจ๋ธ์ ๊ฐ๋ฐํฉ๋๋ค.
ํจ์จ์ ์ธ ํ ํฐํ ๋ฐฉ์ ๋์ : ํ๊ตญ์ด ํ ์คํธ์ ํ ํฐํ ๊ณผ์ ์์ ํจ์จ์ ์ด๊ณ ์ ํํ ๋ถ์์ด ๊ฐ๋ฅํ ์๋ก์ด ํ ํฐํ ๋ฐฉ์์ ๋์ ํ์ฌ ์ธ์ด๋ชจ๋ธ์ ์ฑ๋ฅ์ ํฅ์์ํต๋๋ค.
๊ฑฐ๋ ์ธ์ด๋ชจ๋ธ์ ์ฌ์ฉ์ฑ ๊ฐ์ : ํ์ฌ ๊ฑฐ๋ํ ์ฌ์ด์ฆ์ ์ธ์ด๋ชจ๋ธ๋ค์ ๊ธฐ์ ์ด ์์ฌ์ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ๋ํ๊ธฐ ์ด๋ ค์ด ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ํ๊ตญ์ด ์ธ์ด๋ชจ๋ธ์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ์ฌ ์ฌ์ฉ์ฑ์ ๊ฐ์ ํ๊ณ , ์์ฐ์ด ์ฒ๋ฆฌ ์์ ์ ๋ ์ฝ๊ฒ ์ ์ฉํ ์ ์๋๋ก ํฉ๋๋ค.
์ฌ์ฉ ๋ฐฉ๋ฒ
KoreanLM์ GitHub ์ ์ฅ์๋ฅผ ํตํด ๋ฐฐํฌ๋ฉ๋๋ค. ํ๋ก์ ํธ๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์ค์นํ์ค ์ ์์ต๋๋ค.
git clone https://github.com/quantumaikr/KoreanLM.git
cd KoreanLM
pip install -r requirements.txt
์์
๋ค์์ transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ฅผ ๋ก๋ฉํ๋ ์์ ์ ๋๋ค.
import transformers
model = transformers.AutoModelForCausalLM.from_pretrained("quantumaikr/KoreanLM")
tokenizer = transformers.AutoTokenizer.from_pretrained("quantumaikr/KoreanLM")
ํ๋ จ (ํ์ธํ๋)
torchrun --nproc_per_node=4 --master_port=1004 train.py \
--model_name_or_path quantumaikr/KoreanLM \
--data_path korean_data.json \
--num_train_epochs 3 \
--cache_dir './data' \
--bf16 True \
--tf32 True \
--per_device_train_batch_size 4 \
--per_device_eval_batch_size 4 \
--gradient_accumulation_steps 8 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 500 \
--save_total_limit 1 \
--learning_rate 2e-5 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--fsdp "full_shard auto_wrap" \
--fsdp_transformer_layer_cls_to_wrap 'OPTDecoderLayer' \
pip install deepspeed
torchrun --nproc_per_node=4 --master_port=1004 train.py \
--deepspeed "./deepspeed.json" \
--model_name_or_path quantumaikr/KoreanLM \
--data_path korean_data.json \
--num_train_epochs 3 \
--cache_dir './data' \
--bf16 True \
--tf32 True \
--per_device_train_batch_size 4 \
--per_device_eval_batch_size 4 \
--gradient_accumulation_steps 8 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 2000 \
--save_total_limit 1 \
--learning_rate 2e-5 \
--weight_decay 0. \
--warmup_ratio 0.03 \
ํ๋ จ (LoRA)
python finetune-lora.py \
--base_model 'quantumaikr/KoreanLM' \
--data_path './korean_data.json' \
--output_dir './KoreanLM-LoRA' \
--cache_dir './data'
์ถ๋ก
python generate.py \
--load_8bit \
--share_gradio \
--base_model 'quantumaikr/KoreanLM' \
--lora_weights 'quantumaikr/KoreanLM-LoRA' \
--cache_dir './data'
์ฌ์ ํ์ต ๋ชจ๋ธ ๊ณต๊ฐ ๋ฐ ์น ๋ฐ๋ชจ
* ๋ฐ๋ชจ ๋งํฌ๋ ์ถํ ๊ณต๊ณ์์
๊ธฐ์ฌ๋ฐฉ๋ฒ
์ด์ ์ ๊ธฐ: KoreanLM ํ๋ก์ ํธ์ ๊ด๋ จ๋ ๋ฌธ์ ์ ์ด๋ ๊ฐ์ ์ฌํญ์ ์ด์๋ก ์ ๊ธฐํด์ฃผ์ธ์.
์ฝ๋ ์์ฑ: ๊ฐ์ ์ฌํญ์ด๋ ์๋ก์ด ๊ธฐ๋ฅ์ ์ถ๊ฐํ๊ธฐ ์ํด ์ฝ๋๋ฅผ ์์ฑํ์ค ์ ์์ต๋๋ค. ์์ฑ๋ ์ฝ๋๋ Pull Request๋ฅผ ํตํด ์ ์ถํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
๋ฌธ์ ์์ฑ ๋ฐ ๋ฒ์ญ: ํ๋ก์ ํธ์ ๋ฌธ์ ์์ฑ์ด๋ ๋ฒ์ญ ์์ ์ ์ฐธ์ฌํ์ฌ ํ๋ก์ ํธ์ ์ง์ ๋์ฌ์ฃผ์ธ์.
ํ ์คํธ ๋ฐ ํผ๋๋ฐฑ: ํ๋ก์ ํธ๋ฅผ ์ฌ์ฉํ๋ฉด์ ๋ฐ๊ฒฌํ ๋ฒ๊ทธ๋ ๊ฐ์ ์ฌํญ์ ํผ๋๋ฐฑํด์ฃผ์๋ฉด ํฐ ๋์์ด ๋ฉ๋๋ค.
๋ผ์ด์ ์ค
KoreanLM ํ๋ก์ ํธ๋ Apache 2.0 License ๋ผ์ด์ ์ค๋ฅผ ๋ฐ๋ฆ ๋๋ค. ํ๋ก์ ํธ๋ฅผ ์ฌ์ฉํ์ค ๋ ๋ผ์ด์ ์ค์ ๋ฐ๋ผ ์ฃผ์์ฌํญ์ ์ง์ผ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
๊ธฐ์ ๋ฌธ์
KoreanLM ํ๋ก์ ํธ์ ๊ด๋ จ๋ ๋ฌธ์์ฌํญ์ด ์์ผ์๋ฉด ์ด๋ฉ์ผ ๋๋ GitHub ์ด์๋ฅผ ํตํด ๋ฌธ์ํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ์ด ํ๋ก์ ํธ๊ฐ ํ๊ตญ์ด ์ธ์ด๋ชจ๋ธ์ ๋ํ ์ฐ๊ตฌ์ ๊ฐ๋ฐ์ ๋์์ด ๋๊ธธ ๋ฐ๋ผ๋ฉฐ, ๋ง์ ๊ด์ฌ๊ณผ ์ฐธ์ฌ ๋ถํ๋๋ฆฝ๋๋ค.
์ด๋ฉ์ผ: hi@quantumai.kr
This repository has implementations inspired by open_llama, Stanford Alpaca and alpaca-lora projects.
- Downloads last month
- 23
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="quantumaikr/KoreanLM")