Instructions to use Infinity08/KAWK-1.5-50M-Korean-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Infinity08/KAWK-1.5-50M-Korean-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Infinity08/KAWK-1.5-50M-Korean-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Infinity08/KAWK-1.5-50M-Korean-Instruct") model = AutoModelForCausalLM.from_pretrained("Infinity08/KAWK-1.5-50M-Korean-Instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Infinity08/KAWK-1.5-50M-Korean-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Infinity08/KAWK-1.5-50M-Korean-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Infinity08/KAWK-1.5-50M-Korean-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Infinity08/KAWK-1.5-50M-Korean-Instruct
- SGLang
How to use Infinity08/KAWK-1.5-50M-Korean-Instruct 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 "Infinity08/KAWK-1.5-50M-Korean-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Infinity08/KAWK-1.5-50M-Korean-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Infinity08/KAWK-1.5-50M-Korean-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Infinity08/KAWK-1.5-50M-Korean-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Infinity08/KAWK-1.5-50M-Korean-Instruct with Docker Model Runner:
docker model run hf.co/Infinity08/KAWK-1.5-50M-Korean-Instruct
KAWK-1.5-50M Korean Instruct
한국어 전용 소형 언어모델을 tokenizer부터 직접 만들 수 있는지 검증한 KAWK-50M 프로젝트의 대화·지시 튜닝 모델입니다. 올바른 causal objective로 복구한 한국어 Base와 5,120-token 장문 CPT를 거친 뒤, 필터링한 한국어 대화·RAG 데이터로 supervised fine-tuning(SFT)했습니다.
50M이라는 크기는 범용 챗봇과 경쟁하기 위한 선택이 아닙니다. 개인이 접근 가능한 GPU에서 한국어 데이터 정제, scratch pretraining, long-context CPT, assistant-only SFT, 평가와 공개까지 전체 pipeline을 반복 검증하기 위한 작은 연구 모델입니다. 이 경험은 이후 KAWK-500M 설계와 학습에 사용했습니다.
간단한 한국어 응답 형식을 학습했지만, 51.5M 파라미터의 실험 모델입니다. 사실성, 복잡한 추론, 안전한 거절, 긴 대화 일관성을 기대하면 안 됩니다.
모델 구조
| 항목 | 값 |
|---|---|
| 아키텍처 | LlamaForCausalLM, decoder-only |
| 파라미터 | 51,542,528 |
| 어휘 | 한국어 SentencePiece Unigram 20,000 |
| 레이어 | 14 |
| Hidden / MLP | 512 / 1,408 |
| Attention / KV heads | 8 / 4 |
| Head dimension | 64 |
| 최대 문맥 | 5,120 tokens |
| 위치 표현 | RoPE, theta 10,000 |
| 입력·출력 임베딩 | 공유 |
한국어 20K 어휘를 사용해 50M parameter budget에서 embedding 비중을 낮추고 Transformer를 14층으로 구성했습니다. 한국어 문서에 자연스럽게 포함된 영문·숫자는 유지하지만 영어·코드·수학 전용 사전학습 말뭉치는 사용하지 않았습니다.
학습 단계
- 한국어 중심 데이터와 자체 20K tokenizer로 Base 사전학습
- causal label 이중 shift 오류 확인 및 objective 수정
- 100M A/B 검증 → 1B recovery → 추가 5B recovery
- 한국어 데이터 3B tokens로 5,120-context full-parameter CPT
- 한국어 대화·RAG packed dataset으로 assistant-only SFT
초기의 잘못된 20B Base + 3B CPT 실험은 정상적인 next-token 학습량으로 계산하지 않습니다. 이 Instruct 모델은 오류를 수정하고 다시 검증한 Base/CPT checkpoint에서 시작했습니다.
SFT 데이터와 설정
사용한 원천은 다음과 같습니다.
원문을 그대로 복제해 학습한 것이 아니라 한국어 비율, 반복, HTML/boilerplate, code/math 중심 내용 등을 필터링하고 개인정보 형태를 마스킹한 뒤 5,120 tokens로 고정 패킹했습니다. 사용자·지침 영역은 loss에서 제외하고 assistant 응답과 EOS에만 loss를 적용했습니다.
| 항목 | 값 |
|---|---|
| Packed dataset capacity | 약 80M tokens |
| Epochs / optimizer steps | 2 / 1,303 |
| 총 packed-token exposure | 약 160M tokens |
| Sequence length | 5,120 |
| Precision / GPU | BF16 / NVIDIA RTX 5090 |
| Learning rate | 5e-5 → 5e-6 cosine |
| Effective batch | 24 sequences |
각 원천 데이터의 revision은 학습 기록에 고정돼 있습니다. 데이터의 라이선스와 이용 조건은 upstream dataset card를 확인해야 합니다.
평가
같은 고정 한국어 SFT validation set에서 assistant 응답 토큰만 평가했습니다.
| 모델 | Validation loss | Perplexity |
|---|---|---|
| SFT 전 5K Base | 2.54827 | 12.7850 |
| KAWK-50M Instruct | 2.32156 | 10.1916 |
Gate는 통과했으며 간단한 질문에 직접 답하는 경향은 개선됐습니다. 그러나 정성 평가에서는 항목 반복, 요구한 문장 수 불이행, 문장 교정 실패, 위험 요청에 대한 불안정한 답변이 확인됐습니다. 낮아진 validation loss를 범용 대화 능력이나 안전성으로 해석하면 안 됩니다.
사용 예시
이 저장소의 50M tokenizer에는 자동 chat template가 포함되어 있지 않으므로 아래 역할 헤더를 직접 사용합니다.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_id = "Infinity08/KAWK-1.5-50M-Korean-Instruct"
tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=False)
model = AutoModelForCausalLM.from_pretrained(repo_id)
prompt = """### 사용자:
대한민국의 수도를 한 문장으로 알려주세요.
### 도우미:
"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=80,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.1,
eos_token_id=tokenizer.eos_token_id,
)
new_tokens = outputs[0, inputs["input_ids"].shape[1]:]
print(tokenizer.decode(new_tokens, skip_special_tokens=True))
System instruction을 넣을 때는 ### 지침:, 사용자 입력은 ### 사용자:, 응답 시작은 ### 도우미: 헤더를 사용합니다.
적합한 용도
- 소형 한국어 instruction tuning 연구
- 제한된 장치에서 한국어 생성 실험
- assistant-only loss와 chat formatting 교육
- 더 큰 KAWK 모델을 위한 pipeline 검증
한계
- 질문의 전제나 세부 지시를 놓치고 같은 문장을 반복할 수 있습니다.
- 지식량과 사실성이 낮으며 그럴듯한 오답을 생성할 수 있습니다.
- 5,120 context는 입력 가능 길이이지 긴 대화의 정확한 기억을 보장하지 않습니다.
- 안전 정렬 모델이 아니며 유해·민감 요청에 안정적으로 대응하지 못합니다.
- 의료·법률·금융·안전 관련 판단에 사용하지 마십시오.
관련 자료
- Downloads last month
- -