jp1924/ChartImageTextpairData
Viewer • Updated • 270k • 7 • 1
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-sft 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-sft")
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-sft")
model = AutoModelForMultimodalLM.from_pretrained("ProtenLabs/gemma-4-E4B-it-image2text-ko-sft")
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]:]))How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-sft with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ProtenLabs/gemma-4-E4B-it-image2text-ko-sft"
# 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-sft",
"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"
}
}
]
}
]
}'docker model run hf.co/ProtenLabs/gemma-4-E4B-it-image2text-ko-sft
How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-sft with SGLang:
# 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-sft" \
--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-sft",
"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"
}
}
]
}
]
}'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-sft" \
--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-sft",
"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"
}
}
]
}
]
}'How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-sft with Unsloth Studio:
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-sft to start chatting
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-sft to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ProtenLabs/gemma-4-E4B-it-image2text-ko-sft to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="ProtenLabs/gemma-4-E4B-it-image2text-ko-sft",
max_seq_length=2048,
)How to use ProtenLabs/gemma-4-E4B-it-image2text-ko-sft with Docker Model Runner:
docker model run hf.co/ProtenLabs/gemma-4-E4B-it-image2text-ko-sft
차트 이미지를 입력받아 한국어로 차트 내용을 설명하는 비전-언어 모델(VLM).
google/gemma-4-E4B-it를 jp1924/ChartImageTextpairData로
QLoRA SFT한 뒤 LoRA를 병합한 16bit 전체 모델(merged full model) 입니다. 베이스 모델 없이 단독으로 로딩됩니다.
| 항목 | 내용 |
|---|---|
| 베이스 | google/gemma-4-E4B-it (멀티모달, 8.08B) |
| 태스크 | 차트 이미지 → 한국어 설명 (image-text-to-text) |
| 학습 데이터 | jp1924/ChartImageTextpairData (train 240,002) |
| 방법 | Unsloth FastVisionModel 4bit QLoRA, LoRA r=32 (vision+language), 1 epoch |
| 병합 | LoRA → base 병합(16bit) |
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% |
* SFT+DPO의 judge는 2,000건 표본 기준 추정값. → DPO 버전
from vllm import LLM, SamplingParams
import base64, io
from PIL import Image
llm = LLM(model="ProtenLabs/gemma-4-E4B-it-image2text-ko-sft",
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 라이선스를 따릅니다.