C.W.K.
Stream
Lesson 05 of 05 · published

저장, Push, 변환

~22 min · hub, gguf, ollama, conversion, quantization

Level 0관찰자
0 XP0/43 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Hugging Face Hub에 Push

Hub는 모델 레지스트리. LoRA adapter(작음) 또는 merged 모델(더 큼) push하고 model card로 문서화.

Ollama / llama.cpp용 GGUF 변환

파인튜닝 모델을 Ollama나 llama.cpp에서 돌리려면 GGUF 포맷 필요. 2단계: LoRA를 베이스에 merge한 다음, llama.cpp의 변환기로 HF 포맷 → GGUF.

GGUF 양자화 선택

포맷크기 (7B)품질속도
Q2_K~2.7 GB낮음가장 빠름
Q4_K_M~4.1 GB괜찮음빠름
Q5_K_M~4.8 GB매우 좋음중간
Q6_K~5.5 GB훌륭함느림
Q8_0~7.2 GB거의 무손실가장 느림

Q4_K_M이 가장 많이 쓰는 균형점. RAM 있고 품질 원하면 Q6_K.

Code

Push LoRA + merged model to Hub·python
# Push LoRA adapter (small)
trainer.push_to_hub("your-username/my-lora-adapter")

# Or push merged model (larger)
merged = model.merge_and_unload()
merged.push_to_hub("your-username/my-merged-model")
tokenizer.push_to_hub("your-username/my-merged-model")
Convert merged model to GGUF + quantize·bash
# Step 1: clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp

# Step 2: convert HF model to GGUF
python convert_hf_to_gguf.py /path/to/merged-model \
    --outtype f16 \
    --outfile model-f16.gguf

# Step 3: quantize for efficient inference
./llama-quantize model-f16.gguf model-Q4_K_M.gguf Q4_K_M
# Or for Apple Silicon with plenty of RAM:
./llama-quantize model-f16.gguf model-Q6_K.gguf Q6_K
Deploy with Ollama·bash
# Create a Modelfile
cat > Modelfile << 'EOF'
FROM ./model-Q4_K_M.gguf

TEMPLATE """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{{ .System }}<|eot_id|><|start_header_id|>user<|end_header_id|>
{{ .Prompt }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
"""

PARAMETER temperature 0.7
PARAMETER stop "<|eot_id|>"
SYSTEM "You are my fine-tuned assistant."
EOF

# Build and run
ollama create my-finetuned -f Modelfile
ollama run my-finetuned

External links

Exercise

이전 레슨의 merged 모델 가져와 GGUF로 변환, Q4_K_M으로 양자화, Ollama로 로컬 실행. 5개 프롬프트에서 출력을 원래 HF 포맷 모델이랑 비교. Q4_K_M에선 품질 저하 작아야 함; 발견한 거 다 문서화.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.