Instructions to use ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo") model = AutoModelForMultimodalLM.from_pretrained("ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo
- SGLang
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo 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 "ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo" \ --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": "ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo" \ --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": "ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Unsloth Studio
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo", max_seq_length=2048, ) - Docker Model Runner
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo with Docker Model Runner:
docker model run hf.co/ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo
gemma-4-E4B-it-image2text-ko-dpo
차트 이미지를 입력받아 한국어로 차트 내용을 설명하는 비전-언어 모델(VLM).
google/gemma-4-E4B-it → QLoRA SFT → DPO(선호 정렬) 한 뒤 LoRA를 병합한 16bit 전체 모델(merged full model) 입니다. 베이스 모델 없이 단독 로딩됩니다.
SFT 버전 위에 추가로 선호 학습을 적용했습니다.
모델 개요
| 항목 | 내용 |
|---|---|
| 베이스 | google/gemma-4-E4B-it (멀티모달, 8.08B) |
| 태스크 | 차트 이미지 → 한국어 설명 (image-text-to-text) |
| 학습 데이터 | jp1924/ChartImageTextpairData |
| 1단계 SFT | Unsloth 4bit QLoRA, LoRA r=32, 1 epoch |
| 2단계 DPO | 실패 케이스 타깃 선호쌍 870개로 정렬 (2 epoch) |
DPO 선호 데이터 구성 (failure-targeted)
SFT가 실제로 greedy 디코딩에서 틀리는 케이스만 골라 교정하도록 구성:
- chosen = 정답(ground-truth) 설명
- rejected = SFT의 greedy 출력 중 정답 수치를 일부 누락한 것 (recall < 0.9)
이는 일반적인 on-policy 샘플 선호쌍보다 greedy 출력 자체를 교정하는 데 효과적입니다. (reference = SFT 모델, LR 5e-6. 학습 지표: rewards/accuracy ≈ 1.0, margin↑, chosen 보상 양수 유지 → 과최적화 없음.)
평가 결과 (validation 30,000건)
LLM-as-judge(google/gemma-4-31B-it, 이미지 기반 채점) + metadata 기반 객관 지표.
| 모델 | judge (1-10) | 수치 재현율 | 수치 정밀도 | title | legend |
|---|---|---|---|---|---|
| base (gemma-4-E4B-it) | 6.71 | 76.1% | 75.6% | 58.2% | 90.4% |
| SFT | 9.67 | 98.8% | 88.9% | 67.4% | 96.9% |
| 이 모델 (SFT+DPO) ⭐ | 9.67* | 98.7% | 88.6% | 68.3% | 97.0% |
* judge는 2,000건 표본 기준 추정값(SFT와 사실상 동등).
이 모델의 차별점 — 실패 케이스 타깃 DPO:
- reject = SFT가 실제 greedy로 내놓는 틀린 출력(수치 누락), chosen = 정답(GT)으로 구성.
- SFT 대비 출력 변화율 39.6%(v1은 12.7%) — greedy 분포가 실제로 이동.
- 타깃 실패케이스(883건) recall 60.9 → 65.8% (+4.9pp) 개선.
- 단 SFT가 이미 천장(98.8%)이라 전체 지표는 보합 → 일반 사용 시 SFT와 성능 동등.
사용법 (vLLM, OpenAI 호환)
from vllm import LLM, SamplingParams
import base64, io
from PIL import Image
llm = LLM(model="ProtenLabs/gemma-4-E4B-it-image2text-ko-dpo",
limit_mm_per_prompt={"image": 1}, dtype="bfloat16", max_model_len=4096)
img = Image.open("chart.png").convert("RGB")
buf = io.BytesIO(); img.save(buf, format="PNG")
b64 = base64.b64encode(buf.getvalue()).decode()
messages = [[{"role": "user", "content": [
{"type": "text", "text": "이 차트 이미지를 보고 내용을 한국어로 자세히 설명해 주세요."},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}}]}]]
out = llm.chat(messages, SamplingParams(temperature=0, max_tokens=512))
print(out[0].outputs[0].text)
라이선스
베이스 모델의 Gemma 라이선스를 따릅니다.
- Downloads last month
- 498